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

enh: warn during table manager promotion/demotion #1434

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ Cypress.Commands.add('addUserToGroup', (userId, groupId) => {

Cypress.Commands.add('removeColumn', (title) => {
cy.get('.custom-table table tr th .cell').contains(title).click()
cy.get('.v-popper__popper ul.nc-button-group-content').last().get('button').last().click()
cy.get('.modal__content button').contains('Confirm').click()
cy.get('[data-cy="deleteColumnActionBtn"] button').click()
cy.get('[data-cy="confirmDialog"] button').contains('Confirm').click()
})

// fill in a value in the 'create row' or 'edit row' model
Expand Down
32 changes: 28 additions & 4 deletions src/modules/sidebar/partials/ShareList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</NcActionCheckbox>
<NcActionButton v-if="!isView && !personHasTableManagePermission(share.receiver)"
:close-after-click="true"
@click="promoteToManager(share)">
@click="warnOnPromote(share)">
<template #icon>
<Crown :size="20" />
</template>
Expand Down Expand Up @@ -114,6 +114,16 @@
<div v-else>
{{ t('tables', 'No shares') }}
</div>
<div>
<DialogConfirmation :description="t('tables', 'After table promotion, any applications based on this table created by the share recipients will continue to consume its data even if you demote them later')"
:title="t('tables', 'Confirm table manager promotion')"
:cancel-title="t('tables', 'Cancel')"
:confirm-title="t('tables', 'Promote to table manager')"
confirm-class="warning"
:show-modal="showModal"
@confirm="promoteToManager"
@cancel="showModal=false" />
</div>
</div>
</template>

Expand All @@ -127,6 +137,9 @@ import Crown from 'vue-material-design-icons/Crown.vue'
import Information from 'vue-material-design-icons/Information.vue'
import Account from 'vue-material-design-icons/Account.vue'
import moment from '@nextcloud/moment'
import { showWarning } from '@nextcloud/dialogs'
import DialogConfirmation from '../../../shared/modals/DialogConfirmation.vue'
import '@nextcloud/dialogs/style.css'

export default {
components: {
Expand All @@ -142,6 +155,7 @@ export default {
NcActionSeparator,
OpenInNew,
Crown,
DialogConfirmation,
},

mixins: [formatting],
Expand All @@ -158,6 +172,8 @@ export default {
loading: false,
// To enable the share info popup
debug: false,
showModal: false,
currentShare: {},
}
},

Expand Down Expand Up @@ -205,10 +221,18 @@ export default {
updatePermission(share, permission, value) {
this.$emit('update', { id: share.id, permission, value })
},
promoteToManager(share) {
this.$emit('update', { id: share.id, permission: 'manage', value: true })
warnOnPromote(share) {
this.currentShare = share
this.showModal = true
},
promoteToManager() {
if (!this.currentShare) return
this.$emit('update', { id: this.currentShare?.id, permission: 'manage', value: true })
this.currentShare = {}
this.showModal = false
},
demoteManager(share) {
async demoteManager(share) {
showWarning(t('tables', 'Any application created by a demoted share recipients using a shared table will continue to consume its data.', { share: share.displayName }))
this.$emit('update', { id: share.id, permission: 'manage', value: false })
},
personHasTableManagePermission(userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
</NcActionButton>
<NcActionButton v-if="showDeleteColumn"
:aria-label="t('tables', 'Delete column')"
data-cy="deleteColumnActionBtn"
@click="deleteColumn()">
<template #icon>
<Delete :size="25" />
Expand Down
44 changes: 25 additions & 19 deletions src/shared/modals/DialogConfirmation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,32 @@
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<NcModal v-if="showModal" @close="$emit('cancel')">
<div class="modal__content">
<div class="row">
<div v-if="title" class="col-4">
<h2>{{ title }}</h2>
</div>
<div v-if="description" class="col-4">
<p>{{ description }}</p>
</div>
</div>
<div class="row space-T">
<div class="fix-col-4 end">
<NcButton :type="confirmClass" :aria-label="confirmTitle" @click="$emit('confirm')">
{{ confirmTitle }}
</NcButton>
</div>
<NcDialog v-if="showModal" :out-transition="true"
size="normal" close-on-click-outside :name="title" @closing="$emit('cancel')"
data-cy="confirmDialog">

Check warning on line 8 in src/shared/modals/DialogConfirmation.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute "data-cy" should go before "@closing"
<div class="row">
<div v-if="description" class="col-4">
<p>{{ description }}</p>
</div>
</div>
</NcModal>
<template #actions>
<NcButton :aria-label="cancelTitle" :type="cancelClass" @click="$emit('cancel')">
{{ cancelTitle }}
</NcButton>
<NcButton :type="confirmClass" :aria-label="confirmTitle" @click="$emit('confirm')">
{{ confirmTitle }}
</NcButton>
</template>
</NcDialog>
</template>

<script>
import { NcModal, NcButton } from '@nextcloud/vue'
import { NcDialog, NcButton } from '@nextcloud/vue'

export default {
name: 'DialogConfirmation',
components: {
NcModal,
NcDialog,
NcButton,
},
props: {
Expand All @@ -46,6 +44,14 @@
type: String,
default: null,
},
cancelTitle: {
type: String,
default: t('tables', 'Cancel'),
},
cancelClass: {
type: String,
default: 'tertiary',
},
confirmTitle: {
type: String,
default: t('tables', 'Confirm'),
Expand Down
Loading