Skip to content

Commit

Permalink
[EASI-4469] add Open Requests on home page table (#2752)
Browse files Browse the repository at this point in the history
* clean branch

* naming - typo

* allow sort on col

* remove test code

* remove unneeded Cell prop
  • Loading branch information
samoddball committed Aug 8, 2024
1 parent fe5edd0 commit fba612b
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 59 deletions.
1 change: 1 addition & 0 deletions src/i18n/en-US/systemProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ const systemProfile = {
id: 'system-list',
search: 'Search table',
header: {
openRequests: 'Open EASi requests',
systemName: 'System name',
systemOwner: 'CMS component',
systemAcronym: 'Acronym',
Expand Down
6 changes: 6 additions & 0 deletions src/queries/GetCedarSystemsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export default gql`
systemMaintainerOrgComp
isBookmarked
atoExpirationDate
linkedTrbRequests(state: OPEN) {
id
}
linkedSystemIntakes(state: OPEN) {
id
}
}
}
`;
6 changes: 6 additions & 0 deletions src/queries/GetMyCedarSystemsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export default gql`
systemMaintainerOrgComp
isBookmarked
atoExpirationDate
linkedSystemIntakes(state: OPEN) {
id
}
linkedTrbRequests(state: OPEN) {
id
}
}
}
`;
12 changes: 12 additions & 0 deletions src/queries/types/GetCedarSystems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
// GraphQL query operation: GetCedarSystems
// ====================================================

export interface GetCedarSystems_cedarSystems_linkedTrbRequests {
__typename: "TRBRequest";
id: UUID;
}

export interface GetCedarSystems_cedarSystems_linkedSystemIntakes {
__typename: "SystemIntake";
id: UUID;
}

export interface GetCedarSystems_cedarSystems {
__typename: "CedarSystem";
id: string;
Expand All @@ -20,6 +30,8 @@ export interface GetCedarSystems_cedarSystems {
systemMaintainerOrgComp: string | null;
isBookmarked: boolean;
atoExpirationDate: Time | null;
linkedTrbRequests: GetCedarSystems_cedarSystems_linkedTrbRequests[];
linkedSystemIntakes: GetCedarSystems_cedarSystems_linkedSystemIntakes[];
}

export interface GetCedarSystems {
Expand Down
12 changes: 12 additions & 0 deletions src/queries/types/GetMyCedarSystems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
// GraphQL query operation: GetMyCedarSystems
// ====================================================

export interface GetMyCedarSystems_myCedarSystems_linkedSystemIntakes {
__typename: "SystemIntake";
id: UUID;
}

export interface GetMyCedarSystems_myCedarSystems_linkedTrbRequests {
__typename: "TRBRequest";
id: UUID;
}

export interface GetMyCedarSystems_myCedarSystems {
__typename: "CedarSystem";
id: string;
Expand All @@ -20,6 +30,8 @@ export interface GetMyCedarSystems_myCedarSystems {
systemMaintainerOrgComp: string | null;
isBookmarked: boolean;
atoExpirationDate: Time | null;
linkedSystemIntakes: GetMyCedarSystems_myCedarSystems_linkedSystemIntakes[];
linkedTrbRequests: GetMyCedarSystems_myCedarSystems_linkedTrbRequests[];
}

export interface GetMyCedarSystems {
Expand Down
6 changes: 1 addition & 5 deletions src/views/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ const Home = () => {
</p>

{/* TODO: figure out why need to pass empty params here when they are optional with defaults */}
<SystemsListTable
systems={[]}
isMySystems
defaultPageSize={5}
/>
<SystemsListTable systems={[]} isHomePage defaultPageSize={5} />
</Grid>

<hr className="margin-bottom-3 margin-top-4" aria-hidden />
Expand Down
55 changes: 24 additions & 31 deletions src/views/SystemList/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ export type SystemTableType =
type TableProps = {
systems?: CedarSystem[];
defaultPageSize?: number;
isMySystems?: boolean;
isHomePage?: boolean;
};

export const Table = ({
systems = [],
defaultPageSize = 10,
isMySystems
isHomePage
}: TableProps) => {
const { t } = useTranslation('systemProfile');

Expand All @@ -92,14 +92,14 @@ export const Table = ({
// Sets the systemTableType state to the query param, defaults to all-systems if no param present
// If the query param changes, update the component state
useEffect(() => {
if (!tableType && !isMySystems) {
if (!tableType && !isHomePage) {
history.replace({
search: 'table-type=all-systems'
});
}

setSystemTableType(isMySystems ? 'my-systems' : tableType);
}, [tableType, isMySystems, history]);
setSystemTableType(isHomePage ? 'my-systems' : tableType);
}, [tableType, isHomePage, history]);

// On button group toggle, change query param
const switchTableType = (type: SystemTableType) => {
Expand Down Expand Up @@ -147,7 +147,7 @@ export const Table = ({

const cols: Column<CedarSystem>[] = [];

if (!isMySystems) {
if (!isHomePage) {
cols.push({
Header: <IconBookmark />,
accessor: 'id',
Expand Down Expand Up @@ -190,7 +190,7 @@ export const Table = ({
}
});

if (!isMySystems) {
if (!isHomePage) {
cols.push({
Header: t<string>('systemTable.header.systemOwner'),
accessor: 'businessOwnerOrg',
Expand Down Expand Up @@ -219,27 +219,20 @@ export const Table = ({
: -1
});

/*
{
Header: t<string>('systemTable.header.systemStatus'),
accessor: 'status',
id: 'systemStatus',
disableGlobalFilter: true,
Cell: ({ row }: { row: Row<CedarSystem> }) => (
<div>
<SystemHealthIcon
status={mapCedarStatusToIcon(row.original.status)}
size="medium"
className="margin-right-1"
/>
<span>{row.original.status}</span>
</div>
)
if (isHomePage) {
cols.push({
Header: t<string>('systemTable.header.openRequests'),
accessor: (system: CedarSystem) => {
return (
system.linkedTrbRequests.length + system.linkedSystemIntakes.length
);
},
id: 'openRequests'
});
}
*/

return cols;
}, [t, systems, systemTableType, createMutate, deleteMutate, isMySystems]);
}, [t, systems, systemTableType, createMutate, deleteMutate, isHomePage]);

const {
getTableProps,
Expand Down Expand Up @@ -291,7 +284,7 @@ export const Table = ({
rows.map(row => prepareRow(row));

if (
(isMySystems || tableType === 'my-systems') &&
(isHomePage || tableType === 'my-systems') &&
loading &&
!mySystems?.myCedarSystems
) {
Expand All @@ -300,7 +293,7 @@ export const Table = ({

return (
<div className="margin-bottom-6">
{!isMySystems && (
{!isHomePage && (
<>
<p className="text-bold margin-0 margin-top-3">
{t('systemTable.view')}
Expand Down Expand Up @@ -437,13 +430,13 @@ export const Table = ({

{/* Alerts to show if there is no system/data */}
{filteredSystems.length === 0 &&
(tableType === 'my-systems' || isMySystems) && (
(tableType === 'my-systems' || isHomePage) && (
<Alert
type="info"
heading={t('systemTable.noMySystem.header')}
className="margin-top-5"
>
{isMySystems ? (
{isHomePage ? (
<Trans
i18nKey="systemProfile:systemTable.noMySystem.description"
components={{
Expand All @@ -469,8 +462,8 @@ export const Table = ({
</Alert>
)}

{/* Alery to show to direct to Systems tab when viewing My sytems */}
{filteredSystems.length > 0 && isMySystems && (
{/* Alert to show to direct to Systems tab when viewing My sytems */}
{filteredSystems.length > 0 && isHomePage && (
<Alert
type="info"
heading={t('systemProfile:systemTable:dontSeeSystem.header')}
Expand Down
35 changes: 12 additions & 23 deletions src/views/SystemProfile/mockSystemData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ export const mockSystemInfo: CedarSystemProps[] = [
feugiat laoreet quis. Sapien, sagittis, consectetur adipiscing elit.
Sollicitudin donec aliquam dui sed odio porta.`,
isBookmarked: false,
atoExpirationDate: null
atoExpirationDate: null,
linkedTrbRequests: [],
linkedSystemIntakes: []
},
{
__typename: 'CedarSystem',
Expand All @@ -153,7 +155,9 @@ export const mockSystemInfo: CedarSystemProps[] = [
feugiat laoreet quis. Sapien, sagittis, consectetur adipiscing elit.
Sollicitudin donec aliquam dui sed odio porta.`,
isBookmarked: false,
atoExpirationDate: null
atoExpirationDate: null,
linkedTrbRequests: [],
linkedSystemIntakes: []
},
{
__typename: 'CedarSystem',
Expand All @@ -173,7 +177,9 @@ export const mockSystemInfo: CedarSystemProps[] = [
feugiat laoreet quis. Sapien, sagittis, consectetur adipiscing elit.
Sollicitudin donec aliquam dui sed odio porta.`,
isBookmarked: false,
atoExpirationDate: null
atoExpirationDate: null,
linkedTrbRequests: [],
linkedSystemIntakes: []
},
{
__typename: 'CedarSystem',
Expand All @@ -194,26 +200,9 @@ export const mockSystemInfo: CedarSystemProps[] = [
feugiat laoreet quis. Sapien, sagittis, consectetur adipiscing elit.
Sollicitudin donec aliquam dui sed odio porta.`,
isBookmarked: false,
atoExpirationDate: null
}
];

export const products: tempProductsProp[] = [
{
id: '1',
name: 'Drupal',
manufacturer: 'Drupal Association',
type: 'Enterprise Content Management (ECM)',
version: '9.3',
edition: 'Enterprise'
},
{
id: '2',
name: 'Kong',
manufacturer: 'Kong Enterprise',
type: 'Software Development',
tags: ['API Gateway'],
version: '2.1'
atoExpirationDate: null,
linkedTrbRequests: [],
linkedSystemIntakes: []
}
];

Expand Down

0 comments on commit fba612b

Please sign in to comment.