From 4430b850d93ddfa71dd6a81fb442bf726fcecdda Mon Sep 17 00:00:00 2001 From: Jonas Damtoft Date: Sun, 22 Dec 2024 13:17:51 +0100 Subject: [PATCH] feat(Update): implement python package entries Signed-off-by: Jonas Damtoft --- .../panels/Machine/UpdatePanel/Entry.vue | 41 ++++++++++++++++++- src/store/server/updateManager/actions.ts | 5 ++- src/store/server/updateManager/types.ts | 1 + 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/components/panels/Machine/UpdatePanel/Entry.vue b/src/components/panels/Machine/UpdatePanel/Entry.vue index f837eb740..1586a72b0 100644 --- a/src/components/panels/Machine/UpdatePanel/Entry.vue +++ b/src/components/panels/Machine/UpdatePanel/Entry.vue @@ -16,6 +16,12 @@ {{ versionOutput }} + {{ versionOutput }} @@ -270,6 +276,7 @@ export default class UpdatePanelEntry extends Mixins(BaseMixin) { if (!this.isValid || this.isCorrupt || this.isDirty || this.commitsBehind.length) return false if (this.type === 'web') return !this.webUpdatable + if (this.type === 'python') return !this.pythonUpdateable return this.commitsBehind.length === 0 } @@ -282,6 +289,11 @@ export default class UpdatePanelEntry extends Mixins(BaseMixin) { else if (this.localVersion === null || this.remoteVersion === null) return mdiHelpCircleOutline } + if (this.type === 'python') { + if (this.pythonUpdateable) return mdiProgressUpload + else if (this.localVersion === null || this.remoteVersion === null) return mdiHelpCircleOutline + } + if (this.type === 'git_repo' && this.commitsBehind.length) return mdiProgressUpload return mdiCheck @@ -291,6 +303,7 @@ export default class UpdatePanelEntry extends Mixins(BaseMixin) { if (this.isCorrupt || this.isDetached || this.isDirty || !this.isValid) return 'orange' if (this.type === 'web' && this.webUpdatable) return 'primary' + if (this.type === 'python' && this.pythonUpdateable) return 'primary' if (this.type === 'git_repo' && this.commitsBehind.length) return 'primary' return 'green' @@ -308,6 +321,12 @@ export default class UpdatePanelEntry extends Mixins(BaseMixin) { return this.$t('Machine.UpdatePanel.Unknown') } + if (this.type === 'python') { + if (this.pythonUpdateable) return this.$t('Machine.UpdatePanel.Update') + else if (this.localVersion === null || this.remoteVersion === null) + return this.$t('Machine.UpdatePanel.Unknown') + } + if (this.type === 'git_repo' && this.commitsBehind.length) return this.$t('Machine.UpdatePanel.Update') return this.$t('Machine.UpdatePanel.UpToDate') @@ -328,12 +347,32 @@ export default class UpdatePanelEntry extends Mixins(BaseMixin) { return semver.gt(this.remoteVersion, this.localVersion) } + get pythonUpdateable() { + if (!this.localVersion) return false + if (!this.remoteVersion) return false + + return semver.gt(this.remoteVersion, this.localVersion) + } + get repo_name() { return this.repo.repo_name ?? this.repo.name ?? '' } + get githubRepoUrl() { + return `https://github.com/${this.repo.owner}/${this.repo_name}` + } + get webLinkRelease() { - return `https://github.com/${this.repo.owner}/${this.repo_name}/releases/tag/${this.repo.remote_version}` + return `${this.githubRepoUrl}/releases/tag/${this.repo.remote_version}` + } + + get pythonChangelog() { + if (this.repo.channel === 'dev') + return `${this.githubRepoUrl}/compare/${this.repo.current_hash}..${this.repo.remote_hash}` + + if (this.repo.changelog_url) return this.repo.changelog_url + + return this.webLinkRelease } get hideUpdateWarning() { diff --git a/src/store/server/updateManager/actions.ts b/src/store/server/updateManager/actions.ts index 0fdf84543..67dd62150 100644 --- a/src/store/server/updateManager/actions.ts +++ b/src/store/server/updateManager/actions.ts @@ -24,14 +24,17 @@ export const actions: ActionTree = { continue } - if (['web', 'web_beta'].includes(configured_type)) { + if (['web', 'web_beta', 'python'].includes(configured_type)) { await commit('storeWebRepo', { ...module, name: key }) continue } if (key === 'system') { await commit('updateSystem', { ...module }) + continue } + + console.warn(`Module '${key}' has an unknown type '${configured_type}'`) } await dispatch('socket/removeInitModule', 'server/updateManager/init', { root: true }) diff --git a/src/store/server/updateManager/types.ts b/src/store/server/updateManager/types.ts index 91dfbe121..182f74d13 100644 --- a/src/store/server/updateManager/types.ts +++ b/src/store/server/updateManager/types.ts @@ -57,6 +57,7 @@ export interface ServerUpdateManagerStateGitRepo { warnings?: string[] info_tags?: string[] recovery_url?: string + changelog_url?: string } export interface ServerUpdateManagerStateGitRepoGroupedCommits {