Better handle app updates and show update errors in dialog
This commit is contained in:
@@ -19,11 +19,21 @@ const profile = ref({});
|
||||
const busyUpdate = ref(false);
|
||||
const busyCheck = ref(false);
|
||||
const skipBackup = ref(false);
|
||||
const updateError = ref('');
|
||||
const autoUpdatesEnabled = ref(false);
|
||||
watch(autoUpdatesEnabled, async (newValue) => {
|
||||
const [error] = await appsModel.configure(props.app.id, 'automatic_update', { enable: newValue });
|
||||
if (error) return console.error(error);
|
||||
});
|
||||
const autoUpdatesEnabledBusy = ref(false);
|
||||
|
||||
async function onAutoUpdatesEnabledChange(value) {
|
||||
autoUpdatesEnabledBusy.value = true;
|
||||
|
||||
const [error] = await appsModel.configure(props.app.id, 'automatic_update', { enable: value });
|
||||
if (error) {
|
||||
autoUpdatesEnabled.value = !value;
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
autoUpdatesEnabledBusy.value = false;
|
||||
}
|
||||
|
||||
async function refreshUpdates() {
|
||||
const [error, result] = await updaterModel.info();
|
||||
@@ -50,15 +60,21 @@ async function onCheck() {
|
||||
|
||||
async function onUpdate() {
|
||||
busyUpdate.value = true;
|
||||
const [error] = await appsModel.update(props.app.id, update.value.manifest, skipBackup.value);
|
||||
updateError.value = '';
|
||||
|
||||
let [error] = await appsModel.update(props.app.id, update.value.manifest, skipBackup.value);
|
||||
if (error) {
|
||||
busyUpdate.value = false;
|
||||
if (error.status === 400) updateError.value = error.body ? error.body.message : 'Internal error';
|
||||
return console.error(error);
|
||||
}
|
||||
|
||||
await refreshUpdates();
|
||||
update.value = null;
|
||||
|
||||
dialog.value.close();
|
||||
|
||||
[error] = await appsModel.checkForUpdates(props.app.id);
|
||||
if (error) return console.error(error);
|
||||
}
|
||||
|
||||
function onAskUpdate() {
|
||||
@@ -99,13 +115,12 @@ onMounted(async () => {
|
||||
@alternate="onSetupSubscription()"
|
||||
>
|
||||
<div>
|
||||
<div class="error-label" v-if="!update.manifest.dockerImage">{{ $t('app.updateDialog.subscriptionExpired') }}</div>
|
||||
<div class="error-label" v-if="updateError">{{ updateError }}</div>
|
||||
|
||||
<p class="text-danger" v-if="update.unstable">{{ $t('app.updateDialog.unstableWarning') }}</p>
|
||||
<p>{{ $t('app.updateDialog.changelogHeader', { version: update.manifest.version }) }}</p>
|
||||
<div v-html="marked.parse(update.manifest.changelog)"></div>
|
||||
<p class="text-danger text-bold" v-if="!update.manifest.dockerImage">
|
||||
<br/>
|
||||
{{ $t('app.updateDialog.subscriptionExpired') }}
|
||||
</p>
|
||||
|
||||
<Checkbox v-if="update.manifest.dockerImage" v-model="skipBackup" :label="$t('app.updateDialog.skipBackupCheckbox')" />
|
||||
</div>
|
||||
@@ -116,7 +131,7 @@ onMounted(async () => {
|
||||
<p v-html="$t('app.updates.auto.description', { appStoreLink: 'https://www.cloudron.io/store/index.html' })"></p>
|
||||
<p v-if="!app.appStoreId" class="text-danger">{{ $t('app.updates.info.customAppUpdateInfo') }}</p>
|
||||
|
||||
<Switch v-if="app.appStoreId" v-model="autoUpdatesEnabled" :label="$t(autoUpdatesEnabled ? 'app.updates.auto.enabled' : 'app.updates.auto.disabled')"/>
|
||||
<Switch v-if="app.appStoreId" v-model="autoUpdatesEnabled" :disabled="autoUpdatesEnabledBusy" :label="$t(autoUpdatesEnabled ? 'app.updates.auto.enabled' : 'app.updates.auto.disabled')" @change="onAutoUpdatesEnabledChange"/>
|
||||
|
||||
<div style="display: flex; gap: 6px; margin-top: 20px">
|
||||
<Button v-if="app.appStoreId" @click="onCheck()" :disabled="busyCheck" :loading="busyCheck">{{ $t('settings.updates.checkForUpdatesAction') }}</Button>
|
||||
|
||||
Reference in New Issue
Block a user