Skip to content

Commit

Permalink
Add removeData parameter to ExApp Remove UI (#301)
Browse files Browse the repository at this point in the history
Closes #297.

---------

Signed-off-by: Edward Ly <contact@edward.ly>
  • Loading branch information
edward-ly authored Jun 10, 2024
1 parent fc39b86 commit 8b26399
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/Controller/ExAppsPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public function updateApp(string $appId): JSONResponse {
}

/**
* Unregister ExApp, remove container and volume by default
* Unregister ExApp, remove container by default
*/
#[PasswordConfirmationRequired]
public function uninstallApp(string $appId, bool $removeContainer = true, bool $removeData = false): JSONResponse {
Expand Down
29 changes: 28 additions & 1 deletion src/components/Apps/AppDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
type="button"
:value="t('settings', 'Remove')"
:disabled="installing || isLoading || !defaultDeployDaemonAccessible"
@click="remove(app.id)">
@click="remove(app.id, removeData)">
<input v-if="app.active"
class="enable"
type="button"
Expand All @@ -37,6 +37,12 @@
:value="forceEnableButtonText"
:disabled="installing || isLoading || !defaultDeployDaemonAccessible"
@click="forceEnable(app.id)">
<NcCheckboxRadioSwitch v-if="app.canUnInstall"
:checked="removeData"
:disabled="installing || isLoading || !defaultDeployDaemonAccessible"
@update:checked="toggleRemoveData">
{{ t('settings', 'Delete data on remove') }}
</NcCheckboxRadioSwitch>
</div>
</div>

Expand Down Expand Up @@ -100,6 +106,7 @@
</template>

<script>
import { NcCheckboxRadioSwitch } from '@nextcloud/vue'
import AppManagement from '../../mixins/AppManagement.js'
import PrefixMixin from './PrefixMixin.vue'
import Markdown from './Markdown.vue'
Expand All @@ -109,6 +116,7 @@ export default {
components: {
Markdown,
NcCheckboxRadioSwitch,
},
mixins: [AppManagement, PrefixMixin],
Expand All @@ -119,6 +127,12 @@ export default {
},
},
data() {
return {
removeData: false,
}
},
computed: {
appstoreUrl() {
return `https://apps.nextcloud.com/apps/${this.app.id}`
Expand All @@ -143,6 +157,18 @@ export default {
return this.app.author
},
},
watch: {
'app.id'() {
this.removeData = false
},
},
methods: {
toggleRemoveData() {
this.removeData = !this.removeData
},
},
}
</script>

Expand All @@ -155,6 +181,7 @@ export default {
&-manage {
// if too many, shrink them and ellipsis
display: flex;
flex-wrap: wrap;
input {
flex: 0 1 auto;
min-width: 0;
Expand Down
3 changes: 2 additions & 1 deletion src/components/Apps/AppItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
class="uninstall"
type="tertiary"
:disabled="installing || isLoading || !defaultDeployDaemonAccessible"
@click.stop="remove(app.id)">
@click.stop="remove(app.id, removeData)">
{{ t('settings', 'Remove') }}
</NcButton>
<NcButton v-if="app.active"
Expand Down Expand Up @@ -147,6 +147,7 @@ export default {
data() {
return {
isSelected: false,
removeData: false,
scrolled: false,
screenshotLoaded: false,
}
Expand Down
4 changes: 2 additions & 2 deletions src/mixins/AppManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export default {
.then((response) => { rebuildNavigation() })
.catch((error) => { showError(error) })
},
remove(appId) {
this.$store.dispatch('uninstallApp', { appId })
remove(appId, removeData) {
this.$store.dispatch('uninstallApp', { appId, removeData })
.then((response) => { rebuildNavigation() })
.catch((error) => { showError(error) })
},
Expand Down
4 changes: 2 additions & 2 deletions src/store/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ const actions = {
}).catch((error) => context.commit('API_FAILURE', { appId, error }))
},

uninstallApp(context, { appId }) {
uninstallApp(context, { appId, removeData }) {
return api.requireAdmin().then((response) => {
context.commit('startLoading', appId)
return api.get(generateUrl(`/apps/app_api/apps/uninstall/${appId}`))
return api.get(generateUrl(`/apps/app_api/apps/uninstall/${appId}?removeData=${removeData}`))
.then((response) => {
context.commit('stopLoading', appId)
context.commit('uninstallApp', appId)
Expand Down

0 comments on commit 8b26399

Please sign in to comment.