Skip to content

Commit 3b034bb

Browse files
committed
feat: EnvironmentOverview - integrate ManageTraffic, code optimizations
1 parent 664dbe9 commit 3b034bb

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

src/Pages/Shared/EnvironmentOverviewTable/EnvironmentOverviewBulkSelectionActionWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const EnvironmentOverviewBulkSelectionWidget = ({
5252
</div>
5353
<div className="w-1 h-20 bcb-1" />
5454
{children}
55-
<EnvironmentOverviewPopupMenu popUpMenuItems={popUpMenuItems} />
55+
{popUpMenuItems.length > 0 && <EnvironmentOverviewPopupMenu popUpMenuItems={popUpMenuItems} />}
5656
<div className="w-1 h-20 bcb-1" />
5757
<Button
5858
icon={<Icon name="ic-close-large" color={null} />}

src/Pages/Shared/EnvironmentOverviewTable/EnvironmentOverviewTable.component.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ export const EnvironmentOverviewTable = ({
6969
() =>
7070
rows.sort((a, b) => {
7171
if (sortBy === EnvironmentOverviewTableSortableKeys.DEPLOYED_AT) {
72-
return handleRelativeDateSorting(a.environment.deployedAt, b.environment.deployedAt, sortOrder)
72+
return handleRelativeDateSorting(a.app.deployedAt, b.app.deployedAt, sortOrder)
7373
}
7474

75-
return stringComparatorBySortOrder(a.environment.name, b.environment.name, sortOrder)
75+
return stringComparatorBySortOrder(a.app.name, b.app.name, sortOrder)
7676
}),
7777
[rows, sortBy, sortOrder],
7878
)
@@ -163,15 +163,15 @@ export const EnvironmentOverviewTable = ({
163163
)
164164

165165
const renderRow = ({
166-
environment,
166+
app,
167167
isChecked,
168168
deployedAtLink,
169169
redirectLink,
170170
onCommitClick,
171171
onLastDeployedImageClick,
172172
popUpMenuItems = [],
173173
}: EnvironmentOverviewTableProps['rows'][0]) => {
174-
const { id, name, status, commits, deployedAt, deployedBy, deploymentStatus, lastDeployedImage } = environment
174+
const { id, name, status, commits, deployedAt, deployedBy, deploymentStatus, lastDeployedImage } = app
175175

176176
return (
177177
<div className={`environment-overview-table__row ${isChecked ? isCheckedRowClassName : ''}`}>
@@ -244,7 +244,7 @@ export const EnvironmentOverviewTable = ({
244244
<div className="environment-overview-table dc__border br-4 bg__primary w-100">
245245
{renderHeaderRow()}
246246
{sortedRows.map((row) => (
247-
<Fragment key={row.environment.id}>{renderRow(row)}</Fragment>
247+
<Fragment key={row.app.id}>{renderRow(row)}</Fragment>
248248
))}
249249
</div>
250250
)

src/Pages/Shared/EnvironmentOverviewTable/EnvironmentOverviewTable.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type EnvironmentOverviewTablePopUpMenuItem =
4141
| ReactElement
4242

4343
export interface EnvironmentOverviewTableRow {
44-
environment: EnvironmentOverviewTableRowData
44+
app: EnvironmentOverviewTableRowData
4545
isChecked?: boolean
4646
onLastDeployedImageClick: (event: MouseEvent<HTMLButtonElement>) => void
4747
onCommitClick: (event: MouseEvent<HTMLButtonElement>) => void

src/components/ApplicationGroup/Details/EnvironmentOverview/EnvironmentOverview.tsx

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,15 @@ const processDeploymentWindowAppGroupOverviewMap = importComponentFromFELibrary(
7474
null,
7575
'function',
7676
)
77-
// TODO: remove from fe-lib
78-
// const ClonePipelineButton = importComponentFromFELibrary('ClonePipelineButton', null, 'function')
77+
const AppGroupManageTrafficDrawer = importComponentFromFELibrary('AppGroupManageTrafficDrawer', null, 'function')
78+
const ManageTrafficButton = importComponentFromFELibrary('ManageTrafficButton', null, 'function')
7979
const ClonePipelineMenuButton = importComponentFromFELibrary('ClonePipelineMenuButton', null, 'function')
8080
const ClonePipelineModal = importComponentFromFELibrary('ClonePipelineModal', null, 'function')
81+
const getManageTrafficMenuButtonConfig = importComponentFromFELibrary(
82+
'getManageTrafficMenuButtonConfig',
83+
null,
84+
'function',
85+
)
8186

8287
const EnvironmentOverview = ({
8388
appGroupListData,
@@ -111,6 +116,7 @@ const EnvironmentOverview = ({
111116
Record<string, { type: string; excludedUserEmails: string[]; userActionState: ACTION_STATE; isActive: boolean }>
112117
>({})
113118
const [restartLoader, setRestartLoader] = useState<boolean>(false)
119+
const [isManageTrafficDrawerOpen, setIsManageTrafficDrawerOpen] = useState(false)
114120

115121
// HOOKS
116122
const { envId } = useParams<{ envId: string }>()
@@ -285,10 +291,14 @@ const EnvironmentOverview = ({
285291

286292
const handleBulkSelectionWidgetClose = () => setSelectedAppDetailsList([])
287293

294+
const handleOpenManageTrafficDrawer = () => setIsManageTrafficDrawerOpen(true)
295+
296+
const handleCloseManageTrafficDrawer = () => setIsManageTrafficDrawerOpen(false)
297+
288298
// CONFIGS
289299
const environmentOverviewTableRows = (appListData?.appInfoList ?? []).map<EnvironmentOverviewTableRow>(
290300
(appInfo) => ({
291-
environment: {
301+
app: {
292302
id: appInfo.appId,
293303
name: appInfo.application,
294304
commits: appInfo.commits,
@@ -502,13 +512,7 @@ const EnvironmentOverview = ({
502512
<span className="flex">
503513
<GridIcon className="icon-dim-20 mr-8 scn-9" /> {GROUP_LIST_HEADER.APPLICATIONS}
504514
</span>
505-
<Button
506-
dataTestId="environment-overview-table-manage-traffic"
507-
startIcon={<Icon name="ic-traffic-signal" color={null} />}
508-
variant={ButtonVariantType.secondary}
509-
size={ComponentSizeType.medium}
510-
text="Manage Traffic"
511-
/>
515+
{ManageTrafficButton && <ManageTrafficButton onClick={handleOpenManageTrafficDrawer} />}
512516
</div>
513517
<EnvironmentOverviewTable
514518
rows={environmentOverviewTableRows}
@@ -519,19 +523,26 @@ const EnvironmentOverview = ({
519523
{/* MODALS */}
520524
{renderOverviewModal()}
521525

526+
{AppGroupManageTrafficDrawer && isManageTrafficDrawerOpen && (
527+
<AppGroupManageTrafficDrawer
528+
envId={+envId}
529+
envName={appListData.environment}
530+
appInfoList={appListData?.appInfoList}
531+
initialSelectedAppList={selectedAppDetailsList}
532+
onClose={handleCloseManageTrafficDrawer}
533+
/>
534+
)}
535+
522536
{/* BULK SELECTION WIDGET */}
523537
{!!selectedAppDetailsList.length && (
524538
<EnvironmentOverviewBulkSelectionWidget
525539
parentRef={parentRef}
526540
count={selectedAppDetailsList.length}
527541
onClose={handleBulkSelectionWidgetClose}
528542
popUpMenuItems={[
529-
{
530-
label: 'Manage Traffic',
531-
iconName: 'ic-traffic-signal',
532-
// TODO: open manage traffic drawer here
533-
onClick: () => {},
534-
},
543+
...(getManageTrafficMenuButtonConfig
544+
? [getManageTrafficMenuButtonConfig({ onClick: handleOpenManageTrafficDrawer })]
545+
: []),
535546
...(ClonePipelineMenuButton && appListData.environment
536547
? [
537548
<ClonePipelineMenuButton

0 commit comments

Comments
 (0)