chore: Cleanup feature flags (#6096)
- Add more feature flags for CRM, auto_resolution, and reports - Add a SuperAdmin link in the sidebar if the user is a super-admin - SuperAdmin could view all the features on an account irrespective of whether the feature is enabled.
This commit is contained in:
parent
ca88eb55f4
commit
2dfe38ae4d
14 changed files with 99 additions and 15 deletions
|
@ -1,3 +1,4 @@
|
|||
import { FEATURE_FLAGS } from '../../../../featureFlags';
|
||||
import { frontendURL } from '../../../../helper/URLHelper';
|
||||
|
||||
const primaryMenuItems = accountId => [
|
||||
|
@ -13,6 +14,7 @@ const primaryMenuItems = accountId => [
|
|||
icon: 'book-contacts',
|
||||
key: 'contacts',
|
||||
label: 'CONTACTS',
|
||||
featureFlag: FEATURE_FLAGS.CRM,
|
||||
toState: frontendURL(`accounts/${accountId}/contacts`),
|
||||
toStateName: 'contacts_dashboard',
|
||||
roles: ['administrator', 'agent'],
|
||||
|
@ -21,6 +23,7 @@ const primaryMenuItems = accountId => [
|
|||
icon: 'arrow-trending-lines',
|
||||
key: 'reports',
|
||||
label: 'REPORTS',
|
||||
featureFlag: FEATURE_FLAGS.REPORTS,
|
||||
toState: frontendURL(`accounts/${accountId}/reports`),
|
||||
toStateName: 'settings_account_reports',
|
||||
roles: ['administrator'],
|
||||
|
@ -29,7 +32,7 @@ const primaryMenuItems = accountId => [
|
|||
icon: 'megaphone',
|
||||
key: 'campaigns',
|
||||
label: 'CAMPAIGNS',
|
||||
featureFlag: 'campaigns',
|
||||
featureFlag: FEATURE_FLAGS.CAMPAIGNS,
|
||||
toState: frontendURL(`accounts/${accountId}/campaigns`),
|
||||
toStateName: 'settings_account_campaigns',
|
||||
roles: ['administrator'],
|
||||
|
@ -38,7 +41,7 @@ const primaryMenuItems = accountId => [
|
|||
icon: 'library',
|
||||
key: 'helpcenter',
|
||||
label: 'HELP_CENTER.TITLE',
|
||||
featureFlag: 'help_center',
|
||||
featureFlag: FEATURE_FLAGS.HELP_CENTER,
|
||||
toState: frontendURL(`accounts/${accountId}/portals`),
|
||||
toStateName: 'default_portal_articles',
|
||||
roles: ['administrator'],
|
||||
|
|
|
@ -102,6 +102,7 @@ const settings = accountId => ({
|
|||
label: 'AGENT_BOTS',
|
||||
beta: true,
|
||||
hasSubMenu: false,
|
||||
globalConfigFlag: 'csmlEditorHost',
|
||||
toState: frontendURL(`accounts/${accountId}/settings/agent-bots`),
|
||||
toStateName: 'agent_bots',
|
||||
featureFlag: FEATURE_FLAGS.AGENT_BOTS,
|
||||
|
|
|
@ -61,6 +61,24 @@
|
|||
</a>
|
||||
</router-link>
|
||||
</woot-dropdown-item>
|
||||
<woot-dropdown-item v-if="currentUser.type === 'SuperAdmin'">
|
||||
<a
|
||||
href="/super_admin"
|
||||
class="button small clear secondary"
|
||||
target="_blank"
|
||||
rel="noopener nofollow noreferrer"
|
||||
@click="$emit('close')"
|
||||
>
|
||||
<fluent-icon
|
||||
icon="content-settings"
|
||||
size="14"
|
||||
class="icon icon--font"
|
||||
/>
|
||||
<span class="button__content">
|
||||
{{ $t('SIDEBAR_ITEMS.SUPER_ADMIN_CONSOLE') }}
|
||||
</span>
|
||||
</a>
|
||||
</woot-dropdown-item>
|
||||
<woot-dropdown-item>
|
||||
<woot-button
|
||||
variant="clear"
|
||||
|
|
|
@ -106,18 +106,22 @@ export default {
|
|||
activeInbox: 'getSelectedInbox',
|
||||
accountId: 'getCurrentAccountId',
|
||||
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
|
||||
globalConfig: 'globalConfig/get',
|
||||
}),
|
||||
hasSubMenu() {
|
||||
return !!this.menuItem.children;
|
||||
},
|
||||
isMenuItemVisible() {
|
||||
if (!this.menuItem.featureFlag) {
|
||||
return true;
|
||||
if (this.menuItem.globalConfigFlag) {
|
||||
return !!this.globalConfig[this.menuItem.globalConfigFlag];
|
||||
}
|
||||
return this.isFeatureEnabledonAccount(
|
||||
this.accountId,
|
||||
this.menuItem.featureFlag
|
||||
);
|
||||
if (this.menuItem.featureFlag) {
|
||||
return this.isFeatureEnabledonAccount(
|
||||
this.accountId,
|
||||
this.menuItem.featureFlag
|
||||
);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
isAllConversations() {
|
||||
return (
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
export const FEATURE_FLAGS = {
|
||||
AGENT_BOTS: 'agent_bots',
|
||||
AGENT_MANAGEMENT: 'agent_management',
|
||||
AUTO_RESOLVE_CONVERSATIONS: 'auto_resolve_conversations',
|
||||
AUTOMATIONS: 'automations',
|
||||
CAMPAIGNS: 'campaigns',
|
||||
CANNED_RESPONSES: 'canned_responses',
|
||||
CRM: 'crm',
|
||||
CUSTOM_ATTRIBUTES: 'custom_attributes',
|
||||
INBOX_MANAGEMENT: 'inbox_management',
|
||||
INTEGRATIONS: 'integrations',
|
||||
LABELS: 'labels',
|
||||
MACROS: 'macros',
|
||||
HELP_CENTER: 'help_center',
|
||||
REPORTS: 'reports',
|
||||
TEAM_MANAGEMENT: 'team_management',
|
||||
VOICE_RECORDER: 'voice_recorder',
|
||||
};
|
||||
|
|
|
@ -132,6 +132,7 @@
|
|||
"SELECTOR_SUBTITLE": "Select an account from the following list",
|
||||
"PROFILE_SETTINGS": "Profile Settings",
|
||||
"KEYBOARD_SHORTCUTS": "Keyboard Shortcuts",
|
||||
"SUPER_ADMIN_CONSOLE": "Super Admin Console",
|
||||
"LOGOUT": "Logout"
|
||||
},
|
||||
"APP_GLOBAL": {
|
||||
|
|
|
@ -32,6 +32,7 @@ const GO_TO_COMMANDS = [
|
|||
id: 'goto_contacts_dashboard',
|
||||
title: 'COMMAND_BAR.COMMANDS.GO_TO_CONTACTS_DASHBOARD',
|
||||
section: 'COMMAND_BAR.SECTIONS.GENERAL',
|
||||
featureFlag: FEATURE_FLAGS.CRM,
|
||||
icon: ICON_CONTACT_DASHBOARD,
|
||||
path: accountId => `accounts/${accountId}/contacts`,
|
||||
role: ['administrator', 'agent'],
|
||||
|
@ -40,6 +41,7 @@ const GO_TO_COMMANDS = [
|
|||
id: 'open_reports_overview',
|
||||
section: 'COMMAND_BAR.SECTIONS.REPORTS',
|
||||
title: 'COMMAND_BAR.COMMANDS.GO_TO_REPORTS_OVERVIEW',
|
||||
featureFlag: FEATURE_FLAGS.REPORTS,
|
||||
icon: ICON_REPORTS_OVERVIEW,
|
||||
path: accountId => `accounts/${accountId}/reports/overview`,
|
||||
role: ['administrator'],
|
||||
|
@ -48,6 +50,7 @@ const GO_TO_COMMANDS = [
|
|||
id: 'open_conversation_reports',
|
||||
section: 'COMMAND_BAR.SECTIONS.REPORTS',
|
||||
title: 'COMMAND_BAR.COMMANDS.GO_TO_CONVERSATION_REPORTS',
|
||||
featureFlag: FEATURE_FLAGS.REPORTS,
|
||||
icon: ICON_CONVERSATION_REPORTS,
|
||||
path: accountId => `accounts/${accountId}/reports/conversation`,
|
||||
role: ['administrator'],
|
||||
|
@ -56,6 +59,7 @@ const GO_TO_COMMANDS = [
|
|||
id: 'open_agent_reports',
|
||||
section: 'COMMAND_BAR.SECTIONS.REPORTS',
|
||||
title: 'COMMAND_BAR.COMMANDS.GO_TO_AGENT_REPORTS',
|
||||
featureFlag: FEATURE_FLAGS.REPORTS,
|
||||
icon: ICON_AGENT_REPORTS,
|
||||
path: accountId => `accounts/${accountId}/reports/agent`,
|
||||
role: ['administrator'],
|
||||
|
@ -64,6 +68,7 @@ const GO_TO_COMMANDS = [
|
|||
id: 'open_label_reports',
|
||||
section: 'COMMAND_BAR.SECTIONS.REPORTS',
|
||||
title: 'COMMAND_BAR.COMMANDS.GO_TO_LABEL_REPORTS',
|
||||
featureFlag: FEATURE_FLAGS.REPORTS,
|
||||
icon: ICON_LABEL_REPORTS,
|
||||
path: accountId => `accounts/${accountId}/reports/label`,
|
||||
role: ['administrator'],
|
||||
|
@ -72,6 +77,7 @@ const GO_TO_COMMANDS = [
|
|||
id: 'open_inbox_reports',
|
||||
section: 'COMMAND_BAR.SECTIONS.REPORTS',
|
||||
title: 'COMMAND_BAR.COMMANDS.GO_TO_INBOX_REPORTS',
|
||||
featureFlag: FEATURE_FLAGS.REPORTS,
|
||||
icon: ICON_INBOX_REPORTS,
|
||||
path: accountId => `accounts/${accountId}/reports/inboxes`,
|
||||
role: ['administrator'],
|
||||
|
@ -80,6 +86,7 @@ const GO_TO_COMMANDS = [
|
|||
id: 'open_team_reports',
|
||||
section: 'COMMAND_BAR.SECTIONS.REPORTS',
|
||||
title: 'COMMAND_BAR.COMMANDS.GO_TO_TEAM_REPORTS',
|
||||
featureFlag: FEATURE_FLAGS.REPORTS,
|
||||
icon: ICON_TEAM_REPORTS,
|
||||
path: accountId => `accounts/${accountId}/reports/teams`,
|
||||
role: ['administrator'],
|
||||
|
|
|
@ -62,7 +62,10 @@
|
|||
"
|
||||
/>
|
||||
</label>
|
||||
<label :class="{ error: $v.autoResolveDuration.$error }">
|
||||
<label
|
||||
v-if="showAutoResolutionConfig"
|
||||
:class="{ error: $v.autoResolveDuration.$error }"
|
||||
>
|
||||
{{ $t('GENERAL_SETTINGS.FORM.AUTO_RESOLVE_DURATION.LABEL') }}
|
||||
<input
|
||||
v-model="autoResolveDuration"
|
||||
|
@ -120,6 +123,7 @@ import { mapGetters } from 'vuex';
|
|||
import alertMixin from 'shared/mixins/alertMixin';
|
||||
import configMixin from 'shared/mixins/configMixin';
|
||||
import accountMixin from '../../../../mixins/account';
|
||||
import { FEATURE_FLAGS } from '../../../../featureFlags';
|
||||
const semver = require('semver');
|
||||
|
||||
export default {
|
||||
|
@ -153,7 +157,15 @@ export default {
|
|||
globalConfig: 'globalConfig/get',
|
||||
getAccount: 'accounts/getAccount',
|
||||
uiFlags: 'accounts/getUIFlags',
|
||||
accountId: 'getCurrentAccountId',
|
||||
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
|
||||
}),
|
||||
showAutoResolutionConfig() {
|
||||
return this.isFeatureEnabledonAccount(
|
||||
this.accountId,
|
||||
FEATURE_FLAGS.AUTO_RESOLVE_CONVERSATIONS
|
||||
);
|
||||
},
|
||||
hasAnUpdateAvailable() {
|
||||
if (!semver.valid(this.latestChatwootVersion)) {
|
||||
return false;
|
||||
|
|
|
@ -21,7 +21,16 @@ export const getters = {
|
|||
getUIFlags($state) {
|
||||
return $state.uiFlags;
|
||||
},
|
||||
isFeatureEnabledonAccount: $state => (id, featureName) => {
|
||||
isFeatureEnabledonAccount: ($state, _, __, rootGetters) => (
|
||||
id,
|
||||
featureName
|
||||
) => {
|
||||
// If a user is SuperAdmin and has access to the account, then they would see all the available features
|
||||
const isUserASuperAdmin = rootGetters.getCurrentUser?.type === 'SuperAdmin';
|
||||
if (isUserASuperAdmin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const { features = {} } =
|
||||
$state.records.find(record => record.id === Number(id)) || {};
|
||||
return features[featureName] || false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue