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

refactor: display errors and warnings in the update_manager #1453

Merged
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9cf3fc8
refactor: fix typo
meteyou Oct 20, 2022
1ce87ff
refactor: add last_error to ServerUpdateManagerStateVersionInfoWeb
meteyou Oct 20, 2022
58efed8
refactor: WIP
meteyou Oct 23, 2022
08ae41c
refactor: WIP
meteyou Nov 2, 2022
28b6a84
refactor: WIP
meteyou Nov 6, 2022
ccf6eef
WIP
meteyou Feb 7, 2023
6930a9b
Merge branch 'develop' into feat/add-update-manager-last-error
meteyou Feb 11, 2023
6fa0a7d
feat: WIP
meteyou Feb 12, 2023
a211916
Merge branch 'develop' into feat/add-update-manager-last-error
meteyou Feb 19, 2023
2463abd
fix: fix padding between messages
meteyou Feb 19, 2023
d628911
Merge branch 'develop' into feat/add-update-manager-last-error
meteyou Jul 1, 2023
286d261
Merge branch 'develop' into feat/add-update-manager-last-error
meteyou Jul 1, 2023
c23096b
refactor: change date format from ServerUpdateManagerStateGitRepoComm…
meteyou Jul 1, 2023
c4bb277
refactor: move and rename UpdatePanelGit to Git
meteyou Jul 1, 2023
a002711
refactor: move and rename all other UpdatePanelGit components and fin…
meteyou Jul 1, 2023
da5f025
refactor: move and rename all other UpdatePanelGit components and fin…
meteyou Jul 1, 2023
ce30ac6
refactor: finish GitCommitsList
meteyou Jul 1, 2023
259f7b9
refactor: add type web to update manager
meteyou Jul 1, 2023
30459c6
locale: fix dirty warning in update manager
meteyou Jul 2, 2023
6ee834b
refactor: rework system update entry in update manager
meteyou Jul 2, 2023
9430758
refactor: rework update all components button
meteyou Jul 2, 2023
c7d544c
refactor: add link to release notes of web component
meteyou Jul 2, 2023
5c8068b
refactor: remove ServerUpdateManagerStateWebRepo type and merge all t…
meteyou Jul 2, 2023
7b6f171
feat: add warning for each component before you update
meteyou Jul 4, 2023
c202e17
refactor: add updateAll api call
meteyou Jul 4, 2023
26d1911
refactor: add update api call
meteyou Jul 4, 2023
e2b5713
refactor: add hide all update warnings function
meteyou Jul 4, 2023
ef36539
style: fix prettier issue
meteyou Jul 4, 2023
0a32b83
feat: add warnings output to each update_manager entry
meteyou Jul 11, 2023
64cbea5
feat: add info when all components are "unknown" to init the update m…
meteyou Jul 11, 2023
9d3e929
locale(en): remove unused keys
meteyou Jul 11, 2023
531a2d9
locale(de): add german locale
meteyou Jul 11, 2023
68da4d0
locale(de): add german locale
meteyou Jul 11, 2023
951bb7c
locale: remove outdated locale
meteyou Jul 11, 2023
7340244
Apply suggestions from code review
meteyou Jul 16, 2023
4de3367
refactor: remove unused imports
meteyou Jul 16, 2023
314eaa0
refactor: remove unused comment
meteyou Jul 16, 2023
01a615d
refactor: remove unused import
meteyou Jul 16, 2023
9fe9066
refactor: remove old getters/comments
meteyou Jul 16, 2023
0424af7
refactor: remove unused type define
meteyou Jul 16, 2023
c8d09de
refactor: change date type in ServerUpdateManagerStateGitRepoCommit
meteyou Jul 16, 2023
b06bc1a
locale(de): fix typo in locale
meteyou Jul 16, 2023
604d4db
locale(de): change all locale to "du" from
meteyou Jul 16, 2023
eea1339
refactor: fix typo in getter name
meteyou Jul 17, 2023
8116cde
locale(de): Apply suggestions from code review
meteyou Jul 17, 2023
d3fe5e4
locale: fix locale by th33xitus
meteyou Jul 22, 2023
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
8 changes: 6 additions & 2 deletions src/components/TheUpdateDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,14 @@ export default class TheUpdateDialog extends Mixins(BaseMixin) {
this.complete &&
['client', 'mainsail', 'full'].includes(this.application.toLowerCase())
)
window.location.reload(true)
window.location.reload()
else {
this.$store.commit('server/updateManager/resetUpdateResponse')
this.$socket.emit('machine.update.status', { refresh: false }, { action: 'server/updateManager/getStatus' })
this.$socket.emit(
'machine.update.status',
{ refresh: false },
{ action: 'server/updateManager/onUpdateStatus' }
)
}
}

Expand Down
657 changes: 69 additions & 588 deletions src/components/panels/Machine/UpdatePanel.vue

Large diffs are not rendered by default.

