Skip to content

Commit

Permalink
feat(UpdateManager): implement python package entries (#2092)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Dej <meteyou@gmail.com>
  • Loading branch information
Jomik and meteyou authored Jan 30, 2025
1 parent ad7186f commit 60f7f37
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
37 changes: 28 additions & 9 deletions src/components/panels/Machine/UpdatePanel/Entry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@
{{ versionOutput }}
</a>
</template>
<template v-else-if="type === 'web' && webUpdatable">
<template v-else-if="type === 'web' && semverUpdatable">
<a class="info--text text-decoration-none" :href="webLinkRelease" target="_blank">
<v-icon small color="info" class="mr-1">{{ mdiUpdate }}</v-icon>
{{ versionOutput }}
</a>
</template>
<template v-else-if="type === 'python' && semverUpdatable">
<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 @@ -269,16 +275,16 @@ export default class UpdatePanelEntry extends Mixins(BaseMixin) {
if (['printing', 'paused'].includes(this.printer_state)) return true
if (!this.isValid || this.isCorrupt || this.isDirty || this.commitsBehind.length) return false
if (this.type === 'web') return !this.webUpdatable
if (['python', 'web'].includes(this.type)) return !this.semverUpdatable
return this.commitsBehind.length === 0
}
get btnIcon() {
if (this.isDetached || !this.isValid || this.isCorrupt || this.isDirty) return mdiCloseCircle
if (this.type === 'web') {
if (this.webUpdatable) return mdiProgressUpload
if (['python', 'web'].includes(this.type)) {
if (this.semverUpdatable) return mdiProgressUpload
else if (this.localVersion === null || this.remoteVersion === null) return mdiHelpCircleOutline
}
Expand All @@ -290,7 +296,7 @@ export default class UpdatePanelEntry extends Mixins(BaseMixin) {
get btnColor() {
if (this.isCorrupt || this.isDetached || this.isDirty || !this.isValid) return 'orange'
if (this.type === 'web' && this.webUpdatable) return 'primary'
if (['python', 'web'].includes(this.type) && this.semverUpdatable) return 'primary'
if (this.type === 'git_repo' && this.commitsBehind.length) return 'primary'
return 'green'
Expand All @@ -302,8 +308,8 @@ export default class UpdatePanelEntry extends Mixins(BaseMixin) {
if (this.isDirty) return this.$t('Machine.UpdatePanel.Dirty')
if (!this.isValid) return this.$t('Machine.UpdatePanel.Invalid')
if (this.type === 'web') {
if (this.webUpdatable) return this.$t('Machine.UpdatePanel.Update')
if (['python', 'web'].includes(this.type)) {
if (this.semverUpdatable) return this.$t('Machine.UpdatePanel.Update')
else if (this.localVersion === null || this.remoteVersion === null)
return this.$t('Machine.UpdatePanel.Unknown')
}
Expand All @@ -321,7 +327,7 @@ export default class UpdatePanelEntry extends Mixins(BaseMixin) {
return this.repo.warnings ?? []
}
get webUpdatable() {
get semverUpdatable() {
if (!this.localVersion) return false
if (!this.remoteVersion) return false
Expand All @@ -332,8 +338,21 @@ export default class UpdatePanelEntry extends Mixins(BaseMixin) {
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
2 changes: 1 addition & 1 deletion src/store/server/updateManager/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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
}
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 60f7f37

Please sign in to comment.