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

feat(ui): Support filter for configured and unchanged on SYNC STATUS view #20850

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface Props {
operationState: models.OperationState;
}
const buildResourceUniqueId = (res: Omit<models.ResourceRef, 'uid'>) => `${res.group}-${res.kind}-${res.version}-${res.namespace}-${res.name}`;
const FilterableMessageStatuses = ['configured', 'unchanged'];

const Filter = (props: {filters: string[]; setFilters: (f: string[]) => void; options: string[]; title: string; style?: React.CSSProperties}) => {
const {filters, setFilters, options, title, style} = props;
Expand Down Expand Up @@ -52,6 +53,8 @@ const Filter = (props: {filters: string[]; setFilters: (f: string[]) => void; op
};

export const ApplicationOperationState: React.StatelessComponent<Props> = ({application, operationState}, ctx: AppContext) => {
const [messageFilters, setMessageFilters] = React.useState([]);

const operationAttributes = [
{title: 'OPERATION', value: utils.getOperationType(application)},
{title: 'PHASE', value: operationState.phase},
Expand Down Expand Up @@ -166,7 +169,7 @@ export const ApplicationOperationState: React.StatelessComponent<Props> = ({appl

if (combinedHealthSyncResult && combinedHealthSyncResult.length > 0) {
filtered = combinedHealthSyncResult.filter(r => {
if (filters.length === 0 && healthFilters.length === 0) {
if (filters.length === 0 && healthFilters.length === 0 && messageFilters.length === 0) {
return true;
}

Expand All @@ -179,6 +182,10 @@ export const ApplicationOperationState: React.StatelessComponent<Props> = ({appl
pass = false;
}

if (pass && messageFilters.length !== 0) {
pass = messageFilters.some(filter => r.message?.toLowerCase().includes(filter.toLowerCase()));
}

return pass;
});
}
Expand All @@ -203,6 +210,7 @@ export const ApplicationOperationState: React.StatelessComponent<Props> = ({appl
<Filter options={Healths} filters={healthFilters} setFilters={setHealthFilters} title='HEALTH' style={{marginRight: '5px'}} />
<Filter options={Statuses} filters={filters} setFilters={setFilters} title='STATUS' style={{marginRight: '5px'}} />
<Filter options={OperationPhases} filters={filters} setFilters={setFilters} title='HOOK' />
<Filter options={FilterableMessageStatuses} filters={messageFilters} setFilters={setMessageFilters} title='MESSAGE' />
</div>
</div>
<div className='argo-table-list'>
Expand Down