Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage data policy list view #892

Conversation

GowthamShanmugam
Copy link
Contributor

@GowthamShanmugam GowthamShanmugam commented Jun 6, 2023

  1. Find all assigned policies to the app and display them in a list view.
  2. A dummy action is added for bulk policy un assign the policy.
  3. A dummy action is added for individual policy-wise un assign the policy.
  4. A dummy action is added for to view policy configuration info
  5. Dummy primary action button to switch the assign policy view.

@GowthamShanmugam GowthamShanmugam force-pushed the app_manage_policy branch 2 times, most recently from 19cc70b to 720c8dc Compare June 6, 2023 23:33
@GowthamShanmugam GowthamShanmugam changed the title Manage policy Manage policy - WIP Jun 6, 2023
@GowthamShanmugam
Copy link
Contributor Author

/hold

@GowthamShanmugam
Copy link
Contributor Author

Screencast.from.2023-06-07.14-09-23.webm

@GowthamShanmugam
Copy link
Contributor Author

/hold cancel

@GowthamShanmugam GowthamShanmugam changed the title Manage policy - WIP Manage data policy list view Jun 7, 2023
@GowthamShanmugam
Copy link
Contributor Author

GowthamShanmugam commented Jun 7, 2023

TODO on next PR:

Unassign policy:
Screenshot from 2023-06-07 14-31-17

Assign policy:
Screenshot from 2023-06-07 14-31-59

@@ -0,0 +1,77 @@
import * as React from 'react';
Copy link
Collaborator

@SanjalKatiyar SanjalKatiyar Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don;t think we need "/mco/components/modals/app-manage-data-policy/components/" directory within "packages/mco/components/" (components within components).

"app-manage-data-policy-modal.tsx" can just directly be inside "app-manage-data-policy".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I thought the same. But the reason I used the component folder is, I kept all hook-calling logic inside the parser folder, Becuase parsers will grow for different app types. If I keep "app-manage-data-policy-modal.tsx" outside of the component then the component call hierarchy won't be correct. call will be like:
acm-action-callback.tsx -> parser/argo-application-set-parser.tsx -> ../app-manage-data-policy-modal.tsx

This is the reason i kept one more folder.

@@ -0,0 +1,23 @@
import * as React from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name of the directory "app-manage-policies", instead of "app-manage-policy".
Since it is multi select table, meaning there can be multiple policies per app.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Comment on lines 23 to 81
const modalViewContext = () => {
switch (state.modalViewContext) {
case ModalViewContext.POLICY_LIST_VIEW:
return (
<>
<ModalHeader
title={t('Manage Policy')}
description={t(
'Assign policy to protect the application and ensure quick recovery. Unassign policy from an application when they no longer require to be managed.'
)}
/>
<ModalListView
dataPolicyInfo={applicaitonInfo?.dataPolicies}
state={state}
dispatch={dispatch}
/>
</>
);
case ModalViewContext.ASSIGN_POLICY_VIEW:
return <>ASSIGN_POLICY_VIEW</>;
case ModalViewContext.DISABLE_POLICY_VIEW:
return <>DISABLE_POLICY_VIEW</>;
default:
return <>POLICY_LIST_VIEW</>;
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a new FC in itself...

Copy link
Contributor Author

@GowthamShanmugam GowthamShanmugam Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just dont want to use && condition or any other condition on render, I thought to use the switch, that is why i created it as a function. but your are right, it should be a component

};

return (
<React.Fragment>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<React.Fragment>
<>

<StatusBox loadError={loadError} loaded={loaded} />
)}
</Modal>
</React.Fragment>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
</React.Fragment>
</>

case ModalViewContext.DISABLE_POLICY_VIEW:
return <>DISABLE_POLICY_VIEW</>;
default:
return <>POLICY_LIST_VIEW</>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be returning component corresponding to "ModalViewContext.POLICY_LIST_VIEW", instead of plain text ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its just dummy text, upcoming PR will replace this with proper component

