Skip to content

Commit

Permalink
feat(pci.private-registry): fix
Browse files Browse the repository at this point in the history
ref: TAPC-584
Signed-off-by: Pierre-Philippe <[email protected]>
  • Loading branch information
Pierre-Philippe committed Dec 17, 2024
1 parent 2648ec7 commit d93abbd
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/manager/apps/pci-private-registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@ovh-ux/manager-core-api": "^0.9.0",
"@ovh-ux/manager-core-utils": "*",
"@ovh-ux/manager-pci-common": "^0.14.0",
"@ovh-ux/manager-react-components": "^1.41.1",
"@ovh-ux/manager-react-components": "^1.41.2",
"@ovh-ux/manager-react-core-application": "^0.11.4",
"@ovh-ux/manager-react-shell-client": "^0.8.3",
"@ovh-ux/manager-tailwind-config": "^0.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ const Buttons = () => {

const removeDraftRow = () => {
reset();
queryClient.setQueryData(
getRegistryQueyPrefixWithId(projectId, registryId, [
'management',
'registry',
]),
(oldData: TIPRestrictionsData[]) => oldData.filter((item) => !item.draft),
const key = getRegistryQueyPrefixWithId(projectId, registryId, [
'management',
'registry',
]);
queryClient.setQueryData<TIPRestrictionsData[]>(key, (oldData) =>
oldData.filter((item) => !item.draft),
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ import {
getRegistryQueyPrefixWithId,
useIpRestrictionsWithFilter,
} from '@/api/hooks/useIpRestrictions';
import { TIPRestrictionsData } from '@/types';
import useFilters from '@/pages/CIDR/useFilters';

const createNewRow = (queryClient: QueryClient, key: QueryKey) =>
queryClient.setQueryData(key, (oldData: TIPRestrictionsData[]) => [
queryClient.setQueryData<TIPRestrictionsData[]>(key, (oldData) => [
{
authorization: null,
description: null,
ipBlock: null,
createdAt: new Date(),
id: oldData.length + 1,
draft: true,
checked: null,
Expand Down Expand Up @@ -129,13 +132,16 @@ export default function BlocCIDR() {
<div className="mt-8">
<>
<Filters createNewRow={createNewBlocsCIDR} />
<Datagrid
columns={columns}
items={dataCIDR.rows}
totalItems={dataCIDR.totalRows || 0}
pagination={pagination}
onPaginationChange={setPagination}
/>
<div className="mt-8">
<Datagrid
columns={columns}
items={dataCIDR.rows}
totalItems={dataCIDR.totalRows || 0}
pagination={pagination}
onPaginationChange={setPagination}
className="overflow-x-visible"
/>
</div>
</>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ const Filters = ({ createNewRow }: { createNewRow: () => void }) => {
inputValue: string | string[],
key = 'ipBlock',
label = '',
comparator = FilterComparator.Includes,
) => {
setPagination({ pageIndex: 0, pageSize: pagination.pageSize });
addFilter({
key,
value: inputValue,
comparator: FilterComparator.Includes,
comparator,
label,
} as Filter & { label: string });
};
Expand Down Expand Up @@ -162,7 +163,12 @@ const Filters = ({ createNewRow }: { createNewRow: () => void }) => {
},
]}
onAddFilter={(addedFilter, column) => {
handleAddFilter(addedFilter.value, column.id, column.label);
handleAddFilter(
addedFilter.value,
column.id,
column.label,
FilterComparator.IsEqual,
);
filterPopoverRef.current?.closeSurface();
}}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, it, expect } from 'vitest';
import { categorizeByKey, isCidr, isIp } from '.';
import { categorizeByKey } from '.';

import { aggregateBySpecificKey } from './index';

type TestData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import { useTranslation } from 'react-i18next';
import BreadcrumbCIDR from '@/components/CIDR/Breadcrumb.component';
import { FilterRestrictionsEnum } from '@/types';
import { isCidr, isIp } from '@/helpers';
import { isCidr, isIp } from '@/helpers/ip-restrictions';
import BlocCIDR from '@/components/CIDR/CIDR.component';
import { useIpRestrictions } from '@/api/hooks/useIpRestrictions';
import { useSuspenseRegistry } from '@/api/hooks/useRegistry';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const useDatagridColumn = () => {
'registry',
]);

queryClient.setQueryData(key, (oldData: TIPRestrictionsData[]) =>
queryClient.setQueryData<TIPRestrictionsData[]>(key, (oldData) =>
oldData.map((item) => {
if (allIsSelected && item.checked !== null) {
if (data.rows.find((row) => row.ipBlock === item.ipBlock)) {
Expand Down

0 comments on commit d93abbd

Please sign in to comment.