Skip to content

Commit

Permalink
feat(Update): implement python package entries
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Damtoft <[email protected]>
  • Loading branch information
Jomik committed Dec 22, 2024
1 parent 4c86d7c commit 4430b85
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
41 changes: 40 additions & 1 deletion src/components/panels/Machine/UpdatePanel/Entry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
{{ versionOutput }}
</a>
</template>
<template v-else-if="type === 'python' && pythonUpdateable">
<a class="info--text text-decoration-none" :href="pythonChangelog" target="_blank">
<v-icon small color="info" class="mr-1">{{ mdiUpdate }}</v-icon>
{{ versionOutput }}
</a>
</template>
<span v-else>{{ versionOutput }}</span>
</v-col>
<v-col class="col-auto pr-6 text-right" align-self="center">
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand All @@ -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'
Expand All @@ -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')
Expand All @@ -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() {
Expand Down
5 changes: 4 additions & 1 deletion src/store/server/updateManager/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ export const actions: ActionTree<ServerUpdateManagerState, RootState> = {
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 })
Expand Down
1 change: 1 addition & 0 deletions src/store/server/updateManager/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface ServerUpdateManagerStateGitRepo {
warnings?: string[]
info_tags?: string[]
recovery_url?: string
changelog_url?: string
}

export interface ServerUpdateManagerStateGitRepoGroupedCommits {
Expand Down

0 comments on commit 4430b85

Please sign in to comment.