feat: Opening and closing portal switch (#5126)

This commit is contained in:
Sivin Varghese 2022-07-28 14:52:05 +05:30 committed by GitHub
parent 41df70fb96
commit ef9ea99b91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 336 additions and 37 deletions

View file

@ -4,7 +4,18 @@
"FILTER": "Filter by", "FILTER": "Filter by",
"SORT": "Sort by", "SORT": "Sort by",
"SETTINGS_BUTTON": "Settings", "SETTINGS_BUTTON": "Settings",
"NEW_BUTTON": "New Article" "NEW_BUTTON": "New Article",
"DROPDOWN_OPTIONS": {
"PUBLISHED": "Published",
"DRAFT": "Draft",
"ARCHIVED": "Archived"
},
"TITLES": {
"ALL_ARTICLES": "All Articles",
"MINE": "My Articles",
"DRAFT": "Draft Articles",
"ARCHIVED": "Archived Articles"
}
}, },
"EDIT_HEADER": { "EDIT_HEADER": {
"PUBLISH_BUTTON": "Publish", "PUBLISH_BUTTON": "Publish",
@ -27,11 +38,59 @@
"CANCEL_BUTTON_LABEL": "Cancel", "CANCEL_BUTTON_LABEL": "Cancel",
"CHOOSE_LOCALE_BUTTON": "Choose Locale" "CHOOSE_LOCALE_BUTTON": "Choose Locale"
} }
} },
}, "TABLE": {
"TABLE": { "LOADING_MESSAGE": "Loading articles...",
"COLUMNS": { "404": "No articles matches your search 🔍",
"BY": "by" "NO_ARTICLES": "There are no available articles",
"HEADERS": {
"TITLE": "Title",
"CATEGORY": "Category",
"READ_COUNT": "Read count",
"STATUS": "Status",
"LAST_EDITED": "Last edited"
},
"COLUMNS": {
"BY": "by"
}
},
"EDIT_ARTICLE": {
"TITLE_PLACEHOLDER": "Article title goes here",
"CONTENT_PLACEHOLDER": "Write your article here"
},
"SIDEBAR": {
"SEARCH": {
"PLACEHOLDER": "Search for articles"
}
},
"CATEGORY": {
"ADD": {
"TITLE": "Create a category",
"SUB_TITLE": "The category will be used in the public facing portal to categorize articles.",
"PORTAL": "Portal",
"LOCALE": "Locale",
"NAME": {
"LABEL": "Name",
"PLACEHOLDER": "Category name",
"HELP_TEXT": "The category name will be used in the public facing portal to categorize articles.",
"ERROR": "Name is required"
},
"SLUG": {
"LABEL": "Slug",
"PLACEHOLDER": "Category slug for urls",
"HELP_TEXT": "app.chatwoot.com/portal/my-portal/en-US/categories/my-slug",
"ERROR": "Slug is required"
},
"DESCRIPTION": {
"LABEL": "Description",
"PLACEHOLDER": "Give a short description about the category.",
"ERROR": "Description is required"
},
"BUTTONS": {
"CREATE": "Create category",
"CANCEL": "Cancel"
}
}
} }
} }
} }

View file

