Skip to content
Open
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
55 changes: 39 additions & 16 deletions src/components/NavigationMailbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,27 @@
</template>
</ActionButton>
<ActionButton
v-if="!editing && !account.isUnified && hasDelimiter && mailbox.specialRole !== 'flagged' && hasSubmailboxActionAcl"
v-if="subfolderLabel && !account.isUnified && hasDelimiter && mailbox.specialRole !== 'flagged' && hasSubmailboxActionAcl"
@click="openCreateMailbox">
<template #icon>
<IconAdd :size="20" />
</template>
{{ t('mail', 'Add subfolder') }}
</ActionButton>
<ActionInput
v-if="editing"
v-if="subfolderInput"
:value.sync="createMailboxName"
@submit.prevent.stop="createMailbox">
<template #icon>
<IconAdd :size="20" />
</template>
</ActionInput>
<ActionText v-if="subfolderSaving">
<template #icon>
<IconLoading :size="20" />
</template>
{{ t('mail', 'Saving') }}
</ActionText>
<ActionButton
v-if="renameLabel && !hasSubMailboxes && !account.isUnified && hasRenameAcl"
@click.prevent.stop="openRenameInput">
Expand All @@ -144,7 +150,7 @@
:size="20" />
</template>
</ActionInput>
<ActionText v-if="showSaving">
<ActionText v-if="renameSaving">
<template #icon>
<IconLoading :size="20" />
</template>
Expand Down Expand Up @@ -353,15 +359,17 @@ export default {
mailboxStats: undefined,
loadingMarkAsRead: false,
clearingCache: false,
showSaving: false,
changeSubscription: false,
changingSyncInBackground: false,
editing: false,
subfolderLabel: true,
subfolderInput: false,
subfolderSaving: false,
showSubMailboxes: false,
wasExpandedBeforeDrag: false,
menuOpen: false,
renameLabel: true,
renameInput: false,
renameSaving: false,
mailboxName: this.mailbox.displayName,
showMoveModal: false,
hasDelimiter: !!this.mailbox.delimiter,
Expand Down Expand Up @@ -543,6 +551,16 @@ export default {
onMenuToggle(open) {
if (open) {
this.fetchMailboxStats()
} else {
if (!this.renameSaving) {
this.renameLabel = true
this.renameInput = false
}

if (!this.subfolderSaving) {
this.subfolderLabel = true
this.subfolderInput = false
}
}
},

Expand All @@ -566,11 +584,12 @@ export default {
},

async createMailbox(e) {
this.editing = true
this.subfolderInput = false
this.subfolderSaving = true
const name = this.createMailboxName
const withPrefix = this.mailbox.name + this.mailbox.delimiter + name
logger.info(`creating mailbox ${withPrefix} as submailbox of ${this.mailbox.databaseId}`)
this.menuOpen = false

try {
await this.mainStore.createMailbox({
account: this.account,
Expand All @@ -580,16 +599,20 @@ export default {
logger.error(`could not create mailbox ${withPrefix}`, { error })
throw error
} finally {
this.editing = false
this.showSaving = false
this.menuOpen = false
this.subfolderLabel = true
this.subfolderSaving = false
}

logger.info(`mailbox ${withPrefix} created`)
this.showSubMailboxes = true
},

openCreateMailbox() {
this.editing = true
this.showSaving = false
this.subfolderLabel = false
this.createMailboxName = ''
this.subfolderInput = true
this.subfolderSaving = false
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.

markAsRead() {
Expand Down Expand Up @@ -712,7 +735,7 @@ export default {

async renameMailbox() {
this.renameInput = false
this.showSaving = true
this.renameSaving = true

try {
let newName = this.mailboxName
Expand All @@ -724,21 +747,21 @@ export default {
mailbox: this.mailbox,
newName,
})
this.renameLabel = true
this.renameInput = false
} catch (error) {
showInfo(t('mail', 'An error occurred, unable to rename the mailbox.'))
logger.error('could not rename mailbox', { error })
} finally {
this.showSaving = false
this.renameSaving = false
this.renameLabel = true
}
},

openRenameInput() {
// Hide label and show input
this.renameLabel = false
this.mailboxName = this.mailbox.displayName
this.renameInput = true
this.showSaving = false
this.renameSaving = false
},

onOpenMoveModal() {
Expand Down
Loading