import { Text } from '@patternfly/react-core';
import { ActionsColumn, IAction } from '@patternfly/react-table';
import { Td } from '@patternfly/react-table';
import { formatDateTimeWithZone } from '../../../../../utils';
Copy link
Collaborator

@SanjalKatiyar SanjalKatiyar Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from '@odf/mco/...'

} from '../utils/reducer';
import { DataPolicyType } from '../utils/types';

const getRow = (dataPolicyInfo: DataPolicyType[], searchText: string) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const getRow = (dataPolicyInfo: DataPolicyType[], searchText: string) => {
const getRows = (dataPolicyInfo: DataPolicyType[], searchText: string) => {

Comment on lines 26 to 37
const getRow = (dataPolicyInfo: DataPolicyType[], searchText: string) => {
const rows: TableRowType<DataPolicyType>[] = [];
dataPolicyInfo?.forEach((policyInfo) => {
policyInfo?.policyName?.includes(searchText) &&
rows.push({
data: policyInfo,
rowId: policyInfo?.policyName,
isDisabled: false,
});
});
return rows;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits:

Suggested change
const getRow = (dataPolicyInfo: DataPolicyType[], searchText: string) => {
const rows: TableRowType<DataPolicyType>[] = [];
dataPolicyInfo?.forEach((policyInfo) => {
policyInfo?.policyName?.includes(searchText) &&
rows.push({
data: policyInfo,
rowId: policyInfo?.policyName,
isDisabled: false,
});
});
return rows;
};
const getRow = (dataPolicyInfo: DataPolicyType[], searchText: string) =>
dataPolicyInfo?.reduce((rowsAcc, policyInfo) => {
policyInfo?.policyName?.includes(searchText) &&
rowsAcc.push({
data: policyInfo,
rowId: policyInfo?.policyName,
isDisabled: false,
});
}, []);

Comment on lines 49 to 51
const indexOfLastRow = currentPage * perPage;
const indexOfFirstRow = indexOfLastRow - perPage;
return [indexOfFirstRow, indexOfLastRow];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if:
currentPage = 1
perPage = 10
then:
indexOfLastRow = 10
indexOfFirstRow = 0

won;t it make 11 rows in total ??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: naming wise this can be confusing... better to do "end+1" while using slice later...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rows?.slice(0, 10) will return values from 0 to 9th index of array, i dont want to complicate the logic but adding one (or) subtracting 1

<Td translate={null} dataLabel={policyName}>
{policyName}
</Td>
<Td translate={null} dataLabel={policyType}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there diff type of policies as well ?? why do we have name of the column as "Policy type" ??

Copy link
Contributor Author

@GowthamShanmugam GowthamShanmugam Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per UX design, the modal is designed to support different types of policy, but do we really need to support multiple types of policy in the future is not yet decided. Supporting multiple types might affect the UI performance. for now we are keeping like this.

Comment on lines 102 to 109
{isValidated ? (
<StatusIconAndText title={status} icon={<GreenCheckCircleIcon />} />
) : (
<StatusIconAndText
title={status}
icon={<RedExclamationCircleIcon />}
/>
)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{isValidated ? (
<StatusIconAndText title={status} icon={<GreenCheckCircleIcon />} />
) : (
<StatusIconAndText
title={status}
icon={<RedExclamationCircleIcon />}
/>
)}
{
<StatusIconAndText title={status} icon={isValidated ? <GreenCheckCircleIcon /> : <RedExclamationCircleIcon />} />
}

Comment on lines 119 to 125
<Td translate={null} isActionCell>
<ActionsColumn items={RowActions(t)} isDisabled={false} />
</Td>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not Kebab that we use everywhere else ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kebab is for launch modal, here i just want to switch the context

@@ -0,0 +1,17 @@
.mco-modal-col-padding {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.mco-modal-col-padding {
.mco-modal__table--padding {

padding: 0 3rem 0 1rem;
}

.mco-modal-box__body {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits:

Suggested change
.mco-modal-box__body {
.mco-modal__body {

Comment on lines 29 to 39
) => {
setPage(newPage);
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits:

Suggested change
) => {
setPage(newPage);
};
) =>
setPage(newPage);

Comment on lines 27 to 37
) => {
onSearchChange(value);
};

const onToggle = () => {
setIsExpanded(!isExpanded);
};

const onSelect = () => {
setIsExpanded(false);
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits:

Suggested change
) => {
onSearchChange(value);
};
const onToggle = () => {
setIsExpanded(!isExpanded);
};
const onSelect = () => {
setIsExpanded(false);
};
) => onSearchChange(value);
const onToggle = () => setIsExpanded(!isExpanded);
const onSelect = () => setIsExpanded(false);

Comment on lines 5 to 23
export const PrimaryActionHeader: React.FC<PrimaryActionHeaderType> = ({
title,
actionTitle,
disabled,
onClick,
}) => (
<div className="odf-primary-action-title odf-primary-action--row">
<Text component="h3">{title}</Text>
<div>
<Button
variant={ButtonVariant.primary}
onClick={onClick}
isDisabled={disabled}
>
{actionTitle}
</Button>
</div>
</div>
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can easily re-use ListPageCreateLink in order to replicate this component ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create is for to link, which will redirect the page, may be ListPageCreateButton might work, i need to check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried both. ListPageCreateLink is for redirecting. For ListPageCreateButton unit testing is throws an error. Looks like one is using ListPageCreateButton.

Comment on lines 42 to 50
<ToolbarItem variant="search-filter">
<SearchInput
placeholder="Search"
aria-label={t('Search input')}
value={searchValue}
onChange={onSearch}
/>
</ToolbarItem>
<ToolbarItem>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we re-use ListPageFilter ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i checked, ListPageFilter is designed for name and label-wise filters. It is comes with either name dropdown or label dropdown, in my design both are not present.

) => void;
}[];
onSearchChange?: React.Dispatch<React.SetStateAction<string>>;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure we need new component and we can not re-use any of the existing "ListPage" related components exposed by console ??
cc @GowthamShanmugam

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ListPage dont has a dropdown button, also, the search box is designed for name and level-wise filtering. In manage policy modal mockups, we dont have such filtering.

</Tbody>
</TableComposable>
);
};
Copy link
Collaborator

@SanjalKatiyar SanjalKatiyar Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there no way we can re-use VirtualizedTable ?? do we need to use TableComposable Tbodyetc from PF to implement this ??
cc @GowthamShanmugam

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure VirtualizedTable is providing a selectable option for each row and select all options. Also, we are using import { Table, TableHeader, TableBody } from '@patternfly/react-table'; in select-nodes-table.tsx but it is not that flexible.

Copy link
Collaborator

@SanjalKatiyar SanjalKatiyar Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VirtualizedTable has a rowData prop, whatever is passed to this "rowData" is then passed on to each row that is added via "RowRenderer" FC which is passed to Row prop.
Maybe we can try adding first column of each row as a checkbox in this "RowRenderer", and pass a "setRows" callback via rowData prop ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a select all in column header also
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm. looks like it might work, let me check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i checked VirtualizedTable code, which does not support selectable table

Comment on lines 176 to 195
React.useEffect(() => {
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Shift') {
setShifting(true);
}
};
const onKeyUp = (e: KeyboardEvent) => {
if (e.key === 'Shift') {
setShifting(false);
}
};

document.addEventListener('keydown', onKeyDown);
document.addEventListener('keyup', onKeyUp);

return () => {
document.removeEventListener('keydown', onKeyDown);
document.removeEventListener('keyup', onKeyUp);
};
}, [setShifting]);
Copy link
Collaborator

