-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(dashboards): 🎉 update main and org-dashboard data logic
- Loading branch information
1 parent
c90165c
commit 1227636
Showing
11 changed files
with
699 additions
and
493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import { Fragment, useMemo } from "react"; | ||
import useMain from "../hooks/useMain"; | ||
import InfoCell from "../components/TableInformationCells/InfoCell"; | ||
import { handleSplitOrganizationName } from "../functions/GeneralFunctions"; | ||
import BasicCell from "../components/TableInformationCells/BasicCell"; | ||
import { envOnPremiseFleet, envOnPremiseRobot } from "../helpers/envProvider"; | ||
import StateCell from "../components/TableInformationCells/StateCell"; | ||
import NamespaceActionCells from "../components/TableActionCells/NamespaceActionCells"; | ||
import FleetActionCells from "../components/TableActionCells/FleetActionCells"; | ||
|
||
interface IInstanceTableData { | ||
responseFleets: any; | ||
setReload: any; | ||
} | ||
|
||
export function InstanceTableData({ | ||
responseFleets, | ||
setReload, | ||
}: IInstanceTableData) { | ||
const { pagesState } = useMain(); | ||
|
||
const data: any = useMemo( | ||
() => | ||
responseFleets?.map((fleet: any) => { | ||
return { | ||
key: fleet?.name, | ||
name: fleet, | ||
organization: pagesState?.organization?.organizationName, | ||
roboticsCloud: pagesState?.roboticsCloud?.name, | ||
instance: pagesState?.instance?.name, | ||
state: fleet?.fleetStatus || fleet?.namespaceStatus, | ||
actions: fleet, | ||
}; | ||
}), | ||
[pagesState, responseFleets], | ||
); | ||
|
||
const columns: any = useMemo( | ||
() => [ | ||
{ | ||
key: "name", | ||
header: "Name", | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return ( | ||
<InfoCell | ||
title={rowData?.name?.name} | ||
subtitle={pagesState.organization?.organizationName!} | ||
titleURL={`/${handleSplitOrganizationName( | ||
pagesState?.organization?.organizationName!, | ||
)}/${pagesState?.roboticsCloud?.name}/${pagesState?.instance | ||
?.name}/${rowData?.name?.name}`} | ||
/> | ||
); | ||
}, | ||
}, | ||
{ | ||
key: "organization", | ||
header: "Organization", | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: () => { | ||
return ( | ||
<BasicCell text={pagesState?.organization?.organizationName!} /> | ||
); | ||
}, | ||
}, | ||
{ | ||
key: "roboticsCloud", | ||
header: "Robotics Cloud", | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return <BasicCell text={rowData?.roboticsCloud} />; | ||
}, | ||
}, | ||
{ | ||
key: "instance", | ||
header: "Cloud Instance", | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return <BasicCell text={rowData?.instance} />; | ||
}, | ||
}, | ||
{ | ||
key: "state", | ||
header: `${envOnPremiseRobot ? "Namespace" : "Fleet"} State`, | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return <StateCell state={rowData?.state} />; | ||
}, | ||
}, | ||
{ | ||
key: "actions", | ||
header: "Actions", | ||
align: "right", | ||
body: (rowData: any) => { | ||
return ( | ||
<Fragment> | ||
{envOnPremiseFleet ? ( | ||
<NamespaceActionCells | ||
reload={() => setReload((prevState: boolean) => !prevState)} | ||
data={{ | ||
organization: pagesState?.organization, | ||
roboticsCloud: pagesState?.roboticsCloud?.name, | ||
instance: pagesState?.instance, | ||
fleet: rowData?.actions, | ||
}} | ||
/> | ||
) : ( | ||
<FleetActionCells | ||
reload={() => setReload((prevState: boolean) => !prevState)} | ||
data={{ | ||
organization: pagesState?.organization, | ||
roboticsCloud: pagesState?.roboticsCloud?.name, | ||
instance: pagesState?.instance, | ||
fleet: rowData?.actions, | ||
}} | ||
/> | ||
)} | ||
</Fragment> | ||
); | ||
}, | ||
}, | ||
], | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[], | ||
); | ||
|
||
return { data, columns }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Dispatch, SetStateAction, useMemo } from "react"; | ||
import { | ||
IMainDashboardColumn, | ||
IMainDashboardData, | ||
} from "../interfaces/tableInterface"; | ||
import { IOrganization } from "../interfaces/organizationInterfaces"; | ||
import OrganizationInfoCell from "../components/OrganizationInfoCell/OrganizationInfoCell"; | ||
import StateCell from "../components/TableInformationCells/StateCell"; | ||
import OrganizationActionCells from "../components/TableActionCells/OrganizationActionCells"; | ||
|
||
interface IMainTableData { | ||
responseOrganizations: IOrganization[] | undefined; | ||
setReload: Dispatch<SetStateAction<boolean>>; | ||
} | ||
|
||
export function MainTableData({ | ||
responseOrganizations, | ||
setReload, | ||
}: IMainTableData) { | ||
const data: IMainDashboardData[] = useMemo( | ||
() => | ||
responseOrganizations?.map((organization: IOrganization) => { | ||
return { | ||
key: organization?.organizationName, | ||
name: organization, | ||
state: undefined, | ||
actions: organization, | ||
}; | ||
}) || [], | ||
[responseOrganizations], | ||
); | ||
|
||
const columns: IMainDashboardColumn[] = useMemo( | ||
() => [ | ||
{ | ||
key: "name", | ||
header: "Name", | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: IMainDashboardData) => { | ||
return <OrganizationInfoCell rowData={rowData} />; | ||
}, | ||
}, | ||
{ | ||
key: "state", | ||
header: "State", | ||
align: "left", | ||
body: () => { | ||
return <StateCell state="Ready" />; | ||
}, | ||
}, | ||
{ | ||
key: "actions", | ||
header: "Actions", | ||
align: "right", | ||
body: (rowData: IMainDashboardData) => { | ||
return ( | ||
<OrganizationActionCells | ||
data={rowData?.actions} | ||
reload={() => setReload((prevState: boolean) => !prevState)} | ||
/> | ||
); | ||
}, | ||
}, | ||
], | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[], | ||
); | ||
|
||
return { data, columns }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
import { useMemo } from "react"; | ||
import useMain from "../hooks/useMain"; | ||
import InfoCell from "../components/TableInformationCells/InfoCell"; | ||
import BasicCell from "../components/TableInformationCells/BasicCell"; | ||
import { envOnPremiseRobot } from "../helpers/envProvider"; | ||
import RobotServicesCell from "../components/TableInformationCells/RobotServicesCell"; | ||
import StateCell from "../components/TableInformationCells/StateCell"; | ||
import EnvironmentActionCells from "../components/TableActionCells/EnvironmentActionCells"; | ||
import RobotActionCells from "../components/TableActionCells/RobotActionCells"; | ||
import { handleSplitOrganizationName } from "../functions/GeneralFunctions"; | ||
|
||
interface INamespaceTableData { | ||
responseRobots: any; | ||
setReload: any; | ||
} | ||
|
||
export function NamespaceTableData({ | ||
responseRobots, | ||
setReload, | ||
}: INamespaceTableData) { | ||
const { pagesState } = useMain(); | ||
|
||
const data: any = useMemo( | ||
() => | ||
responseRobots?.map((robot: any) => { | ||
return { | ||
key: robot?.name, | ||
name: robot, | ||
organization: handleSplitOrganizationName( | ||
pagesState?.organization?.organizationName!, | ||
), | ||
roboticsCloud: pagesState?.roboticsCloud?.name!, | ||
instance: pagesState?.instance?.name!, | ||
fleet: pagesState?.fleet?.name!, | ||
virtualState: robot?.robotClusters?.[0]?.robotStatus || undefined, | ||
physicalState: robot?.robotClusters?.[1]?.robotStatus || undefined, | ||
robotServices: { | ||
isEnabledRosBridge: robot?.bridgeEnabled, | ||
isEnabledIDE: robot?.ideEnabled, | ||
isEnabledVDI: robot?.vdiEnabled, | ||
}, | ||
actions: { | ||
organizationId: pagesState.organization?.organizationId!, | ||
roboticsCloudName: pagesState.roboticsCloud?.name!, | ||
instanceId: pagesState.instance?.instanceId!, | ||
region: pagesState.instance?.region!, | ||
fleetName: pagesState.fleet?.name!, | ||
robotName: robot?.name, | ||
virtualState: robot?.robotClusters?.[0] || undefined, | ||
physicalState: robot?.robotClusters?.[1] || undefined, | ||
}, | ||
}; | ||
}), | ||
[responseRobots, pagesState], | ||
); | ||
|
||
const columns: any = useMemo( | ||
() => [ | ||
{ | ||
key: "name", | ||
header: "Name", | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return ( | ||
<InfoCell | ||
title={rowData?.name?.name} | ||
subtitle={rowData?.name?.fleetName} | ||
titleURL={`/${handleSplitOrganizationName( | ||
pagesState?.organization?.organizationName!, | ||
)}/${pagesState.roboticsCloud?.name}/${pagesState.instance | ||
?.name}/${pagesState.fleet?.name}/${rowData?.name?.name}`} | ||
/> | ||
); | ||
}, | ||
}, | ||
{ | ||
key: "organization", | ||
header: "Organization", | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return <BasicCell text={rowData?.organization} />; | ||
}, | ||
}, | ||
{ | ||
key: "roboticsCloud", | ||
header: "Robotics Cloud", | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return <BasicCell text={rowData?.roboticsCloud} />; | ||
}, | ||
}, | ||
{ | ||
key: "instance", | ||
header: "Cloud Instance", | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return <BasicCell text={rowData?.instance} />; | ||
}, | ||
}, | ||
{ | ||
key: "fleet", | ||
header: envOnPremiseRobot ? "Namespace" : "Fleet", | ||
sortable: false, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return <BasicCell text={rowData?.fleet} />; | ||
}, | ||
}, | ||
!envOnPremiseRobot && { | ||
key: "robotServices", | ||
header: `${envOnPremiseRobot ? "Application" : "Robot"} Services`, | ||
sortable: true, | ||
filter: true, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return ( | ||
<RobotServicesCell | ||
data={undefined} | ||
states={rowData.robotServices} | ||
/> | ||
); | ||
}, | ||
}, | ||
{ | ||
key: "virtualState", | ||
header: `Virtual ${envOnPremiseRobot ? "Application" : "Robot"} State`, | ||
sortable: true, | ||
filter: false, | ||
align: "left", | ||
body: (rowData: any) => { | ||
return <StateCell state={rowData?.virtualState} />; | ||
}, | ||
}, | ||
!envOnPremiseRobot && { | ||
key: "physicalState", | ||
header: `Physical ${envOnPremiseRobot ? "Application" : "Robot"} State`, | ||
sortable: true, | ||
filter: true, | ||
align: "left", | ||
body: (rowData: any) => { | ||
if (!rowData?.physicalState) { | ||
return <BasicCell text="None" />; | ||
} | ||
return <StateCell state={rowData?.physicalState} />; | ||
}, | ||
}, | ||
{ | ||
key: "actions", | ||
header: "Actions", | ||
align: "right", | ||
body: (rowData: any) => { | ||
return envOnPremiseRobot ? ( | ||
<EnvironmentActionCells | ||
data={rowData?.actions} | ||
reload={() => setReload((prevState: boolean) => !prevState)} | ||
/> | ||
) : ( | ||
<RobotActionCells | ||
data={rowData?.actions} | ||
reload={() => setReload((prevState: boolean) => !prevState)} | ||
/> | ||
); | ||
}, | ||
}, | ||
], | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[], | ||
); | ||
|
||
return { | ||
data, | ||
columns, | ||
}; | ||
} |
Oops, something went wrong.