@ -12,6 +12,7 @@
sub-title="English" sub-title="English"
:accessible-menu-items="accessibleMenuItems" :accessible-menu-items="accessibleMenuItems"
:additional-secondary-menu-items="additionalSecondaryMenuItems" :additional-secondary-menu-items="additionalSecondaryMenuItems"
@open-popover="openPortalPopover"
/> />
</div> </div>
<section class="app-content columns"> <section class="app-content columns">
@ -26,6 +27,11 @@
v-if="showNotificationPanel" v-if="showNotificationPanel"
@close="closeNotificationPanel" @close="closeNotificationPanel"
/> />
<portal-popover
v-if="showPortalPopover"
:portals="portals"
@close-popover="closePortalPopover"
/>
</section> </section>
</div> </div>
</template> </template>
@ -34,7 +40,8 @@ import { mapGetters } from 'vuex';
import { frontendURL } from '../../../../helper/URLHelper'; import { frontendURL } from '../../../../helper/URLHelper';
import Sidebar from 'dashboard/components/layout/Sidebar'; import Sidebar from 'dashboard/components/layout/Sidebar';
import HelpCenterSidebar from 'dashboard/components/helpCenter/Sidebar/Sidebar'; import PortalPopover from 'dashboard/routes/dashboard/helpcenter/components/PortalPopover';
import HelpCenterSidebar from 'dashboard/routes/dashboard/helpcenter/components/Sidebar/Sidebar';
import CommandBar from 'dashboard/routes/dashboard/commands/commandbar.vue'; import CommandBar from 'dashboard/routes/dashboard/commands/commandbar.vue';
import WootKeyShortcutModal from 'dashboard/components/widgets/modal/WootKeyShortcutModal'; import WootKeyShortcutModal from 'dashboard/components/widgets/modal/WootKeyShortcutModal';
import NotificationPanel from 'dashboard/routes/dashboard/notifications/components/NotificationPanel.vue'; import NotificationPanel from 'dashboard/routes/dashboard/notifications/components/NotificationPanel.vue';
@ -46,11 +53,13 @@ export default {
CommandBar, CommandBar,
WootKeyShortcutModal, WootKeyShortcutModal,
NotificationPanel, NotificationPanel,
PortalPopover,
}, },
data() { data() {
return { return {
showShortcutModal: false, showShortcutModal: false,
showNotificationPanel: false, showNotificationPanel: false,
showPortalPopover: false,
}; };
}, },
computed: { computed: {
@ -171,6 +180,136 @@ export default {
}, },
]; ];
}, },
portals() {
return [
{
name: 'Chatwoot Help Center',
id: 1,
color: null,
custom_domain: 'doc',
articles_count: 123,
header_text: null,
homepage_link: null,
page_title: null,
slug: 'first_portal',
archived: false,
config: {
allowed_locales: [
{
code: 'en',
name: 'English',
articles_count: 123,
},
{
code: 'fr',
name: 'Français',
articles_count: 123,
},
{
code: 'de',
name: 'Deutsch',
articles_count: 32,
},
{
code: 'es',
name: 'Español',
articles_count: 12,
},
{
code: 'it',
name: 'Italiano',
articles_count: 8,
},
],
},
locales: [
{
name: 'English',
code: 'en',
articles_count: 12,
},
{
name: 'Español',
code: 'es',
articles_count: 42,
},
{
name: 'French',
code: 'fr',
articles_count: 29,
},
{
name: 'Italian',
code: 'it',
articles_count: 4,
},
{
name: 'German',
code: 'de',
articles_count: 66,
},
],
},
{
name: 'Chatwoot Docs',
id: 2,
color: null,
custom_domain: 'doc',
articles_count: 124,
header_text: null,
homepage_link: null,
page_title: null,
slug: 'second_portal',
archived: false,
config: {
allowed_locales: [
{
code: 'en',
name: 'English',
articles_count: 123,
},
{
code: 'fr',
name: 'Français',
articles_count: 123,
},
{
code: 'de',
name: 'Deutsch',
articles_count: 32,
},
{
code: 'es',
name: 'Español',
articles_count: 12,
},
{
code: 'it',
name: 'Italiano',
articles_count: 8,
},
],
},
locales: [
{
name: 'English',
code: 'en',
articles_count: 12,
},
{
name: 'Japanese',
code: 'jp',
articles_count: 4,
},
{
name: 'Mandarin',
code: 'CH',
articles_count: 6,
},
],
},
];
},
currentRoute() { currentRoute() {
return ' '; return ' ';
}, },
@ -188,6 +327,12 @@ export default {
closeNotificationPanel() { closeNotificationPanel() {
this.showNotificationPanel = false; this.showNotificationPanel = false;
}, },
openPortalPopover() {
this.showPortalPopover = !this.showPortalPopover;
},
closePortalPopover() {
this.showPortalPopover = false;
},
}, },
}; };
</script> </script>

View file

