Skip to content

Commit

Permalink
Merge branch 'main' into feat/Tapis-v3-redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
jarosenb authored Apr 29, 2024
2 parents bbc23a4 + ab88881 commit b953f05
Show file tree
Hide file tree
Showing 39 changed files with 1,292 additions and 116 deletions.
21 changes: 21 additions & 0 deletions client/modules/_hooks/src/datafiles/projects/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type TProjectUser = {
inst: string;
role: 'pi' | 'co_pi' | 'team_member' | 'guest';
username?: string;
authorship?: boolean;
};

export type TProjectAward = {
Expand Down Expand Up @@ -92,6 +93,8 @@ export type TBaseProjectValue = {
fileObjs: TFileObj[];
fileTags: TFileTag[];

hazmapperMaps?: THazmapperMap[];

license?: string;
};

Expand All @@ -102,6 +105,23 @@ export type TEntityValue = {
authors?: TProjectUser[];
fileObjs?: TFileObj[];
fileTags: TFileTag[];
dateStart?: string;
dateEnd?: string;
location?: string;
event?: string;
facility?: TDropdownValue;
latitude?: string;
longitude?: string;
dois?: string[];
referencedData: TReferencedWork[];
relatedWork: TAssociatedProject[];

experimentType?: TDropdownValue;
equipmentType?: TDropdownValue;
procedureStart?: string;
procedureEnd?: string;

simulationType?: TDropdownValue;
};

export type TProjectMeta = {
Expand All @@ -126,6 +146,7 @@ export type TPreviewTreeData = {
uuid: string;
value: TEntityValue;
order: number;
publicationDate?: string;
children: TPreviewTreeData[];
};

Expand Down
19 changes: 16 additions & 3 deletions client/modules/_hooks/src/datafiles/projects/useProjectListing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useQuery } from '@tanstack/react-query';
import { useSearchParams } from 'react-router-dom';
import apiClient from '../../apiClient';
import { TBaseProject } from './types';

Expand All @@ -10,25 +11,37 @@ export type TProjectListingResponse = {
async function getProjectListing({
page = 1,
limit = 100,
queryString,
signal,
}: {
page: number;
limit: number;
queryString?: string;
signal: AbortSignal;
}) {
const resp = await apiClient.get<TProjectListingResponse>(
'/api/projects/v2',
{
signal,
params: { offset: (page - 1) * limit, limit },
params: { offset: (page - 1) * limit, limit, q: queryString },
}
);
return resp.data;
}

export function useProjectListing(page: number, limit: number) {
const [searchParams] = useSearchParams();
const queryString = searchParams.get('q') ?? undefined;
return useQuery({
queryKey: ['datafiles', 'projects', 'listing', page, limit],
queryFn: ({ signal }) => getProjectListing({ page, limit, signal }),
queryKey: [
'datafiles',
'projects',
'listing',
page,
limit,
queryString ?? '',
],
queryFn: ({ signal }) =>
getProjectListing({ page, limit, queryString, signal }),
});
}
16 changes: 14 additions & 2 deletions client/modules/_hooks/src/datafiles/useFileListing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useInfiniteQuery } from '@tanstack/react-query';
import apiClient from '../apiClient';
import { AxiosError } from 'axios';
import { useSearchParams } from 'react-router-dom';

export type TFileListing = {
system: string;
Expand Down Expand Up @@ -28,13 +29,14 @@ async function getFileListing(
limit: number = 100,
page: number = 0,
nextPageToken: string | undefined,
queryString: string | undefined,
{ signal }: { signal: AbortSignal }
) {
const offset = page * limit;

const res = await apiClient.get<FileListingResponse>(
`/api/datafiles/${api}/${scheme}/listing/${system}/${path}`,
{ signal, params: { offset, limit, nextPageToken } }
{ signal, params: { offset, limit, nextPageToken, q: queryString } }
);
return res.data;
}
Expand All @@ -61,12 +63,21 @@ function useFileListing({
pageSize = 100,
disabled = false,
}: TFileListingHookArgs) {
const [searchParams] = useSearchParams();
const queryString = searchParams.get('q');
return useInfiniteQuery<
FileListingResponse,
AxiosError<{ message?: string }>
>({
initialPageParam: 0,
queryKey: ['datafiles', 'fileListing', api, system, path],
queryKey: [
'datafiles',
'fileListing',
api,
system,
path,
queryString ?? '',
],
queryFn: ({ pageParam, signal }) =>
getFileListing(
api,
Expand All @@ -76,6 +87,7 @@ function useFileListing({
pageSize,
(pageParam as TFileListingPageParam).page,
(pageParam as TFileListingPageParam).nextPageToken,
queryString ?? undefined,
{
signal,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const ToolbarButton: React.FC<ButtonProps> = (props) => {
);
};

export const DatafilesToolbar: React.FC = () => {
export const DatafilesToolbar: React.FC<{ searchInput?: React.ReactNode }> = ({
searchInput,
}) => {
const { api, system, scheme, path } = useFileListingRouteParams();
const { selectedFiles } = useSelectedFiles(api, system, path);
const { user } = useAuthenticatedUser();
Expand All @@ -45,7 +47,7 @@ export const DatafilesToolbar: React.FC = () => {

return (
<div className={styles.toolbarRoot}>
<span>(search bar goes here)</span>
<div style={{ marginLeft: '12px' }}>{searchInput ?? null}</div>

<div className={styles.toolbarButtonContainer}>
<DatafilesModal.Rename api={api} system={system} path={path}>
Expand Down
14 changes: 11 additions & 3 deletions client/modules/datafiles/src/FileListing/FileListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@ export const FileListing: React.FC<
system: string;
path?: string;
scheme?: string;
baseRoute?: string;
} & Omit<TableProps, 'columns'>
> = ({ api, system, path = '', scheme = 'private', ...tableProps }) => {
> = ({
api,
system,
path = '',
scheme = 'private',
baseRoute,
...tableProps
}) => {
// Base file listing for use with My Data/Community Data
const [previewModalState, setPreviewModalState] = useState<{
isOpen: boolean;
Expand All @@ -43,7 +51,7 @@ export const FileListing: React.FC<
record.type === 'dir' ? (
<NavLink
className="listing-nav-link"
to={`../${encodeURIComponent(record.path)}`}
to={`${baseRoute ?? '..'}/${encodeURIComponent(record.path)}`}
replace={false}
>
<i
Expand Down Expand Up @@ -85,7 +93,7 @@ export const FileListing: React.FC<
render: (d) => new Date(d).toLocaleString(),
},
],
[setPreviewModalState]
[setPreviewModalState, baseRoute]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
-webkit-box-orient: vertical;
overflow: hidden;
}

.prj-row td {
padding: 2px 0px;
}
Loading

0 comments on commit b953f05

Please sign in to comment.