366 changes: 366 additions & 0 deletions src/components/panels/Machine/UpdatePanel/Entry.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,366 @@
<template>
<div>
<v-row class="py-2">
<v-col class="pl-6">
<strong>{{ repo.name }}</strong>
<br />
<template v-if="type === 'git_repo' && commitsBehind.length">
<a class="primary--text cursor--pointer" @click="boolShowCommitList = true">
<v-icon small color="primary" class="mr-1">{{ mdiInformation }}</v-icon>
{{ versionOutput }}
</a>
</template>
<template v-else-if="type === 'web' && webUpdatable">
<a class="primary--text text-decoration-none" :href="webLinkRelease" target="_blank">
<v-icon small color="primary" class="mr-1">{{ mdiInformation }}</v-icon>
{{ versionOutput }}
</a>
</template>
<span v-else>{{ versionOutput }}</span>
</v-col>
<v-col class="col-auto pr-6 text-right" align-self="center">
<template v-if="needsRecovery">
<v-menu :offset-y="true">
<template #activator="{ on, attrs }">
<v-chip
small
label
outlined
:color="btnColor"
:disabled="btnDisabled"
class="minwidth-0 px-2 text-uppercase"
v-bind="attrs"
v-on="on">
<v-icon small class="mr-1">{{ btnIcon }}</v-icon>
{{ btnText }}
<v-icon small>{{ mdiMenuDown }}</v-icon>
</v-chip>
</template>
<v-list dense class="py-0">
<v-list-item @click="doRecovery(false)">
<v-list-item-icon class="mr-0">
<v-icon small>{{ mdiReload }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Machine.UpdatePanel.SoftRecovery') }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item @click="doRecovery(true)">
<v-list-item-icon class="mr-0">
<v-icon small>{{ mdiReload }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $t('Machine.UpdatePanel.HardRecovery') }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-menu>
</template>
<v-chip
v-else
small
label
outlined
:color="btnColor"
:disabled="btnDisabled"
class="minwidth-0 px-2 text-uppercase"
@click="clickUpdate">
<v-icon small class="mr-1">{{ btnIcon }}</v-icon>
{{ btnText }}
</v-chip>
</v-col>
</v-row>
<v-row v-if="notificationText" class="mt-0">
<v-col class="px-6 pt-0">
<v-alert text dense :color="notificationColor" :icon="notificationIcon" border="left">
{{ notificationText }}
</v-alert>
</v-col>
</v-row>
<v-row v-if="gitMessages.length" class="mt-0">
<v-col class="px-6 pt-0">
<v-alert
v-for="(message, index) in gitMessages"
:key="'message_' + index"
text
dense
border="left"
type="info">
{{ message }}
</v-alert>
</v-col>
</v-row>
<v-row v-if="warnings.length" class="mt-0">
<v-col class="px-6 pt-0">
<v-alert
v-for="(message, index) in warnings"
:key="'warnings_' + index"
text
dense
border="left"
color="orange"
:icon="mdiAlertCircle">
{{ message }}
</v-alert>
</v-col>
</v-row>
<git-commits-list
v-if="type === 'git_repo'"
:bool-show-dialog="boolShowCommitList"
:repo="repo"
@close-dialog="closeCommitList" />
<update-hint
:bool-show-dialog="boolShowUpdateHint"
:repo="repo"
@open-commit-history="boolShowCommitList = true"
@do-update="doUpdate"
@close-dialog="closeShowUpdateHint" />
</div>
</template>

<script lang="ts">
import { Component, Mixins, Prop } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import { ServerUpdateManagerStateGitRepo } from '@/store/server/updateManager/types'
import {
mdiAlertCircle,
mdiCheck,
mdiHelpCircleOutline,
mdiInformation,
mdiMenuDown,
mdiProgressUpload,
mdiReload,
} from '@mdi/js'
import semver from 'semver'
import GitCommitsList from '@/components/panels/Machine/UpdatePanel/GitCommitsList.vue'
import UpdateHint from '@/components/panels/Machine/UpdatePanel/UpdateHint.vue'
@Component({
components: { GitCommitsList, UpdateHint },
})
export default class UpdatePanelEntry extends Mixins(BaseMixin) {
mdiInformation = mdiInformation
mdiMenuDown = mdiMenuDown
mdiReload = mdiReload
mdiAlertCircle = mdiAlertCircle

boolShowCommitList = false
boolShowUpdateHint = false

@Prop({ required: true }) readonly repo!: ServerUpdateManagerStateGitRepo

get name() {
return this.repo.name ?? 'UNKNOWN'
}

get type() {
return this.repo.configured_type
}

get localVersion() {
const version = this.repo.version ?? '?'

if (!semver.valid(version)) return null

return version
}

get remoteVersion() {
const version = this.repo.remote_version ?? '?'

if (!semver.valid(version)) return null

return version
}

get branch() {
return this.repo.branch ?? 'master'
}

get remoteAlias() {
return this.repo.remote_alias ?? 'origin'
}

get branchOutput() {
if (this.remoteAlias !== 'origin') return `${this.remoteAlias}/${this.branch}`
if (!['master', 'main'].includes(this.branch)) return this.branch

return null
}

get commitsBehind() {
return this.repo.commits_behind ?? []
}

get fullVersionString() {
return this.repo.full_version_string ?? null
}

get versionOutput() {
let output = this.branchOutput ? `${this.branchOutput}: ` : ''

if (this.localVersion && this.remoteVersion && semver.gt(this.remoteVersion, this.localVersion)) {
return `${output}${this.localVersion} > ${this.remoteVersion}`
}

if (this.commitsBehind.length) {
const tmp = this.$tc('Machine.UpdatePanel.CommitsAvailable', this.commitsBehind.length, {
count: this.commitsBehind.length,
}).toString()

if (this.localVersion) return `${output}${this.localVersion} > ${tmp}`

return `${output}${tmp}`
}

if (this.fullVersionString) return this.fullVersionString
if (this.localVersion) return this.localVersion

return 'UNKNOWN'
}

get configuredType() {
return this.repo.configured_type ?? 'git_repo'
}

get isValid() {
return this.repo.is_valid ?? true
meteyou marked this conversation as resolved.
Show resolved Hide resolved
}

get isDirty() {
return this.repo.is_dirty ?? false
}

get debugEnabled() {
return this.repo.debug_enabled ?? false
}

get isDetached() {
if (this.configuredType !== 'git_repo') return false

return !this.debugEnabled && (this.repo.detached ?? false)
}

get needsRecovery() {
return !this.isValid || this.isDirty
}

get btnDisabled() {
if (['printing', 'paused'].includes(this.printer_state)) return true
if (!this.isValid || this.isDirty || this.commitsBehind.length) return false

return !(this.localVersion && this.remoteVersion && semver.gt(this.remoteVersion, this.localVersion))
}

get btnIcon() {
if (this.isDetached || !this.isValid || this.isDirty) return mdiAlertCircle

if (
this.commitsBehind.length ||
(this.localVersion && this.remoteVersion && semver.gt(this.remoteVersion, this.localVersion))
)
return mdiProgressUpload

if (this.localVersion === null || this.remoteVersion === null) return mdiHelpCircleOutline

return mdiCheck
}

get btnColor() {
if (this.isDetached || !this.isValid) return 'orange'
if (this.isDirty) return 'red'

if (
this.commitsBehind.length ||
(this.localVersion && this.remoteVersion && semver.gt(this.remoteVersion, this.localVersion))
)
return 'primary'

return 'green'
}

get btnText() {
if (this.isDetached) return this.$t('Machine.UpdatePanel.Detached')
if (!this.isValid) return this.$t('Machine.UpdatePanel.Invalid')
if (this.isDirty) return this.$t('Machine.UpdatePanel.Dirty')
if (
this.commitsBehind.length ||
(this.localVersion && this.remoteVersion && semver.gt(this.remoteVersion, this.localVersion))
)
return this.$t('Machine.UpdatePanel.Update')

if (this.localVersion === null || this.remoteVersion === null) return this.$t('Machine.UpdatePanel.Unknown')

return this.$t('Machine.UpdatePanel.UpToDate')
}

get notificationText() {
if (this.isDetached) return this.$t('Machine.UpdatePanel.Notification.Detached')
if (this.isDirty) return this.$t('Machine.UpdatePanel.Notification.Dirty')

return null
}

get notificationColor() {
return this.btnColor
}

get notificationIcon() {
return this.btnIcon
}

get gitMessages() {
return this.repo.git_messages ?? []
}

get warnings() {
return this.repo.warnings ?? []
}

get webUpdatable() {
if (!this.localVersion) return false
if (!this.remoteVersion) return false

return semver.gt(this.remoteVersion, this.localVersion)
}

get webLinkRelease() {
return `https://github.com/${this.repo.owner}/${this.repo.name}/releases/tag/${this.repo.remote_version}`
}

get hideUpdateWarning() {
return this.$store.state.gui.uiSettings.hideUpdateWarnings ?? false
}

clickUpdate() {
if (this.hideUpdateWarning) {
this.doUpdate()
return
}

this.boolShowUpdateHint = true
}

doUpdate() {
if (['klipper', 'moonraker'].includes(this.repo.name)) {
this.$socket.emit('machine.update.' + this.repo.name, {})
return
}

this.$socket.emit('machine.update.client', { name: this.repo.name })
}

doRecovery(hard: boolean) {
this.$socket.emit('machine.update.recover', { name: this.repo.name, hard: hard })
}

closeCommitList() {
this.boolShowCommitList = false
}

closeShowUpdateHint() {
this.boolShowUpdateHint = false
}
}
</script>

<style scoped></style>
Loading
Loading