Skip to content

Commit

Permalink
Merge 1351 (F4092)
Browse files Browse the repository at this point in the history
F4092: Add toggle to fetch deprecated resources, default to false
  • Loading branch information
bilalesi authored Jul 28, 2023
2 parents c25af9a + 2b0a5e6 commit 1045905
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
26 changes: 25 additions & 1 deletion src/subapps/dataExplorer/DataExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface DataExplorerConfiguration {
type: string | undefined;
predicate: ((resource: Resource) => boolean) | null;
selectedPath: string | null;
deprecated: boolean;
}

export const DataExplorer: React.FC<{}> = () => {
Expand All @@ -31,7 +32,15 @@ export const DataExplorer: React.FC<{}> = () => {
const [headerHeight, setHeaderHeight] = useState<number>(0);

const [
{ pageSize, offset, orgAndProject, predicate, type, selectedPath },
{
pageSize,
offset,
orgAndProject,
predicate,
type,
selectedPath,
deprecated,
},
updateTableConfiguration,
] = useReducer(
(
Expand All @@ -45,6 +54,7 @@ export const DataExplorer: React.FC<{}> = () => {
type: undefined,
predicate: null,
selectedPath: null,
deprecated: false,
}
);

Expand All @@ -53,6 +63,7 @@ export const DataExplorer: React.FC<{}> = () => {
offset,
orgAndProject,
type,
deprecated,
});

const currentPageDataSource: Resource[] = resources?._results || [];
Expand All @@ -71,6 +82,11 @@ export const DataExplorer: React.FC<{}> = () => {
[currentPageDataSource, showMetadataColumns, selectedPath]
);

const onDeprecatedChange = (checked: boolean) =>
updateTableConfiguration({
deprecated: checked,
});

return (
<div className="data-explorer-contents">
{isLoading && <Spin className="loading" />}
Expand Down Expand Up @@ -113,6 +129,14 @@ export const DataExplorer: React.FC<{}> = () => {
totalFiltered={predicate ? displayedDataSource.length : undefined}
/>
<div className="data-explorer-toggles">
<Switch
defaultChecked={false}
checked={deprecated}
onClick={onDeprecatedChange}
id="show-deprecated-resources"
className="data-explorer-toggle"
/>
<label htmlFor="show-metadata-columns">Show deprecated</label>
<Switch
defaultChecked={false}
checked={showMetadataColumns}
Expand Down
8 changes: 7 additions & 1 deletion src/subapps/dataExplorer/DataExplorerUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ export const usePaginatedExpandedResources = ({
offset,
orgAndProject,
type,
deprecated,
}: PaginatedResourcesParams) => {
const nexus = useNexusContext();

return useQuery({
queryKey: ['data-explorer', { pageSize, offset, orgAndProject, type }],
queryKey: [
'data-explorer',
{ pageSize, offset, orgAndProject, type, deprecated },
],
retry: false,
queryFn: async () => {
const resultWithPartialResources = await nexus.Resource.list(
orgAndProject?.[0],
orgAndProject?.[1],
{
type,
deprecated,
from: offset,
size: pageSize,
}
Expand Down Expand Up @@ -181,4 +186,5 @@ interface PaginatedResourcesParams {
offset: number;
orgAndProject?: string[];
type?: string;
deprecated: boolean;
}

0 comments on commit 1045905

Please sign in to comment.