Skip to content

Commit f176d51

Browse files
sandrodw3brianchandotcom
authored andcommitted
LPD-91502 Render tabs if FF is enabled
1 parent dee77c3 commit f176d51

2 files changed

Lines changed: 106 additions & 21 deletions

File tree

modules/apps/site/site-cms-site-initializer/src/main/resources/META-INF/resources/js/main_view/dashboard/Dashboards.tsx

Lines changed: 96 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,37 @@
44
*/
55

66
import ClayLayout from '@clayui/layout';
7+
import ClayLink from '@clayui/link';
8+
import ClayNavigationBar from '@clayui/navigation-bar';
79
import {ClayTooltipProvider} from '@clayui/tooltip';
8-
import React from 'react';
10+
import React, {useState} from 'react';
911

1012
import Breadcrumb from '../../common/components/Breadcrumb';
1113
import InventoryDashboard from './inventory/InventoryDashboard';
14+
import PerformanceDashboard from './performance/PerformanceDashboard';
1215

1316
import '../../../css/dashboard/Dashboard.scss';
1417

1518
import {ILearnResourceContext} from 'frontend-js-components-web';
1619

1720
import EnterpriseOnlyPlaceholder from '../../common/components/EnterpriseOnlyPlaceholder';
1821

19-
interface IDashboards {
20-
constants: {
21-
[key: string]: string;
22-
};
23-
freeTier: boolean;
24-
learnResources: ILearnResourceContext;
25-
}
22+
const TABS = {
23+
inventory: Liferay.Language.get('inventory'),
24+
performance: Liferay.Language.get('performance'),
25+
} as const;
26+
27+
type TabId = keyof typeof TABS;
2628

27-
const Dashboards: React.FC<IDashboards> = ({
29+
function Wrapper({
2830
constants,
2931
freeTier,
3032
learnResources,
31-
}) => {
33+
}: {
34+
constants: {[key: string]: string};
35+
freeTier: boolean;
36+
learnResources: ILearnResourceContext;
37+
}) {
3238
return (
3339
<>
3440
<Breadcrumb
@@ -38,18 +44,87 @@ const Dashboards: React.FC<IDashboards> = ({
3844
/>
3945

4046
<ClayTooltipProvider>
41-
<ClayLayout.Container className="px-4" fluid>
42-
{freeTier ? (
43-
<EnterpriseOnlyPlaceholder
44-
learnResources={learnResources}
45-
/>
46-
) : (
47-
<InventoryDashboard constants={constants} />
48-
)}
49-
</ClayLayout.Container>
47+
<Dashboards
48+
constants={constants}
49+
freeTier={freeTier}
50+
learnResources={learnResources}
51+
/>
5052
</ClayTooltipProvider>
5153
</>
5254
);
53-
};
55+
}
56+
57+
function Dashboards({
58+
constants,
59+
freeTier,
60+
learnResources,
61+
}: {
62+
constants: {[key: string]: string};
63+
freeTier: boolean;
64+
learnResources: ILearnResourceContext;
65+
}) {
66+
const [tabId, setTabId] = useState<TabId>('inventory');
67+
68+
if (freeTier) {
69+
return (
70+
<ClayLayout.Container className="px-4" fluid>
71+
<EnterpriseOnlyPlaceholder learnResources={learnResources} />
72+
</ClayLayout.Container>
73+
);
74+
}
75+
76+
if (!Liferay.FeatureFlags['LPD-58315']) {
77+
return (
78+
<ClayLayout.Container className="px-4" fluid>
79+
<InventoryDashboard constants={constants} />
80+
</ClayLayout.Container>
81+
);
82+
}
83+
84+
return (
85+
<>
86+
<Tabs setTabId={setTabId} tabId={tabId} />
87+
88+
<ClayLayout.Container className="px-4" fluid>
89+
{tabId === 'inventory' ? (
90+
<InventoryDashboard constants={constants} />
91+
) : null}
92+
93+
{tabId === 'performance' ? <PerformanceDashboard /> : null}
94+
</ClayLayout.Container>
95+
</>
96+
);
97+
}
98+
99+
function Tabs({
100+
setTabId,
101+
tabId,
102+
}: {
103+
setTabId: (id: TabId) => void;
104+
tabId: TabId;
105+
}) {
106+
return (
107+
<ClayNavigationBar
108+
className="mb-4"
109+
fluidSize={false}
110+
triggerLabel={TABS[tabId]}
111+
>
112+
{(Object.keys(TABS) as TabId[]).map((id) => (
113+
<ClayNavigationBar.Item active={id === tabId} key={id}>
114+
<ClayLink
115+
onClick={(event) => {
116+
event.preventDefault();
117+
118+
setTabId(id);
119+
}}
120+
role="tab"
121+
>
122+
{TABS[id]}
123+
</ClayLink>
124+
</ClayNavigationBar.Item>
125+
))}
126+
</ClayNavigationBar>
127+
);
128+
}
54129

55-
export default Dashboards;
130+
export default Wrapper;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* SPDX-FileCopyrightText: (c) 2025 Liferay, Inc. https://liferay.com
3+
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
4+
*/
5+
6+
import React from 'react';
7+
8+
export default function PerformanceDashboard() {
9+
return <div />;
10+
}

0 commit comments

Comments
 (0)