@ -1,5 +1,5 @@
<template> <template>
<div class="portal-popover__container"> <div v-on-clickaway="closePortalPopover" class="portal-popover__container">
<header> <header>
<div class="actions"> <div class="actions">
<h2 class="block-title"> <h2 class="block-title">
@ -24,7 +24,7 @@
/> />
</div> </div>
<footer> <footer>
<woot-button variant="link"> <woot-button variant="link" @click="closePortalPopover">
{{ $t('HELP_CENTER.PORTAL.POPOVER.CANCEL_BUTTON_LABEL') }} {{ $t('HELP_CENTER.PORTAL.POPOVER.CANCEL_BUTTON_LABEL') }}
</woot-button> </woot-button>
<woot-button> <woot-button>
@ -35,22 +35,32 @@
</template> </template>
<script> <script>
import { mixin as clickaway } from 'vue-clickaway';
import PortalSwitch from './PortalSwitch.vue'; import PortalSwitch from './PortalSwitch.vue';
export default { export default {
components: { components: {
PortalSwitch, PortalSwitch,
}, },
mixins: [clickaway],
props: { props: {
portals: { portals: {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
}, },
methods: {
closePortalPopover() {
this.$emit('close-popover');
},
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.portal-popover__container { .portal-popover__container {
position: absolute;
overflow: scroll;
max-height: 96vh;
padding: var(--space-normal); padding: var(--space-normal);
background-color: var(--white); background-color: var(--white);
border-radius: var(--border-radius-normal); border-radius: var(--border-radius-normal);

View file

@ -4,26 +4,23 @@
:thumbnail-src="thumbnailSrc" :thumbnail-src="thumbnailSrc"
:header-title="headerTitle" :header-title="headerTitle"
:sub-title="subTitle" :sub-title="subTitle"
@open-popover="openPortalPopover"
/> />
<sidebar-search @input="onSearch" /> <sidebar-search @input="onSearch" />
<!-- <transition-group name="menu-list" tag="ul" class="menu vertical"> --> <transition-group name="menu-list" tag="ul" class="menu vertical">
<div name="menu-list" tag="ul" class="menu vertical">
<secondary-nav-item <secondary-nav-item
v-for="menuItem in accessibleMenuItems" v-for="menuItem in accessibleMenuItems"
:key="menuItem.toState" :key="menuItem.toState"
:menu-item="menuItem" :menu-item="menuItem"
:is-help-center-sidebar="true" :is-help-center-sidebar="true"
/> />
</div>
<div name="menu-list" tag="ul" class="menu vertical">
<secondary-nav-item <secondary-nav-item
v-for="menuItem in additionalSecondaryMenuItems" v-for="menuItem in additionalSecondaryMenuItems"
:key="menuItem.key" :key="menuItem.key"
:menu-item="menuItem" :menu-item="menuItem"
:is-help-center-sidebar="true" :is-help-center-sidebar="true"
/> />
</div> </transition-group>
<!-- </transition-group> -->
</div> </div>
</template> </template>
@ -67,6 +64,9 @@ export default {
onSearch(value) { onSearch(value) {
this.$emit('input', value); this.$emit('input', value);
}, },
openPortalPopover() {
this.$emit('open-popover');
},
}, },
}; };
</script> </script>

View file

@ -13,18 +13,29 @@
</div> </div>
</div> </div>
<div class="header-right--side"> <div class="header-right--side">
<fluent-icon <woot-button
icon="arrow-up-right" variant="link"
size="28px" color-scheme="secondary"
class="pop-out--icon"
@click="popOutHelpCenter" @click="popOutHelpCenter"
/> >
<fluent-icon <fluent-icon
icon="arrow-swap" icon="arrow-up-right"
size="28px" size="28px"
class="portal-switch--icon" class="pop-out--icon"
@click="openSwitchPortalModal" @click="popOutHelpCenter"
/> />
</woot-button>
<woot-button
variant="link"
color-scheme="secondary"
@click="openPortalPopover"
>
<fluent-icon
icon="arrow-swap"
size="28px"
class="portal-switch--icon"
/>
</woot-button>
</div> </div>
</div> </div>
</template> </template>
@ -53,8 +64,8 @@ export default {
popOutHelpCenter() { popOutHelpCenter() {
this.$emit('pop-out'); this.$emit('pop-out');
}, },
openSwitchPortalModal() { openPortalPopover() {
this.$emit('open'); this.$emit('open-popover');
}, },
}, },
}; };

View file

@ -1,5 +1,5 @@
import { action } from '@storybook/addon-actions'; import { action } from '@storybook/addon-actions';
import ArticleHeader from './ArticleHeader'; import ArticleHeader from '../Header/ArticleHeader';
export default { export default {
title: 'Components/Help Center/Header', title: 'Components/Help Center/Header',

View file

@ -1,5 +1,5 @@
import { action } from '@storybook/addon-actions'; import { action } from '@storybook/addon-actions';
import EditArticleHeader from './EditArticleHeader'; import EditArticleHeader from '../Header/EditArticleHeader';
export default { export default {
title: 'Components/Help Center/Header', title: 'Components/Help Center/Header',

View file

@ -26,7 +26,44 @@ Primary.args = {
portals: [ portals: [
{ {
name: 'Chatwoot Help Center', name: 'Chatwoot Help Center',
articles_count: 124, id: 1,
color: null,
custom_domain: 'doc',
articles_count: 123,
header_text: null,
homepage_link: null,
page_title: null,
slug: 'first_portal',
archived: false,
config: {
allowed_locales: [
{
code: 'en',
name: 'English',
articles_count: 123,
},
{
code: 'fr',
name: 'Français',
articles_count: 123,
},
{
code: 'de',
name: 'Deutsch',
articles_count: 32,
},
{
code: 'es',
name: 'Español',
articles_count: 12,
},
{
code: 'it',
name: 'Italiano',
articles_count: 8,
},
],
},
locales: [ locales: [
{ {
name: 'English', name: 'English',
@ -57,7 +94,44 @@ Primary.args = {
}, },
{ {
name: 'Chatwoot Docs', name: 'Chatwoot Docs',
articles_count: 16, id: 2,
color: null,
custom_domain: 'doc',
articles_count: 124,
header_text: null,
homepage_link: null,
page_title: null,
slug: 'second_portal',
archived: false,
config: {
allowed_locales: [
{
code: 'en',
name: 'English',
articles_count: 123,
},
{
code: 'fr',
name: 'Français',
articles_count: 123,
},
{
code: 'de',
name: 'Deutsch',
articles_count: 32,
},
{
code: 'es',
name: 'Español',
articles_count: 12,
},
{
code: 'it',
name: 'Italiano',
articles_count: 8,
},
],
},
locales: [ locales: [
{ {
name: 'English', name: 'English',

View file

@ -1,5 +1,5 @@
import { action } from '@storybook/addon-actions'; import { action } from '@storybook/addon-actions';
import Sidebar from './Sidebar'; import Sidebar from '../Sidebar/Sidebar';
import Thumbnail from 'dashboard/components/widgets/Thumbnail'; import Thumbnail from 'dashboard/components/widgets/Thumbnail';
export default { export default {

View file

@ -10,7 +10,7 @@
</template> </template>
<script> <script>
import EditArticleHeader from 'dashboard/components/helpCenter/Header/EditArticleHeader'; import EditArticleHeader from 'dashboard/routes/dashboard/helpcenter/components/Header/EditArticleHeader';
import EditArticleField from 'dashboard/components/helpCenter/EditArticle'; import EditArticleField from 'dashboard/components/helpCenter/EditArticle';
export default { export default {
components: { components: {

View file

@ -23,8 +23,8 @@
</template> </template>
<script> <script>
import Spinner from 'shared/components/Spinner.vue'; import Spinner from 'shared/components/Spinner.vue';
import ArticleHeader from 'dashboard/components/helpCenter/Header/ArticleHeader'; import ArticleHeader from 'dashboard/routes/dashboard/helpcenter/components/Header/ArticleHeader';
import EmptyState from 'dashboard/components/widgets/EmptyState.vue'; import EmptyState from 'dashboard/components/widgets/EmptyState';
import ArticleTable from '../../components/ArticleTable'; import ArticleTable from '../../components/ArticleTable';
export default { export default {
components: { components: {

View file

@ -10,7 +10,7 @@
</template> </template>
<script> <script>
import EditArticleHeader from 'dashboard/components/helpCenter/Header/EditArticleHeader'; import EditArticleHeader from 'dashboard/routes/dashboard/helpcenter/components/Header/EditArticleHeader';
import EditArticleField from 'dashboard/components/helpCenter/EditArticle'; import EditArticleField from 'dashboard/components/helpCenter/EditArticle';
export default { export default {
components: { components: {