-
Notifications
You must be signed in to change notification settings - Fork 25
feat: implement mail account switcher #1677
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
12e5fe6
feat: implement mail account switcher
AlexAndBear c38a7ec
format
AlexAndBear 0dd3cfc
add truncate
AlexAndBear 609e80c
adjust margin
AlexAndBear f98fafa
MailAccountSwitch.vue aktualisieren
AlexAndBear fa7ecb2
MailAccountSwitch.vue aktualisieren
AlexAndBear a8eb25c
conditional mail address rendering
AlexAndBear File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
86 changes: 86 additions & 0 deletions
86
packages/web-app-mail/src/components/MailAccountSwitch.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,86 @@ | ||||||||||||||||||||
| <template> | ||||||||||||||||||||
| <oc-button | ||||||||||||||||||||
| id="account-list-toggle" | ||||||||||||||||||||
| class="w-full" | ||||||||||||||||||||
| appearance="filled" | ||||||||||||||||||||
| color-role="surface" | ||||||||||||||||||||
| justify-content="space-between" | ||||||||||||||||||||
| no-hover | ||||||||||||||||||||
| > | ||||||||||||||||||||
| <app-loading-spinner v-if="isLoading" /> | ||||||||||||||||||||
| <div v-else class="flex justify-between items-center w-full"> | ||||||||||||||||||||
| <div class="flex items-center truncate"> | ||||||||||||||||||||
| <oc-avatar :user-name="currentAccount.name" /> | ||||||||||||||||||||
| <div class="flex flex-col items-start ml-5 truncate"> | ||||||||||||||||||||
| <span class="font-bold" v-text="currentAccount.name" /> | ||||||||||||||||||||
| <span | ||||||||||||||||||||
| v-if="currentAccount.identities?.[0]?.email" | ||||||||||||||||||||
| v-text="currentAccount.identities[0].email" | ||||||||||||||||||||
| /> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| <oc-icon class="ml-2" name="more-2" /> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| </oc-button> | ||||||||||||||||||||
| <oc-drop :title="$gettext('Accounts')" class="w-md" toggle="#account-list-toggle" close-on-click> | ||||||||||||||||||||
| <oc-list> | ||||||||||||||||||||
| <li v-for="account in accounts" :key="account.accountId" class="oc-list"> | ||||||||||||||||||||
| <oc-button | ||||||||||||||||||||
| class="p-2" | ||||||||||||||||||||
| :appearance="account.accountId === currentAccount.accountId ? 'filled' : 'raw-inverse'" | ||||||||||||||||||||
| :color-role=" | ||||||||||||||||||||
| account.accountId === currentAccount.accountId ? 'secondaryContainer' : 'surface' | ||||||||||||||||||||
| " | ||||||||||||||||||||
| @click="onSelectAccount(account)" | ||||||||||||||||||||
| > | ||||||||||||||||||||
| <div class="flex justify-between items-center w-full"> | ||||||||||||||||||||
| <div class="flex items-center truncate"> | ||||||||||||||||||||
| <oc-avatar :user-name="account.name" /> | ||||||||||||||||||||
| <div class="flex flex-col items-start ml-5 truncate"> | ||||||||||||||||||||
| <span class="font-bold" v-text="account.name" /> | ||||||||||||||||||||
| <span v-if="account.identities?.[0]?.email" v-text="account.identities[0].email" /> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| <oc-icon | ||||||||||||||||||||
| v-if="account.accountId === currentAccount.accountId" | ||||||||||||||||||||
| class="ml-2" | ||||||||||||||||||||
| name="check" | ||||||||||||||||||||
| /> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| </oc-button> | ||||||||||||||||||||
| </li> | ||||||||||||||||||||
| </oc-list> | ||||||||||||||||||||
| </oc-drop> | ||||||||||||||||||||
| </template> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <script setup lang="ts"> | ||||||||||||||||||||
| import { AppLoadingSpinner } from '@opencloud-eu/web-pkg' | ||||||||||||||||||||
| import type { MailAccount } from '../types' | ||||||||||||||||||||
| import { useLoadAccounts } from '../composables/useLoadAccounts' | ||||||||||||||||||||
| import { useAccountsStore } from '../composables/piniaStores/accounts' | ||||||||||||||||||||
| import { storeToRefs } from 'pinia' | ||||||||||||||||||||
| import { useMailboxesStore } from '../composables/piniaStores/mailboxes' | ||||||||||||||||||||
| import { useLoadMailboxes } from '../composables/useLoadMailboxes' | ||||||||||||||||||||
| import { unref } from 'vue' | ||||||||||||||||||||
| import { useLoadMails } from '../composables/useLoadMails' | ||||||||||||||||||||
| import { useMailsStore } from '../composables/piniaStores/mails' | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const accountsStore = useAccountsStore() | ||||||||||||||||||||
| const { accounts, currentAccount } = storeToRefs(accountsStore) | ||||||||||||||||||||
| const { setCurrentAccount } = accountsStore | ||||||||||||||||||||
| const mailboxesStore = useMailboxesStore() | ||||||||||||||||||||
| const { mailboxes, currentMailbox } = storeToRefs(mailboxesStore) | ||||||||||||||||||||
| const { setCurrentMailbox } = mailboxesStore | ||||||||||||||||||||
| const { loadMailboxes } = useLoadMailboxes() | ||||||||||||||||||||
| const { loadMails } = useLoadMails() | ||||||||||||||||||||
| const { setCurrentMail } = useMailsStore() | ||||||||||||||||||||
| const { isLoading } = useLoadAccounts() | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const onSelectAccount = async (account: MailAccount) => { | ||||||||||||||||||||
| setCurrentAccount(account) | ||||||||||||||||||||
| setCurrentMail(null) | ||||||||||||||||||||
| await loadMailboxes(unref(currentAccount).accountId) | ||||||||||||||||||||
| setCurrentMailbox(unref(mailboxes)[0]) | ||||||||||||||||||||
| await loadMails(unref(currentAccount).accountId, unref(currentMailbox).id) | ||||||||||||||||||||
|
Comment on lines
+83
to
+84
|
||||||||||||||||||||
| setCurrentMailbox(unref(mailboxes)[0]) | |
| await loadMails(unref(currentAccount).accountId, unref(currentMailbox).id) | |
| if (unref(mailboxes) && unref(mailboxes).length > 0) { | |
| setCurrentMailbox(unref(mailboxes)[0]) | |
| await loadMails(unref(currentAccount).accountId, unref(mailboxes)[0].id) | |
| } else { | |
| setCurrentMailbox(null) | |
| // Optionally handle the empty mailbox case here (e.g., show a message) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just noticing it here: could you add
index.tsfiles which export all the files of a dir, so that we can merge multiple imports into one line? like we do it in all other apps and packages...