Skip to content

Commit

Permalink
Merge branch 'feature/rename_mailbox' of github.com:nextcloud/mail in…
Browse files Browse the repository at this point in the history
…to feature/rename_mailbox
  • Loading branch information
GretaD committed Aug 27, 2020
2 parents 73f8e70 + 420389c commit 3c4845b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 36 deletions.
55 changes: 29 additions & 26 deletions src/components/NavigationMailbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,38 @@
@click="openCreateMailbox">
{{ t('mail', 'Add subfolder') }}
</ActionButton>
<ActionInput v-if="editing" icon="icon-folder" @submit.prevent.stop="createMailbox" />
<ActionInput v-if="editing" icon="icon-folder" @submit.prevent.stop="createMailbox">
</ActionInput>
<ActionText v-if="showSaving" icon="icon-loading-small">
{{ t('mail', 'Saving') }}
<ActionButton
v-if="renameLabel && mailbox.specialRole === null"
icon="icon-rename"
@click.prevent.stop="openRenameInput">
{{ t('mail', 'Edit name') }}
</ActionButton>
<ActionInput
v-if="renameInput"
icon="icon-rename"
:value.sync="mailbox.displayName"
@submit.prevent.stop="renameMailbox" />
<ActionText v-if="showSaving" icon="icon-loading-small">
{{ t('mail', 'Saving') }}
</ActionText>
</Actiontext>
<ActionButton
v-if="renameLabel"
icon="icon-rename"
@click.prevent.stop="openRenameInput">
{{ t('mail', 'Edit name') }}
</ActionButton>
<ActionInput
v-if="renameInput"
icon="icon-rename"
:value.sync="mailbox.displayName"
@submit.prevent.stop="renameMailbox">
</ActionInput>
<ActionText v-if="showSaving" icon="icon-loading-small">
{{ t('mail', 'Saving') }}
</ActionText>

<ActionButton
v-if="debug && !account.isUnified && mailbox.specialRole !== 'flagged'"
icon="icon-settings"
:title="t('mail', 'Clear cache')"
:disabled="clearingCache"
@click="clearCache">
{{ t('mail', 'Clear locally cached data, in case there are issues with synchronization.') }}
</ActionButton>
<ActionButton v-if="!account.isUnified && !mailbox.specialRole" icon="icon-delete" @click="deleteMailbox">
{{ t('mail', 'Delete folder') }}
</ActionButton>
<ActionButton
v-if="debug && !account.isUnified && mailbox.specialRole !== 'flagged'"
icon="icon-settings"
:title="t('mail', 'Clear cache')"
:disabled="clearingCache"
@click="clearCache">
{{ t('mail', 'Clear locally cached data, in case there are issues with synchronization.') }}
</ActionButton>
<ActionButton v-if="!account.isUnified && !mailbox.specialRole" icon="icon-delete" @click="deleteMailbox">
{{ t('mail', 'Delete folder') }}
</ActionButton>
</template>
</template>
<AppNavigationCounter v-if="mailbox.unread" slot="counter">
Expand Down
8 changes: 4 additions & 4 deletions src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ export default {
const oldId = mailbox.id

// Remove the old entry
Vue.delete(state.folders, normalizedFolderId(accountId, oldId))
Vue.delete(state.mailboxes, mailbox.databaseId(accountId, oldId))
// Update the ID
mailbox.id = btoa(newName)
// Set the new entry
Vue.set(state.mailbox, normalizedFolderId(accountId, mailbox.id), mailbox)
Vue.set(state.mailbox, mailbox.databaseId(accountId, mailbox.id), mailbox)

// Update the reference
const oldNormalized = normalizedFolderId(accountId, oldId)
const oldNormalized = mailbox.databaseId(accountId, oldId)
state.accounts[accountId].mailboxes = state.accounts[accountId].mailboxes.filter(id => id !== oldNormalized)
state.accounts[accountId].mailboxes.push(normalizedFolderId(accountId, mailbox.id))
state.accounts[accountId].mailboxes.push(mailbox.databaseId(accountId, mailbox.id))
},
}
12 changes: 6 additions & 6 deletions src/tests/unit/store/mutations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ describe('Vuex store mutations', () => {
123: {
accountId: 123,
id: 123,
folders: [
mailboxes: [
'123-' + oldId
],
},
},
envelopes: {},
folders: {
mailboxes: {
['123-' + oldId]: {
id: oldId,
envelopeLists: {},
},
},
}

mutations.renameFolder(state, {
mutations.renameMailbox(state, {
accountId: 123,
folder: {
mailboxes: {
id: oldId,
envelopeLists: {},
},
Expand All @@ -63,13 +63,13 @@ describe('Vuex store mutations', () => {
123: {
accountId: 123,
id: 123,
folders: [
mailboxes: [
'123-' + newId
],
},
},
envelopes: {},
folders: {
mailboxes: {
['123-' + newId]: {
id: newId,
envelopeLists: {},
Expand Down

0 comments on commit 3c4845b

Please sign in to comment.