|
1 | 1 | // Libraries |
2 | 2 | import React, {FC} from 'react' |
3 | | -import {useSelector} from 'react-redux' |
4 | 3 | import {Link} from 'react-router-dom' |
| 4 | +import {useSelector} from 'react-redux' |
5 | 5 |
|
6 | 6 | // Components |
7 | | -import {Tabs, Orientation, ComponentSize} from '@influxdata/clockface' |
| 7 | +import {ComponentSize, Orientation, Tabs} from '@influxdata/clockface' |
8 | 8 |
|
9 | 9 | // Utils |
10 | 10 | import {getOrg} from 'src/organizations/selectors' |
| 11 | +import {isFlagEnabled} from 'src/shared/utils/featureFlag' |
11 | 12 |
|
12 | 13 | interface Props { |
13 | 14 | activeTab: string |
14 | 15 | } |
15 | 16 |
|
16 | 17 | interface AccountPageTab { |
17 | | - text: string |
18 | 18 | id: string |
| 19 | + enabled: boolean |
19 | 20 | link: string |
20 | 21 | testID: string |
21 | | -} |
22 | | - |
23 | | -enum Tab { |
24 | | - Billing = 'billing', |
25 | | - About = 'about', |
| 22 | + text: string |
26 | 23 | } |
27 | 24 |
|
28 | 25 | const AccountTabs: FC<Props> = ({activeTab}) => { |
29 | 26 | const orgID = useSelector(getOrg)?.id |
30 | 27 |
|
31 | 28 | const tabs: AccountPageTab[] = [ |
32 | 29 | { |
33 | | - text: 'Settings', |
34 | | - id: Tab.About, |
35 | | - testID: 'accounts-setting-tab', |
| 30 | + id: 'settings', |
36 | 31 | link: `/orgs/${orgID}/accounts/settings`, |
| 32 | + enabled: true, |
| 33 | + testID: 'accounts-setting-tab', |
| 34 | + text: 'Settings', |
37 | 35 | }, |
38 | 36 | { |
39 | | - text: 'Billing', |
40 | | - id: Tab.Billing, |
41 | | - testID: 'accounts-billing-tab', |
| 37 | + id: 'organizations', |
| 38 | + enabled: isFlagEnabled('createDeleteOrgs'), |
| 39 | + link: `/orgs/${orgID}/accounts/orglist`, |
| 40 | + testID: 'accounts-orglist-tab', |
| 41 | + text: 'Organizations', |
| 42 | + }, |
| 43 | + { |
| 44 | + id: 'billing', |
| 45 | + enabled: true, |
42 | 46 | link: `/orgs/${orgID}/billing`, |
| 47 | + testID: 'accounts-billing-tab', |
| 48 | + text: 'Billing', |
43 | 49 | }, |
44 | 50 | ] |
45 | 51 |
|
46 | 52 | return ( |
47 | 53 | <Tabs orientation={Orientation.Horizontal} size={ComponentSize.Large}> |
48 | | - {tabs.map(tabInfo => { |
49 | | - const isActive = tabInfo.id === activeTab |
| 54 | + {tabs |
| 55 | + .filter(tab => tab.enabled) |
| 56 | + .map(tab => { |
| 57 | + const isActive = tab.id === activeTab |
50 | 58 |
|
51 | | - return ( |
52 | | - <Tabs.Tab |
53 | | - key={tabInfo.id} |
54 | | - text={tabInfo.text} |
55 | | - id={tabInfo.id} |
56 | | - linkElement={className => ( |
57 | | - <Link to={tabInfo.link} className={className} /> |
58 | | - )} |
59 | | - testID={tabInfo.testID} |
60 | | - active={isActive} |
61 | | - /> |
62 | | - ) |
63 | | - })} |
| 59 | + return ( |
| 60 | + <Tabs.Tab |
| 61 | + key={tab.id} |
| 62 | + text={tab.text} |
| 63 | + id={tab.id} |
| 64 | + linkElement={className => ( |
| 65 | + <Link to={tab.link} className={className} /> |
| 66 | + )} |
| 67 | + testID={tab.testID} |
| 68 | + active={isActive} |
| 69 | + /> |
| 70 | + ) |
| 71 | + })} |
64 | 72 | </Tabs> |
65 | 73 | ) |
66 | 74 | } |
|
0 commit comments