Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Update): implement python package entries #2092

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading