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: Consolidate user/group search code #1025

Merged
merged 5 commits into from
Jun 27, 2024
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
2 changes: 1 addition & 1 deletion cypress/e2e/tables-table.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('Manage a table', () => {
cy.get('[data-cy="editTableModal"]').should('not.exist')
cy.get('[data-cy="transferTableModal"]').should('be.visible')
cy.get('[data-cy="transferTableModal"] input[type="search"]').clear().type(targetUserTransfer.userId)
cy.get(`.vs__dropdown-menu [user="${targetUserTransfer.userId}"]`).click()
cy.get(`.vs__dropdown-menu [id="${targetUserTransfer.userId}"]`).click()
cy.get('[data-cy="transferTableButton"]').should('be.enabled').click()
cy.get('.toastify.toast-success').should('be.visible')
cy.get('.app-navigation__list').contains('test table').should('not.exist')
Expand Down
2 changes: 1 addition & 1 deletion src/modules/modals/EditContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default {
sharing = sharing.filter((share) => getCurrentUser().uid !== share.receiver)
const receivers = sharing.map((share) => {
return {
user: share.receiver,
id: share.receiver,
displayName: share.receiver_display_name,
icon: share.receiver_type === 'user' ? 'icon-user' : 'icon-group',
isUser: share.receiver_type === 'user',
Expand Down
6 changes: 3 additions & 3 deletions src/modules/modals/TransferContext.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>
<div class="row">
<h3>{{ t('tables', 'Transfer this application to another user') }}</h3>
<NcUserAndGroupPicker :select-users="true" :select-groups="false" :new-owner-user-id.sync="newOwnerId" />
<NcUserPicker :select-users="true" :select-groups="false" :selected-user-id.sync="newOwnerId" />
</div>
<div class="row">
<div class="fix-col-4 space-T end">
Expand All @@ -28,7 +28,7 @@ import { NcModal, NcButton } from '@nextcloud/vue'
import { showSuccess } from '@nextcloud/dialogs'
import '@nextcloud/dialogs/dist/index.css'
import permissionsMixin from '../../shared/components/ncTable/mixins/permissionsMixin.js'
import NcUserAndGroupPicker from '../../shared/components/ncUserAndGroupPicker/NcUserAndGroupPicker.vue'
import NcUserPicker from '../../shared/components/ncUserPicker/NcUserPicker.vue'
import { mapGetters, mapState } from 'vuex'
import { getCurrentUser } from '@nextcloud/auth'

Expand All @@ -37,7 +37,7 @@ export default {
components: {
NcModal,
NcButton,
NcUserAndGroupPicker,
NcUserPicker,
},
mixins: [permissionsMixin],
props: {
Expand Down
14 changes: 7 additions & 7 deletions src/modules/modals/TransferTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
</div>
<div class="row">
<h3>{{ t('tables', 'Transfer this table to another user') }}</h3>
<NcUserAndGroupPicker :select-users="true" :select-groups="false" :new-owner-user-id.sync="newOwnerUserId" />
<NcUserPicker :select-users="true" :select-groups="false" :selected-user-id.sync="selectedUserId" />
</div>
<div class="row">
<div class="fix-col-4 space-T end">
<NcButton type="warning" :disabled="newOwnerUserId === ''" data-cy="transferTableButton" @click="transferMe">
<NcButton type="warning" :disabled="selectedUserId === ''" data-cy="transferTableButton" @click="transferMe">
{{ t('tables', 'Transfer') }}
</NcButton>
</div>
Expand All @@ -28,7 +28,7 @@ import { NcModal, NcButton } from '@nextcloud/vue'
import { showSuccess } from '@nextcloud/dialogs'
import '@nextcloud/dialogs/dist/index.css'
import permissionsMixin from '../../shared/components/ncTable/mixins/permissionsMixin.js'
import NcUserAndGroupPicker from '../../shared/components/ncUserAndGroupPicker/NcUserAndGroupPicker.vue'
import NcUserPicker from '../../shared/components/ncUserPicker/NcUserPicker.vue'
import { mapGetters } from 'vuex'
import { getCurrentUser } from '@nextcloud/auth'

Expand All @@ -37,7 +37,7 @@ export default {
components: {
NcModal,
NcButton,
NcUserAndGroupPicker,
NcUserPicker,
},
mixins: [permissionsMixin],
props: {
Expand All @@ -53,7 +53,7 @@ export default {
data() {
return {
loading: false,
newOwnerUserId: '',
selectedUserId: '',
}
},
computed: {
Expand Down Expand Up @@ -84,9 +84,9 @@ export default {
if (this.activeTable) {
activeTableId = !this.isView ? this.activeTable.id : null
}
const res = await this.$store.dispatch('transferTable', { id: this.table.id, data: { newOwnerUserId: this.newOwnerUserId } })
const res = await this.$store.dispatch('transferTable', { id: this.table.id, data: { newOwnerUserId: this.selectedUserId } })
if (res) {
showSuccess(t('tables', 'Table "{emoji}{table}" transferred to {user}', { emoji: this.table?.emoji ? this.table?.emoji + ' ' : '', table: this.table?.title, user: this.newOwnerUserId }))
showSuccess(t('tables', 'Table "{emoji}{table}" transferred to {user}', { emoji: this.table?.emoji ? this.table?.emoji + ' ' : '', table: this.table?.title, user: this.selectedUserId }))

if (transferId === activeTableId) {
await this.$router.push('/').catch(err => err)
Expand Down
Loading
Loading