Skip to content

Commit

Permalink
Data Files/Projects styling fixes (#1336)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarosenb authored Jul 8, 2024
1 parent f8dd741 commit 0906586
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const FileListingTable: React.FC<
disabled?: boolean;
className?: string;
emptyListingDisplay?: React.ReactNode;
noSelection?: boolean;
searchTerm?: string | null;
} & Omit<TableProps, 'columns' | 'className'>
> = ({
Expand All @@ -38,6 +39,7 @@ export const FileListingTable: React.FC<
className,
emptyListingDisplay,
searchTerm = '',
noSelection,
...props
}) => {
const limit = 100;
Expand Down Expand Up @@ -133,17 +135,21 @@ export const FileListingTable: React.FC<
className={`${styles['listing-table-base']} ${
(combinedListing?.length ?? 0) > 0 ? 'table--pull-spinner-bottom' : ''
} ${className ?? ''}`}
rowSelection={{
type: 'checkbox',
onChange: onSelectionChange,
selectedRowKeys,
renderCell: (checked, _rc, _idx, node) => (
<FileListingTableCheckbox
checked={checked}
onChange={(node as React.ReactElement)?.props.onChange}
/>
),
}}
rowSelection={
noSelection
? undefined
: {
type: 'checkbox',
onChange: onSelectionChange,
selectedRowKeys,
renderCell: (checked, _rc, _idx, node) => (
<FileListingTableCheckbox
checked={checked}
onChange={(node as React.ReactElement)?.props.onChange}
/>
),
}
}
scroll={{ y: '100%', x: '1000px' }} // set to undefined to disable sticky header
columns={columns}
rowKey={(record) => record.path}
Expand Down
2 changes: 1 addition & 1 deletion client/modules/_hooks/src/datafiles/usePathDisplayName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function getSystemRootDisplayName(
return (
{
'designsafe.storage.default': 'My Data',
'designsafe.storage.frontera.work': 'My Data (Work)',
'designsafe.storage.frontera.work': 'HPC Work',
'designsafe.storage.community': 'Community Data',
}[system] ?? label
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const UploadFileModalBody: React.FC<{
path: string;
handleCancel: () => void;
}> = ({ isOpen, api, system, scheme, path, handleCancel }) => {
const { mutate } = useUploadFile();
const { mutateAsync } = useUploadFile();

const [fileList, setFileList] = useState<UploadFile[]>([]);
const [uploading, setUploading] = useState(false);
Expand All @@ -36,7 +36,7 @@ export const UploadFileModalBody: React.FC<{
formData.append('file_name', fileList[i].name);
formData.append('webkit_relative_path', '');

await mutate({
await mutateAsync({
api,
system,
scheme: 'private', // Optional
Expand All @@ -47,6 +47,7 @@ export const UploadFileModalBody: React.FC<{

// All files uploaded successfully, close the modal
setUploading(false);
setFileList([]);
handleCancel();
} catch (error) {
console.error('Error during form submission:', error);
Expand Down
3 changes: 3 additions & 0 deletions client/modules/datafiles/src/FileListing/FileListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const FileListing: React.FC<
scheme?: string;
baseRoute?: string;
fileTags?: TFileTag[];
emptyListingDisplay?: React.ReactNode;
} & Omit<TableProps, 'columns'>
> = ({
api,
Expand All @@ -36,6 +37,7 @@ export const FileListing: React.FC<
scheme = 'private',
baseRoute,
fileTags,
emptyListingDisplay,
...tableProps
}) => {
// Base file listing for use with My Data/Community Data
Expand Down Expand Up @@ -122,6 +124,7 @@ export const FileListing: React.FC<
scheme={scheme}
path={path}
columns={columns}
emptyListingDisplay={emptyListingDisplay}
{...tableProps}
/>
{previewModalState.path && previewModalState.selectedFile && (
Expand Down
24 changes: 24 additions & 0 deletions client/modules/datafiles/src/projects/EmptyProjectFileListing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';

export const EmptyProjectFileListing: React.FC = () => {
return (
<p style={{ marginTop: '20px', fontSize: '16px' }}>
This folder is empty! <br />
<i role="none" className="fa fa-folder-open-o">
&nbsp;
</i>
<br />
<a
href="https://www.youtube.com/watch?v=ITf4hlBamGU&amp;list=PL2GxvrdFrBlkwHBgQ47pZO-77ZLrJKYHV"
target="_blank"
rel="noopener noreferrer"
aria-describedby="msg-open-ext-site-new-window"
>
<i role="none" className="fa fa-question-circle">
&nbsp;
</i>
Learn how to move files to a project
</a>
</p>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
} from '../constants';
import { DefaultOptionType } from 'antd/es/select';
import { FILE_TAG_OPTIONS } from './ProjectFileTagOptions';
import { EmptyProjectFileListing } from '../EmptyProjectFileListing';

const FileTagInput: React.FC<{
projectId: string;
Expand Down Expand Up @@ -354,6 +355,7 @@ export const ProjectCurationFileListing: React.FC<{
scheme="private"
path={path}
columns={columns}
emptyListingDisplay={<EmptyProjectFileListing />}
scroll={{ y: 500 }}
/>
{previewModalState.path && previewModalState.selectedFile && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const EntityFileListingTable: React.FC<{
&nbsp;&nbsp;
<Button
type="link"
disabled={preview}
onClick={() =>
setPreviewModalState({
isOpen: true,
Expand Down Expand Up @@ -103,6 +102,7 @@ const EntityFileListingTable: React.FC<{
columns={columns}
scroll={{ x: 500, y: 500 }}
dataSource={treeData.value.fileObjs}
noSelection={preview}
disabled
/>
{previewModalState.path && previewModalState.selectedFile && (
Expand Down Expand Up @@ -313,6 +313,7 @@ export const PublishedEntityDisplay: React.FC<{
)}
{(sortedChildren ?? []).map((child) => (
<RecursiveTree
preview={preview}
treeData={child}
key={child.id}
defaultOpen={defaultOpenChildren}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const BaseProjectCreateForm: React.FC<{
<Form
form={form}
layout="vertical"
onFinish={(v) => onSubmit(processFormData(v))}
onFinish={(v) => {
onSubmit(processFormData(v));
form.resetFields();
}}
onFinishFailed={(v) => console.log(processFormData(v.values))}
requiredMark={customRequiredMark}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import dayjs from 'dayjs';
export const DateInput: React.FC<
{
value?: string;
id?: string;
onChange?: (value?: string) => void;
} & DatePickerProps
> = ({ value, onChange, ...props }) => {
> = ({ value, onChange, id, ...props }) => {
return (
<>
<DatePicker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export const DropdownSelect: React.FC<{
options: SelectProps['options'];
value?: DropdownValue[];
placeholder?: string;
id?: string;
onChange?: (value: DropdownValue[]) => void;
}> = ({ value, onChange, options, maxCount, placeholder }) => {
}> = ({ value, onChange, options, maxCount, placeholder, id }) => {
const [open, setOpen] = useState(false);
const handleChange = (newVal: { label?: string; value: string }[]) => {
const formValue = newVal.map((v) =>
Expand All @@ -31,6 +32,7 @@ export const DropdownSelect: React.FC<{

return (
<Select
id={id}
open={open}
onDropdownVisibleChange={(visible) => setOpen(visible)}
virtual={false}
Expand All @@ -48,10 +50,11 @@ export const DropdownSelect: React.FC<{

export const DropdownSelectSingleValue: React.FC<{
options: SelectProps['options'];
id?: string;
value?: DropdownValue;
placeholder?: string;
onChange?: (value?: DropdownValue) => void;
}> = ({ value, onChange, options, placeholder }) => {
}> = ({ value, onChange, options, id, placeholder }) => {
const [open, setOpen] = useState(false);

const handleChange = (newVal: { label?: string; value: string }[]) => {
Expand Down Expand Up @@ -79,6 +82,7 @@ export const DropdownSelectSingleValue: React.FC<{

return (
<Select
id={id}
maxCount={1}
virtual={false}
placeholder={placeholder}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export type TProjectUser = {
export const UserSelect: React.FC<{
value?: TProjectUser[];
onChange?: (value: TProjectUser[]) => void;
id?: string;
userRole?: string;
maxCount?: number;
disabled?: boolean;
}> = ({ value, onChange, userRole, maxCount, disabled }) => {
}> = ({ value, onChange, id, userRole, maxCount, disabled }) => {
const initialOptions: SelectProps['options'] = useMemo(
() =>
value?.map((u) => ({
Expand Down Expand Up @@ -63,6 +64,7 @@ export const UserSelect: React.FC<{

return (
<Select
id={id}
notFoundContent={
<span>
No users were found matching your query. An exact TACC username match
Expand Down
1 change: 1 addition & 0 deletions client/modules/datafiles/src/projects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { ProjectTitleHeader } from './ProjectTitleHeader/ProjectTitleHeader';
export { ProjectCurationFileListing } from './ProjectCurationFileListing/ProjectCurationFileListing';
export { ProjectNavbar } from './ProjectNavbar/ProjectNavbar';
export { ProjectPipeline } from './ProjectPipeline/ProjectPipeline';
export { EmptyProjectFileListing } from './EmptyProjectFileListing';
export {
ProjectPreview,
PublicationView,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const ManageCategoryModal: React.FC<{
</section>
)}
<article style={{ marginTop: '5px' }}>
<strong>Category Inventory</strong>
{categories.length >= 1 && <strong>Category Inventory</strong>}
{categories.map((category) =>
data.entities
.filter((e) => e.name === category)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export const ManagePublishableEntityModal: React.FC<{
)}

<article style={{ marginTop: '5px' }}>
{data.entities.length >= 1 && (
<strong>{DISPLAY_NAMES[entityName]} Inventory</strong>
)}
{data.entities
.filter((e) => e.name === entityName)
.map((entity) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const ProjectPreviewLayout: React.FC = () => {
if (!projectId) return null;
if (!data) return null;
return (
<div style={{ flex: 1 }}>
<div style={{ flex: 1, paddingBottom: '30px' }}>
<ProjectTitleHeader projectId={projectId} />
<BaseProjectDetails projectValue={data.baseProject.value} />
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { Link, useParams } from 'react-router-dom';
import {
ChangeProjectTypeModal,
EmptyProjectFileListing,
FileListing,
ProjectNavbar,
} from '@client/datafiles';
Expand Down Expand Up @@ -72,6 +73,7 @@ export const ProjectWorkdirLayout: React.FC = () => {
system={`project-${data.baseProject.uuid}`}
path={path ?? ''}
scroll={{ y: 500 }}
emptyListingDisplay={<EmptyProjectFileListing />}
/>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions client/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@
.o-site__body:has(> #apps-root),
#apps-root,
#apps-root > div.ant-flex,
.ant-layout-has-sider,
.ant-layout-sider {
#apps-root .ant-layout-has-sider,
#apps-root .ant-layout-sider {
height: 100%;
overflow: hidden;
}
Expand Down

0 comments on commit 0906586

Please sign in to comment.