feat: Open "Switch Account" modal when clicking account name on dashboard (#4613)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Jordan Brough 2022-05-06 03:25:38 -06:00 committed by GitHub
parent 8d2b719dc1
commit 77a6893203
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 74 additions and 2 deletions

View file

@ -19,6 +19,7 @@
:menu-config="activeSecondaryMenu" :menu-config="activeSecondaryMenu"
:current-role="currentRole" :current-role="currentRole"
@add-label="showAddLabelPopup" @add-label="showAddLabelPopup"
@toggle-accounts="toggleAccountModal"
/> />
</aside> </aside>
</template> </template>

View file

@ -1,14 +1,34 @@
<template> <template>
<div v-if="showShowCurrentAccountContext" class="account-context--group"> <div
v-if="showShowCurrentAccountContext"
class="account-context--group"
@mouseover="setShowSwitch"
@mouseleave="resetShowSwitch"
>
{{ $t('SIDEBAR.CURRENTLY_VIEWING_ACCOUNT') }} {{ $t('SIDEBAR.CURRENTLY_VIEWING_ACCOUNT') }}
<p class="account-context--name text-ellipsis"> <p class="account-context--name text-ellipsis">
{{ account.name }} {{ account.name }}
</p> </p>
<transition name="fade">
<div v-if="showSwitchButton" class="account-context--switch-group">
<woot-button
variant="clear"
icon="arrow-swap"
class="cursor-pointer"
@click="$emit('toggle-accounts')"
>
{{ $t('SIDEBAR.SWITCH') }}
</woot-button>
</div>
</transition>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
export default { export default {
data() {
return { showSwitchButton: false };
},
computed: { computed: {
...mapGetters({ ...mapGetters({
account: 'getCurrentAccount', account: 'getCurrentAccount',
@ -18,6 +38,14 @@ export default {
return this.userAccounts.length > 1 && this.account.name; return this.userAccounts.length > 1 && this.account.name;
}, },
}, },
methods: {
setShowSwitch() {
this.showSwitchButton = true;
},
resetShowSwitch() {
this.showSwitchButton = false;
},
},
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@ -27,10 +55,49 @@ export default {
font-size: var(--font-size-mini); font-size: var(--font-size-mini);
padding: var(--space-small); padding: var(--space-small);
margin-bottom: var(--space-small); margin-bottom: var(--space-small);
width: 100%;
position: relative;
&:hover {
background: var(--b-100);
}
.account-context--name { .account-context--name {
font-weight: var(--font-weight-medium); font-weight: var(--font-weight-medium);
margin-bottom: 0; margin-bottom: 0;
} }
} }
.account-context--switch-group {
--overlay-shadow: linear-gradient(
to right,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 1) 50%
);
align-items: center;
background-image: var(--overlay-shadow);
border-top-left-radius: 0;
border-top-right-radius: var(--border-radius-normal);
border-bottom-left-radius: 0;
border-bottom-right-radius: var(--border-radius-normal);
display: flex;
height: 100%;
justify-content: end;
opacity: 1;
position: absolute;
right: 0;
top: 0;
width: 100%;
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 300ms ease;
}
.fade-enter,
.fade-leave-to {
opacity: 0;
}
</style> </style>

View file

@ -1,6 +1,6 @@
<template> <template>
<div v-if="hasSecondaryMenu" class="main-nav secondary-menu"> <div v-if="hasSecondaryMenu" class="main-nav secondary-menu">
<account-context /> <account-context @toggle-accounts="toggleAccountModal" />
<transition-group name="menu-list" tag="ul" class="menu vertical"> <transition-group name="menu-list" tag="ul" class="menu vertical">
<secondary-nav-item <secondary-nav-item
v-for="menuItem in accessibleMenuItems" v-for="menuItem in accessibleMenuItems"
@ -224,6 +224,9 @@ export default {
showAddLabelPopup() { showAddLabelPopup() {
this.$emit('add-label'); this.$emit('add-label');
}, },
toggleAccountModal() {
this.$emit('toggle-accounts');
},
}, },
}; };
</script> </script>

View file

@ -147,6 +147,7 @@
}, },
"SIDEBAR": { "SIDEBAR": {
"CURRENTLY_VIEWING_ACCOUNT": "Currently viewing:", "CURRENTLY_VIEWING_ACCOUNT": "Currently viewing:",
"SWITCH": "Switch",
"CONVERSATIONS": "Conversations", "CONVERSATIONS": "Conversations",
"ALL_CONVERSATIONS": "All Conversations", "ALL_CONVERSATIONS": "All Conversations",
"MENTIONED_CONVERSATIONS": "Mentions", "MENTIONED_CONVERSATIONS": "Mentions",