@SanjalKatiyar SanjalKatiyar Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we even need to support such cases ??
I know PF might be supporting this, but, does tables in console support this ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will check and remove this

isSelecting: boolean
) => {
// If the user is shift + selecting the checkboxes, then all intermediate checkboxes should be selected
if (shifting && recentSelectedRowIndex !== null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don;t think we need to support this if console tables do not support this. If they does, then it might make sense to have it for us as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this table is multi-select, and console tables are different, I am unable to find any other component which gives a selectable table, that why I created this selectable table component, which means this use case is also new, we may support this or we may not. Even i dont like this shifting option :)

} from '@patternfly/react-table';
import { useCustomTranslation } from '../useCustomTranslationHook';

const isRowsSelectable = (row: TableRowType) => !row?.isDisabled;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isRowsSelectable = (row: TableRowType) => !row?.isDisabled;
const isRowSelectable = (row: TableRowType) => !row?.isDisabled;

);
};

const isRowsSelected = (rowId: any, selectedRows: TableRowType[]) =>
Copy link
Collaborator

@SanjalKatiyar SanjalKatiyar Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isRowsSelected = (rowId: any, selectedRows: TableRowType[]) =>
const areRowsSelected = (rowId: any, selectedRows: TableRowType[]) =>

Comment on lines 156 to 162
// Note that we perform the sort as part of the component's render logic and not in onSort.
let sortedRows: TableRowType[] = sortRows(
activeSortIndex,
activeSortDirection,
rows,
columns
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why bother to sort as a part of render ??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren;t we doing something which is not needed, also this will happen everytime component re-renders...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check this why, the I referred patternfly example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The funny thing is sort is always used to render level everywhere, what I am assuming is, since the list is a watcher, it needs to be sorted always. Since the arrow asc or dec is displayed always, it looks like it needs to sorted always

@GowthamShanmugam GowthamShanmugam force-pushed the app_manage_policy branch 4 times, most recently from 63b2676 to ae881ef Compare June 16, 2023 11:22
@GowthamShanmugam
Copy link
Contributor Author

/retest

@@ -77,7 +78,7 @@ const DRPolicyRow: React.FC<RowProps<DRPolicyKind, RowData>> = ({
{obj?.metadata?.name}
</TableData>
<TableData {...tableColumnInfo[1]} activeColumnIDs={activeColumnIDs}>
{condition?.status === 'True' ? t('Validated') : t('Not Validated')}
{isDRPolicyValidated(obj) ? t('Validated') : t('Not Validated')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to backport this potentially?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its, not a fix, just moved the condition?.status === 'True' under util function just to reuse the logic in multiple places

sortField: string
) => {
const negation = c !== SortByDirection.asc;
const aValue = _.get(a, sortField, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const aValue = _.get(a, sortField, '');
const aValue = a?.[sortField] || '';

This should work.

Comment on lines 26 to 27
const selectedRowIds = selectedRows?.map((selectedRow) =>
getUID(selectedRow)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const selectedRowIds = selectedRows?.map((selectedRow) =>
getUID(selectedRow)
const selectedRowIds = selectedRows?.map(getUID)

nit: you could do something like this as well.

) => {
const selectedRowIds = selectedRows?.map((selectedRow) =>
getUID(selectedRow)
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const selecteableRowsIds = selectableRows.map(getUID)
return ( selectableRowsIds?.every(rowID => selectedRowIds.includes(rowID)))

Would this make it easier to read? WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but still keeping the length check to avoid a corner case: every will return true for an empty array, and select all checkbox will be checked for empty rows.

};

type SelectableTableProps = <T extends K8sResourceCommon>(
props: TableProps<T>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
props: TableProps<T>
props: React.PropsWithoutRef<TableProps<T>>

<>
<Modal
title={
state.modalViewContext !== ModalViewContext.ASSIGN_POLICY_VIEW &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we do if it is AssignPolicyView?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assign policy view is a wizard flow, and wizard component will comeup with its own header

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i talk to UX about reusing the same header for assign policy, and he agreed. i am going to remove this condition

SET_ERROR = 'SET_ERROR',
}

export const managePolicyState = (): ManagePolicyState => ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not exactly, changing to object

},
];

return (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we generate coulmns once instad of running getColumns(t) multiple times?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks the same to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i want to use the column name under the row render component. It means column names are used between two different components. if i move get column as object under PolicyListViewTable, then i can't access it from PolicyListViewTableRow.

children,
}) => {
return (
<div className="mco-manage-policies__panelContent--col-padding">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see a scss file associated with this file? Please add a scss file and add these styles there

children,
}) => {
return (
<div className="mco-manage-policies__panelHeader">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are the styles defined?

!_.isEmpty(drPolicy)
? [
{
apiVersion: drPolicy?.apiVersion,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
apiVersion: drPolicy?.apiVersion,
apiVersion: drPolicy.apiVersion,

Comment on lines 60 to 68
kind: drPolicy?.kind,
metadata: drPolicy?.metadata,
// TODO: For multiple DRPC find least recently created
assignedOn: drpcInfo?.[0]?.metadata?.creationTimestamp,
// TODO: For multiple DRPC summarize the activity
activity: getCurrentActivity(drpcInfo?.[0]?.status, t),
isValidated: isDRPolicyValidated(drPolicy),
schedulingInterval: drPolicy?.spec?.schedulingInterval,
replicationType: findDRType(drClusters),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are all these optional chaining really required after you have tested it to be not empty already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack i will check and remove unwanted optional symbol

export const getClustersFromPlacementDecision = (
placementDecision: ACMPlacementDecisionKind
): string[] =>
placementDecision?.status?.decisions?.map(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not performing find. It's doing a map.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed function to getClustersFromPlacementDecision

apiVersion: application?.apiVersion,
kind: application?.kind,
metadata: application?.metadata,
workloadNamespace: getRemoteNSFromAppSet(application),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
workloadNamespace: getRemoteNSFromAppSet(application),
workloadNamespace: getRemoteNamespaceFromAppSet(application),

nit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

@@ -0,0 +1,232 @@
import * as React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the file should be ApplicationSetModal.tsx or something related to that since it exports that component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has parser logic and calls the AppManagePoliciesModal component, the actual modal component is called in app-manage-policies-modal.tsx. Instead of renaming the file, i am renaming the component to ApplicationSetParser

SET_ERROR = 'SET_ERROR',
}

export const initialPolicyState: ManagePolicyState = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not a function, this is an object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i already changed to object

@GowthamShanmugam GowthamShanmugam force-pushed the app_manage_policy branch 2 times, most recently from 35b4b8a to 8852d35 Compare June 19, 2023 13:03
Copy link
Contributor

@bipuladh bipuladh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few nits. looks good overall.

import * as React from 'react';
import { ArgoApplicationSetModel } from '@odf/mco/models';
import { ArgoApplicationSetKind } from '@odf/mco/types';
import { getGVKFromK8Resource } from '@odf/mco/utils';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use getReference it's already part of shared.


return (
<>
{gvk === referenceForModel(ArgoApplicationSetModel) && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to launch a modal for Argo applications only? Are there other applications on which this would perform nothing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DR is going to support multiple application types, Argo applications is one type, and in 4.15 we support another type

});

return (
<>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<>

<StatusBox loadError={props.loadError} loaded={props.loaded} />
)}
</Modal>
</>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
</>

import { ApplicationType } from './utils/types';

export const AppManagePoliciesModal: React.FC<AppManagePoliciesModalProps> = (
props
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
props
{isOpen, ...

Destructure all props here itself.

];

const PolicyListViewTableRow: React.FC<RowComponentType<DataPolicyType>> = (
props
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: destructure props here.

};

export const PolicyListViewTable: React.FC<PolicyListViewTableProps> = (
props
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: destructure props here.

} from '@patternfly/react-core';
import { useCustomTranslation } from '../useCustomTranslationHook';

export const ActionDropdown: React.FC<ActionDropdownProps> = (props) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructure props here.

);

export const PolicyListViewToolBar: React.FC<PolicyListViewToolBarProps> = (
props
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: destructure props here

Signed-off-by: Gowtham Shanmugasundaram <[email protected]>
Copy link
Contributor

@bipuladh bipuladh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 21, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bipuladh, GowthamShanmugam

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@GowthamShanmugam
Copy link
Contributor Author

/test odf-console-e2e-aws

@openshift-merge-robot openshift-merge-robot merged commit 7561878 into red-hat-storage:master Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants