fix: Fixes bug with locale switching from popover (#5426)

This commit is contained in:
Nithin David Thomas 2022-09-13 18:49:55 +05:30 committed by GitHub
parent 8af27d861b
commit cb4dd7e633
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 32 deletions

View file

@ -10,7 +10,7 @@
v-if="portals.length" v-if="portals.length"
:class="sidebarClassName" :class="sidebarClassName"
:header-title="headerTitle" :header-title="headerTitle"
:sub-title="localeName(selectedPortalLocale)" :sub-title="localeName(selectedLocaleInPortal)"
:accessible-menu-items="accessibleMenuItems" :accessible-menu-items="accessibleMenuItems"
:additional-secondary-menu-items="additionalSecondaryMenuItems" :additional-secondary-menu-items="additionalSecondaryMenuItems"
@open-popover="openPortalPopover" @open-popover="openPortalPopover"
@ -32,13 +32,14 @@
v-if="showPortalPopover" v-if="showPortalPopover"
:portals="portals" :portals="portals"
:active-portal-slug="selectedPortalSlug" :active-portal-slug="selectedPortalSlug"
:active-locale="selectedLocaleInPortal"
@close-popover="closePortalPopover" @close-popover="closePortalPopover"
/> />
<add-category <add-category
v-if="showAddCategoryModal" v-if="showAddCategoryModal"
:show.sync="showAddCategoryModal" :show.sync="showAddCategoryModal"
:portal-name="selectedPortalName" :portal-name="selectedPortalName"
:locale="selectedPortalLocale" :locale="selectedLocaleInPortal"
:portal-slug="selectedPortalSlug" :portal-slug="selectedPortalSlug"
@cancel="onClickCloseAddCategoryModal" @cancel="onClickCloseAddCategoryModal"
/> />
@ -96,6 +97,9 @@ export default {
return this.$store.getters['portals/allPortals'][0]; return this.$store.getters['portals/allPortals'][0];
}, },
selectedLocaleInPortal() {
return this.$route.params.locale || this.defaultPortalLocale;
},
sidebarClassName() { sidebarClassName() {
if (this.isOnDesktop) { if (this.isOnDesktop) {
return ''; return '';
@ -120,7 +124,7 @@ export default {
selectedPortalSlug() { selectedPortalSlug() {
return this.selectedPortal ? this.selectedPortal?.slug : ''; return this.selectedPortal ? this.selectedPortal?.slug : '';
}, },
selectedPortalLocale() { defaultPortalLocale() {
return this.selectedPortal return this.selectedPortal
? this.selectedPortal?.meta?.default_locale ? this.selectedPortal?.meta?.default_locale
: ''; : '';
@ -142,7 +146,7 @@ export default {
key: 'list_all_locale_articles', key: 'list_all_locale_articles',
count: allArticlesCount, count: allArticlesCount,
toState: frontendURL( toState: frontendURL(
`accounts/${this.accountId}/portals/${this.selectedPortalSlug}/${this.selectedPortalLocale}/articles` `accounts/${this.accountId}/portals/${this.selectedPortalSlug}/${this.selectedLocaleInPortal}/articles`
), ),
toolTip: 'All Articles', toolTip: 'All Articles',
toStateName: 'list_all_locale_articles', toStateName: 'list_all_locale_articles',
@ -153,7 +157,7 @@ export default {
key: 'list_mine_articles', key: 'list_mine_articles',
count: mineArticlesCount, count: mineArticlesCount,
toState: frontendURL( toState: frontendURL(
`accounts/${this.accountId}/portals/${this.selectedPortalSlug}/${this.selectedPortalLocale}/articles/mine` `accounts/${this.accountId}/portals/${this.selectedPortalSlug}/${this.selectedLocaleInPortal}/articles/mine`
), ),
toolTip: 'My articles', toolTip: 'My articles',
toStateName: 'list_mine_articles', toStateName: 'list_mine_articles',
@ -164,7 +168,7 @@ export default {
key: 'list_draft_articles', key: 'list_draft_articles',
count: draftArticlesCount, count: draftArticlesCount,
toState: frontendURL( toState: frontendURL(
`accounts/${this.accountId}/portals/${this.selectedPortalSlug}/${this.selectedPortalLocale}/articles/draft` `accounts/${this.accountId}/portals/${this.selectedPortalSlug}/${this.selectedLocaleInPortal}/articles/draft`
), ),
toolTip: 'Draft', toolTip: 'Draft',
toStateName: 'list_draft_articles', toStateName: 'list_draft_articles',
@ -175,7 +179,7 @@ export default {
key: 'list_archived_articles', key: 'list_archived_articles',
count: archivedArticlesCount, count: archivedArticlesCount,
toState: frontendURL( toState: frontendURL(
`accounts/${this.accountId}/portals/${this.selectedPortalSlug}/${this.selectedPortalLocale}/articles/archived` `accounts/${this.accountId}/portals/${this.selectedPortalSlug}/${this.selectedLocaleInPortal}/articles/archived`
), ),
toolTip: 'Archived', toolTip: 'Archived',
toStateName: 'list_archived_articles', toStateName: 'list_archived_articles',

View file

@ -34,18 +34,11 @@
:key="portal.id" :key="portal.id"
:portal="portal" :portal="portal"
:active-portal-slug="activePortalSlug" :active-portal-slug="activePortalSlug"
:active-locale="activeLocale"
:active="portal.slug === activePortalSlug" :active="portal.slug === activePortalSlug"
@open-portal-page="onPortalSelect" @open-portal-page="onPortalSelect"
/> />
</div> </div>
<footer>
<woot-button variant="link" @click="closePortalPopover">
{{ $t('HELP_CENTER.PORTAL.POPOVER.CANCEL_BUTTON_LABEL') }}
</woot-button>
<woot-button @click="() => {}">
{{ $t('HELP_CENTER.PORTAL.POPOVER.CHOOSE_LOCALE_BUTTON') }}
</woot-button>
</footer>
</div> </div>
</template> </template>
@ -66,6 +59,10 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
activeLocale: {
type: String,
default: '',
},
}, },
methods: { methods: {
@ -125,12 +122,5 @@ export default {
} }
} }
} }
footer {
display: flex;
justify-content: end;
align-items: center;
gap: var(--space-small);
}
} }
</style> </style>

View file

@ -19,13 +19,13 @@
/> />
</header> </header>
<div class="portal-locales"> <div class="portal-locales">
<h5 class="locale-title"> <h5 class="locale-title sub-block-title">
{{ $t('HELP_CENTER.PORTAL.CHOOSE_LOCALE_LABEL') }} {{ $t('HELP_CENTER.PORTAL.CHOOSE_LOCALE_LABEL') }}
</h5> </h5>
<ul> <ul>
<li v-for="locale in locales" :key="locale.code"> <li v-for="locale in locales" :key="locale.code">
<woot-button <woot-button
:class=" :variant="
`locale-item ${ `locale-item ${
isLocaleActive(locale.code, activePortalSlug) isLocaleActive(locale.code, activePortalSlug)
? 'smooth' ? 'smooth'
@ -38,7 +38,7 @@
> >
<div class="locale-content"> <div class="locale-content">
<div class="meta"> <div class="meta">
<h6 class="text-block-title text-left"> <h6 class="text-block-title text-left locale-name">
<span> <span>
{{ localeName(locale.code) }} {{ localeName(locale.code) }}
</span> </span>
@ -90,6 +90,10 @@ export default {
type: String, type: String,
default: '', default: '',
}, },
activeLocale: {
type: String,
default: '',
},
}, },
data() { data() {
return { return {
@ -129,7 +133,7 @@ export default {
}, },
isLocaleActive(code, slug) { isLocaleActive(code, slug) {
const isPortalActive = this.portal.slug === slug; const isPortalActive = this.portal.slug === slug;
const isLocaleActive = this.portal?.meta?.default_locale === code; const isLocaleActive = this.activeLocale === code;
return isPortalActive && isLocaleActive; return isPortalActive && isLocaleActive;
}, },
isLocaleDefault(code) { isLocaleDefault(code) {
@ -151,6 +155,7 @@ export default {
&.active { &.active {
border: 1px solid var(--w-400); border: 1px solid var(--w-400);
background: var(---25);
} }
.actions-container { .actions-container {
@ -177,15 +182,13 @@ export default {
.portal-count { .portal-count {
font-size: var(--font-size-mini); font-size: var(--font-size-mini);
margin-bottom: 0; margin-bottom: 0;
color: var(--s-500); color: var(--s-600);
} }
} }
.portal-locales { .portal-locales {
.locale-title { .locale-name {
color: var(--s-600); margin-bottom: var(--space-micro);
font-size: var(--font-size-default);
font-weight: var(--font-weight-medium);
} }
.locale-content { .locale-content {
@ -204,6 +207,7 @@ export default {
.locale__radio { .locale__radio {
width: var(--space-large); width: var(--space-large);
margin-top: var(--space-tiny); margin-top: var(--space-tiny);
color: var(--g-600);
} }
.add-locale-wrap { .add-locale-wrap {
@ -227,7 +231,7 @@ export default {
.locale-meta { .locale-meta {
display: flex; display: flex;
color: var(--s-500); color: var(--s-600);
font-size: var(--font-size-small); font-size: var(--font-size-small);
text-align: left; text-align: left;
line-height: var(--space-normal); line-height: var(--space-normal);