Merge pull request #532 from YunoHost/supportpurge

[enh] add --purge option in app uninstall modal
This commit is contained in:
Alexandre Aubin 2023-09-29 17:15:43 +02:00 committed by GitHub
commit 93b73600c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

View file

@ -136,6 +136,9 @@
"license": "License" "license": "License"
}, },
"potential_alternative_to": "Potential alternative to:", "potential_alternative_to": "Potential alternative to:",
"uninstall": {
"purge_desc": "Remove the data directory associated with the app (this is usually data you uploaded yourself using the app)."
},
"upgrade": { "upgrade": {
"confirm": { "confirm": {
"apps": "Apps that will be upgraded", "apps": "Apps that will be upgraded",

View file

@ -64,7 +64,7 @@
</b-button> </b-button>
<b-button <b-button
@click="uninstall" v-b-modal.uninstall-modal
id="uninstall" id="uninstall"
variant="danger" variant="danger"
:class="{ 'ml-auto': !app.url }" :class="{ 'ml-auto': !app.url }"
@ -262,6 +262,19 @@
</b-list-group> </b-list-group>
</card> </card>
<b-modal
v-if="app"
id="uninstall-modal" :title="$t('confirm_uninstall', { name: id })"
header-bg-variant="warning" :body-class="{ 'd-none': !app.supports_purge }" body-bg-variant=""
@ok="uninstall"
>
<b-form-group v-if="app.supports_purge">
<b-form-checkbox v-model="purge">
{{ $t('app.uninstall.purge_desc', { name: id }) }}
</b-form-checkbox>
</b-form-group>
</b-modal>
<template #skeleton> <template #skeleton>
<card-info-skeleton :item-count="8" /> <card-info-skeleton :item-count="8" />
<card-form-skeleton /> <card-form-skeleton />
@ -306,6 +319,7 @@ export default {
loading: true, loading: true,
app: undefined, app: undefined,
form: undefined, form: undefined,
purge: false,
config_panel_err: null, config_panel_err: null,
config: { config: {
panels: [ panels: [
@ -408,7 +422,7 @@ export default {
links: [ links: [
['license', `https://spdx.org/licenses/${app.manifest.upstream.license}`], ['license', `https://spdx.org/licenses/${app.manifest.upstream.license}`],
...['website', 'admindoc', 'userdoc', 'code'].map((key) => ([key, app.manifest.upstream[key]])), ...['website', 'admindoc', 'userdoc', 'code'].map((key) => ([key, app.manifest.upstream[key]])),
['package', app.from_catalog.git.url], ['package', app.from_catalog.git?.url],
['forum', `https://forum.yunohost.org/tag/${app.manifest.id}`] ['forum', `https://forum.yunohost.org/tag/${app.manifest.id}`]
].filter(([key, val]) => !!val), ].filter(([key, val]) => !!val),
doc: { doc: {
@ -429,6 +443,7 @@ export default {
is_default: app.is_default, is_default: app.is_default,
supports_change_url: app.supports_change_url, supports_change_url: app.supports_change_url,
supports_config_panel: app.supports_config_panel, supports_config_panel: app.supports_config_panel,
supports_purge: app.supports_purge,
permissions permissions
} }
if (app.settings.domain && app.settings.path) { if (app.settings.domain && app.settings.path) {
@ -518,12 +533,8 @@ export default {
}, },
async uninstall () { async uninstall () {
const confirmed = await this.$askConfirmation( const data = this.purge === true ? { purge: 1 } : {}
this.$i18n.t('confirm_uninstall', { name: this.id }) api.delete('apps/' + this.id, data, { key: 'apps.uninstall', name: this.app.label }).then(() => {
)
if (!confirmed) return
api.delete('apps/' + this.id, {}, { key: 'apps.uninstall', name: this.app.label }).then(() => {
this.$router.push({ name: 'app-list' }) this.$router.push({ name: 'app-list' })
}) })
} }