|
| 1 | +<!-- |
| 2 | + - SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors |
| 3 | + - SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | +--> |
| 5 | + |
| 6 | +<template> |
| 7 | + <div class="app-sidebar-manage__actions"> |
| 8 | + <div v-if="app.active && canLimitToGroups(app)" class="app-sidebar-manage__actions-groups"> |
| 9 | + <input |
| 10 | + :id="`groups_enable_${app.id}`" |
| 11 | + v-model="groupCheckedAppsData" |
| 12 | + type="checkbox" |
| 13 | + :value="app.id" |
| 14 | + class="groups-enable__checkbox checkbox" |
| 15 | + @change="setGroupLimit"> |
| 16 | + <label :for="`groups_enable_${app.id}`">{{ t('settings', 'Limit to groups') }}</label> |
| 17 | + <input |
| 18 | + type="hidden" |
| 19 | + class="group_select" |
| 20 | + :title="t('settings', 'All')" |
| 21 | + value=""> |
| 22 | + <br> |
| 23 | + <label for="limitToGroups"> |
| 24 | + <span>{{ t('settings', 'Limit app usage to groups') }}</span> |
| 25 | + </label> |
| 26 | + <NcSelect |
| 27 | + v-if="isLimitedToGroups(app)" |
| 28 | + input-id="limitToGroups" |
| 29 | + :options="groups" |
| 30 | + :model-value="appGroups" |
| 31 | + :limit="5" |
| 32 | + label="name" |
| 33 | + :multiple="true" |
| 34 | + keep-open |
| 35 | + @option:selected="addGroupLimitation" |
| 36 | + @option:deselected="removeGroupLimitation" |
| 37 | + @search="asyncFindGroup"> |
| 38 | + <span slot="noResult">{{ t('settings', 'No results') }}</span> |
| 39 | + </NcSelect> |
| 40 | + </div> |
| 41 | + <div class="app-sidebar-manage__actions-manage"> |
| 42 | + <input |
| 43 | + v-if="app.update" |
| 44 | + class="update primary" |
| 45 | + type="button" |
| 46 | + :value="t('settings', 'Update to {version}', { version: app.update })" |
| 47 | + :disabled="installing || isLoading || isManualInstall" |
| 48 | + @click="update(app.id)"> |
| 49 | + <input |
| 50 | + v-if="app.canUnInstall" |
| 51 | + class="uninstall" |
| 52 | + type="button" |
| 53 | + :value="t('settings', 'Remove')" |
| 54 | + :disabled="installing || isLoading" |
| 55 | + @click="remove(app.id, removeData)"> |
| 56 | + <input |
| 57 | + v-if="app.active" |
| 58 | + class="enable" |
| 59 | + type="button" |
| 60 | + :value="disableButtonText" |
| 61 | + :disabled="installing || isLoading || isInitializing || isDeploying" |
| 62 | + @click="disable(app.id)"> |
| 63 | + <input |
| 64 | + v-if="!app.active && (app.canInstall || app.isCompatible)" |
| 65 | + :title="enableButtonTooltip" |
| 66 | + :aria-label="enableButtonTooltip" |
| 67 | + class="enable primary" |
| 68 | + type="button" |
| 69 | + :value="enableButtonText" |
| 70 | + :disabled="!app.canInstall || installing || isLoading || !defaultDeployDaemonAccessible || isInitializing || isDeploying" |
| 71 | + @click="enableButtonAction"> |
| 72 | + <input |
| 73 | + v-else-if="!app.active && !app.canInstall" |
| 74 | + :title="forceEnableButtonTooltip" |
| 75 | + :aria-label="forceEnableButtonTooltip" |
| 76 | + class="enable force" |
| 77 | + type="button" |
| 78 | + :value="forceEnableButtonText" |
| 79 | + :disabled="installing || isLoading" |
| 80 | + @click="forceEnable(app.id)"> |
| 81 | + <NcButton |
| 82 | + v-if="app?.app_api && (app.canInstall || app.isCompatible)" |
| 83 | + :aria-label="t('settings', 'Advanced deploy options')" |
| 84 | + variant="secondary" |
| 85 | + @click="() => showDeployOptionsModal = true"> |
| 86 | + <template #icon> |
| 87 | + <NcIconSvgWrapper :path="mdiToyBrickPlusOutline" /> |
| 88 | + </template> |
| 89 | + {{ t('settings', 'Deploy options') }} |
| 90 | + </NcButton> |
| 91 | + </div> |
| 92 | + <p v-if="!defaultDeployDaemonAccessible" class="warning"> |
| 93 | + {{ t('settings', 'Default Deploy daemon is not accessible') }} |
| 94 | + </p> |
| 95 | + <NcCheckboxRadioSwitch |
| 96 | + v-if="app.canUnInstall" |
| 97 | + :model-value="removeData" |
| 98 | + :disabled="installing || isLoading || !defaultDeployDaemonAccessible" |
| 99 | + @update:modelValue="toggleRemoveData"> |
| 100 | + {{ t('settings', 'Delete data on remove') }} |
| 101 | + </NcCheckboxRadioSwitch> |
| 102 | + |
| 103 | + <AppDeployOptionsModal |
| 104 | + v-if="app?.app_api" |
| 105 | + :show.sync="showDeployOptionsModal" |
| 106 | + :app="app" /> |
| 107 | + </div> |
| 108 | +</template> |
| 109 | + |
| 110 | +<script> |
| 111 | +import { mdiToyBrickPlusOutline } from '@mdi/js' |
| 112 | +import { emit } from '@nextcloud/event-bus' |
| 113 | +import { translate as t } from '@nextcloud/l10n' |
| 114 | +import NcButton from '@nextcloud/vue/components/NcButton' |
| 115 | +import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch' |
| 116 | +import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper' |
| 117 | +import AppDeployOptionsModal from './AppDeployOptionsModal.vue' |
| 118 | +import AppManagement from '../../mixins/AppManagement.js' |
| 119 | +import { useAppApiStore } from '../../store/app-api-store.js' |
| 120 | +import { useAppsStore } from '../../store/apps-store.js' |
| 121 | +
|
| 122 | +export default { |
| 123 | + name: 'AppStoreSidebarActions', |
| 124 | +
|
| 125 | + components: { |
| 126 | + NcButton, |
| 127 | + NcCheckboxRadioSwitch, |
| 128 | + NcIconSvgWrapper, |
| 129 | + AppDeployOptionsModal, |
| 130 | + }, |
| 131 | +
|
| 132 | + mixins: [AppManagement], |
| 133 | +
|
| 134 | + props: { |
| 135 | + app: { |
| 136 | + type: Object, |
| 137 | + required: true, |
| 138 | + }, |
| 139 | + }, |
| 140 | +
|
| 141 | + setup() { |
| 142 | + const store = useAppsStore() |
| 143 | + const appApiStore = useAppApiStore() |
| 144 | + return { |
| 145 | + store, |
| 146 | + appApiStore, |
| 147 | + t, |
| 148 | + mdiToyBrickPlusOutline, |
| 149 | + } |
| 150 | + }, |
| 151 | +
|
| 152 | + data() { |
| 153 | + return { |
| 154 | + removeData: false, |
| 155 | + showDeployOptionsModal: false, |
| 156 | + } |
| 157 | + }, |
| 158 | +
|
| 159 | + methods: { |
| 160 | + toggleRemoveData() { |
| 161 | + this.removeData = !this.removeData |
| 162 | + }, |
| 163 | +
|
| 164 | + async enableButtonAction() { |
| 165 | + if (!this.app?.app_api) { |
| 166 | + this.enable(this.app.id) |
| 167 | + return |
| 168 | + } |
| 169 | + await this.appApiStore.fetchDockerDaemons() |
| 170 | + if (this.appApiStore.dockerDaemons.length === 1 && this.app.needsDownload) { |
| 171 | + this.enable(this.app.id, this.appApiStore.dockerDaemons[0]) |
| 172 | + } else if (this.app.needsDownload) { |
| 173 | + emit('showDaemonSelectionModal') |
| 174 | + } else { |
| 175 | + this.enable(this.app.id, this.app.daemon) |
| 176 | + } |
| 177 | + }, |
| 178 | + }, |
| 179 | +} |
| 180 | +</script> |
| 181 | +
|
| 182 | +<style scoped lang="scss"> |
| 183 | +.app-sidebar-manage { |
| 184 | + &__actions { |
| 185 | + display: flex; |
| 186 | + align-items: center; |
| 187 | + flex-wrap: wrap; |
| 188 | + gap: 4px; |
| 189 | +
|
| 190 | + &-manage { |
| 191 | + display: flex; |
| 192 | + align-items: center; |
| 193 | + input { |
| 194 | + flex: 0 1 auto; |
| 195 | + min-width: 0; |
| 196 | + text-overflow: ellipsis; |
| 197 | + white-space: nowrap; |
| 198 | + overflow: hidden; |
| 199 | + } |
| 200 | + } |
| 201 | + } |
| 202 | +} |
| 203 | +
|
| 204 | +.force { |
| 205 | + color: var(--color-text-error); |
| 206 | + border-color: var(--color-border-error); |
| 207 | + background: var(--color-main-background); |
| 208 | +} |
| 209 | +
|
| 210 | +.force:hover, |
| 211 | +.force:active { |
| 212 | + color: var(--color-main-background); |
| 213 | + border-color: var(--color-border-error) !important; |
| 214 | + background: var(--color-error); |
| 215 | +} |
| 216 | +</style> |
0 commit comments