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

F4092: Add toggle to fetch deprecated resources, default to false #1351

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
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
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;
}
Loading