Skip to content

Commit cc0bd83

Browse files
longshuicylmarinitcnichol
authored
clear more breakpoints and move role to the Details (#968)
* clear more breakpoints and move role to the Details * bump version up * add version to public layout too * update changelog * package json version * Pre commit autoformat (#846) * Removed unused imports using autoflake. * Ordered imports using isort. * Reformatted using black. * Setting up pre-commits. * Ran pre-commit an all files. * Working on creating openapi.json without running backend to be used with codegen. * Fixed `MUI: The Tabs component doesn't accept a Fragment as a child.` * Fixed runtime error due to replacing `== None` with 'is None'. * Fixed runtime error due to replacing `== None` with 'is None'. * Automatically generate openapi json file using pre-commit hook. * Added codegen precommit hook. * Setting up prettier and eslint. * First run of prettier. * Runnin eslint and prettier as hooks. * Skip codegen directories when running eslint and prettier. * Flake8 E711 exception. Required for Beanie query to work. * Fixed search_users_prefix codegen stub. * Fixed beanie query for get_dataset_folders. * Ignore Flake8 E711 since beanie query do not support `is None`. * bump keycloak chart version to 13 so it's using keycloak appversion 20 * update chart lock * add login to github repo * push set to true * revert login to github repo * version updates * revert * no v in the appVersion * change to make keycloak point to external url (#942) * 929 message on empty page if there is no datasets (#930) * basic message, need to improve * adding a login or register button * removing buttons * links to login or register if no public datasets * changing text * srink the version and align to left (#950) * moved key to grid instead of card * adding admin mode to the authwrapper (#951) * Fixed dataset parameters. They weren't being included in rabbtimq message. (#957) * fix extractor bugs and deployment script bug (#958) * Use --host 0.0.0.0 when running uvicorn to make backend listen on host IP. * fix missing add metadata button on dataset pycharm was complaining about missing publicView boolean in DisplayMetadata * Drag and Drop One or More Files (#935) * initial commit, add dependency, new class will eventually combine all file uploads * working on adding upload drag and drop * page does not load * drag and drop does not actually work * addign fileinputdrop as independent component * add fileupload drop inside uploadfiledraganddrop * drag and drop does not add files select selects files but misses the first one * drag and drop works now, is overwritten if file selected using button, need to fix * uploads but overwrites, need to fix * works for the select, need to fix other * should work for drop now too * was not an array * delete icon works removing console logs * drag and drop and select means other upload methods no longer needed * removing text in drag and drop * added to styles but not using because it does not work * some changes, not sure how to do rest * fix button * return to dataset * remove unnecessary imports --------- Co-authored-by: Chen Wang <[email protected]> * precommits --------- Co-authored-by: Luigi Marini <[email protected]> Co-authored-by: Todd Nicholson <[email protected]> Co-authored-by: toddn <[email protected]>
1 parent 980cafb commit cc0bd83

File tree

12 files changed

+61
-58
lines changed

12 files changed

+61
-58
lines changed

frontend/src/components/datasets/Dataset.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import ShareIcon from "@mui/icons-material/Share";
4444
import BuildIcon from "@mui/icons-material/Build";
4545
import { ExtractionHistoryTab } from "../listeners/ExtractionHistoryTab";
4646
import { SharingTab } from "../sharing/SharingTab";
47-
import RoleChip from "../auth/RoleChip";
4847
import { TabStyle } from "../../styles/Styles";
4948
import { ErrorModal } from "../errors/ErrorModal";
5049
import { Visualization } from "../visualizations/Visualization";
@@ -231,7 +230,9 @@ export const Dataset = (): JSX.Element => {
231230
</Typography>
232231
</Box>
233232
<Box>
234-
<RoleChip role={datasetRole.role} />
233+
<Typography variant="body1" paragraph>
234+
{about["description"]}
235+
</Typography>
235236
</Box>
236237
</Stack>
237238
</Grid>
@@ -246,10 +247,7 @@ export const Dataset = (): JSX.Element => {
246247
{/*actions*/}
247248
</Grid>
248249
<Grid container spacing={2} sx={{ mt: 2 }}>
249-
<Grid item xs={10}>
250-
<Typography variant="body1" paragraph>
251-
{about["description"]}
252-
</Typography>
250+
<Grid item xs={12} sm={12} md={10} lg={10} xl={10}>
253251
<Tabs
254252
value={selectedTabIndex}
255253
onChange={handleTabChange}
@@ -429,8 +427,8 @@ export const Dataset = (): JSX.Element => {
429427
<></>
430428
)}
431429
</Grid>
432-
<Grid item>
433-
<DatasetDetails details={about} />
430+
<Grid item xs={12} sm={12} md={2} lg={2} xl={2}>
431+
<DatasetDetails details={about} myRole={datasetRole.role} />
434432
</Grid>
435433
</Grid>
436434
</Layout>

frontend/src/components/datasets/DatasetDetails.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import { StackedList } from "../util/StackedList";
55
import { Dataset } from "../../types/data";
66

77
type DatasetAboutProps = {
8+
myRole?: string;
89
details: Dataset;
910
};
1011

1112
export function DatasetDetails(props: DatasetAboutProps) {
12-
const { id, created, modified, creator, status, views, downloads } =
13-
props.details;
13+
const { myRole } = props;
14+
const { id, created, modified, creator, status, downloads } = props.details;
1415

1516
const details = new Map<string, string>();
1617
details.set("Owner", `${creator.first_name} ${creator.last_name}`);
@@ -20,6 +21,8 @@ export function DatasetDetails(props: DatasetAboutProps) {
2021
details.set("Dataset id", id);
2122
details.set("Downloads", downloads);
2223

24+
if (myRole) details.set("My Role", myRole ? myRole.toUpperCase() : "");
25+
2326
return (
2427
<Box sx={{ mt: 5 }}>
2528
<Typography variant="h5" gutterBottom>

frontend/src/components/datasets/NewMenu.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useSelector } from "react-redux";
1414
import { RootState } from "../../types/data";
1515
import { UploadFile } from "../files/UploadFile";
1616
import { UploadFileMultiple } from "../files/UploadFileMultiple";
17-
import {UploadFileDragAndDrop} from "../files/UploadFileDragAndDrop";
17+
import { UploadFileDragAndDrop } from "../files/UploadFileDragAndDrop";
1818
import UploadIcon from "@mui/icons-material/Upload";
1919
import { Folder } from "@material-ui/icons";
2020

@@ -30,8 +30,7 @@ export const NewMenu = (props: ActionsMenuProps): JSX.Element => {
3030
const about = useSelector((state: RootState) => state.dataset.about);
3131

3232
const [anchorEl, setAnchorEl] = React.useState<Element | null>(null);
33-
const [dragDropFiles, setDragDropFiles] =
34-
React.useState<boolean>(false);
33+
const [dragDropFiles, setDragDropFiles] = React.useState<boolean>(false);
3534
const [newFolder, setNewFolder] = React.useState<boolean>(false);
3635

3736
const handleCloseNewFolder = () => {
@@ -55,7 +54,10 @@ export const NewMenu = (props: ActionsMenuProps): JSX.Element => {
5554
maxWidth="lg"
5655
aria-labelledby="form-dialog"
5756
>
58-
<UploadFileDragAndDrop selectedDatasetId={datasetId} folderId={folderId}/>
57+
<UploadFileDragAndDrop
58+
selectedDatasetId={datasetId}
59+
folderId={folderId}
60+
/>
5961
</Dialog>
6062

6163
<CreateFolder

frontend/src/components/datasets/PublicDataset.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ export const PublicDataset = (): JSX.Element => {
167167
{about["name"]}
168168
</Typography>
169169
</Box>
170-
<Box>{/*<RoleChip role={datasetRole.role} />*/}</Box>
170+
<Box>
171+
<Typography variant="body1" paragraph>
172+
{about["description"]}
173+
</Typography>
174+
</Box>
171175
</Stack>
172176
</Grid>
173177
{/*actions*/}
@@ -177,10 +181,7 @@ export const PublicDataset = (): JSX.Element => {
177181
{/*actions*/}
178182
</Grid>
179183
<Grid container spacing={2} sx={{ mt: 2 }}>
180-
<Grid item xs={10}>
181-
<Typography variant="body1" paragraph>
182-
{about["description"]}
183-
</Typography>
184+
<Grid item xs={12} sm={12} md={10} lg={10} xl={10}>
184185
<Tabs
185186
value={selectedTabIndex}
186187
onChange={handleTabChange}
@@ -268,7 +269,7 @@ export const PublicDataset = (): JSX.Element => {
268269
<Listeners datasetId={datasetId} />
269270
</TabPanel>
270271
</Grid>
271-
<Grid item>
272+
<Grid item xs={12} sm={12} md={2} lg={2} xl={2}>
272273
<DatasetDetails details={about} />
273274
</Grid>
274275
</Grid>

frontend/src/components/files/File.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import { Visualization } from "../visualizations/Visualization";
4747
import { ErrorModal } from "../errors/ErrorModal";
4848
import { FileHistory } from "./FileHistory";
4949
import { VersionChip } from "../versions/VersionChip";
50-
import RoleChip from "../auth/RoleChip";
5150
import Typography from "@mui/material/Typography";
5251
import { ClowderSelect } from "../styledComponents/ClowderSelect";
5352

@@ -299,7 +298,6 @@ export const File = (): JSX.Element => {
299298
) : (
300299
<></>
301300
)}
302-
<RoleChip role={fileRole} />
303301
</Grid>
304302
</Grid>
305303
<Grid item xs={2} sx={{ display: "flex-top", alignItems: "center" }}>
@@ -311,7 +309,7 @@ export const File = (): JSX.Element => {
311309
</Grid>
312310
</Grid>
313311
<Grid container spacing={2}>
314-
<Grid item xs={10}>
312+
<Grid item xs={12} sm={12} md={10} lg={10} xl={10}>
315313
<Tabs
316314
value={selectedTabIndex}
317315
onChange={handleTabChange}
@@ -449,12 +447,12 @@ export const File = (): JSX.Element => {
449447
)}
450448
</TabPanel>
451449
</Grid>
452-
<Grid item xs={2}>
450+
<Grid item xs={12} sm={12} md={2} lg={2} xl={2}>
453451
{latestVersionNum == selectedVersionNum ? (
454452
// latest version
455453
<>
456454
{Object.keys(fileSummary).length > 0 && (
457-
<FileDetails fileSummary={fileSummary} />
455+
<FileDetails fileSummary={fileSummary} myRole={fileRole} />
458456
)}
459457
</>
460458
) : (

frontend/src/components/files/FileDetails.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@ import { StackedList } from "../util/StackedList";
77

88
type FileAboutProps = {
99
fileSummary: FileOut;
10+
myRole?: string;
1011
};
1112

1213
export function FileDetails(props: FileAboutProps) {
14+
const { myRole } = props;
1315
const {
1416
id,
1517
created,
1618
name,
1719
creator,
18-
version_id,
1920
bytes,
2021
content_type,
21-
views,
2222
downloads,
2323
storage_type,
24-
storage_path,
2524
} = props.fileSummary;
2625

2726
const details = new Map<string, string>();
@@ -30,6 +29,7 @@ export function FileDetails(props: FileAboutProps) {
3029
details.set("Updated on", parseDate(created));
3130
details.set("Uploaded as", name);
3231
details.set("Uploaded by", `${creator.first_name} ${creator.last_name}`);
32+
3333
switch (storage_type) {
3434
case "minio": {
3535
details.set("Storage location", "Database");
@@ -51,6 +51,8 @@ export function FileDetails(props: FileAboutProps) {
5151
details.set("File id", id);
5252
details.set("Downloads", downloads);
5353

54+
if (myRole) details.set("My Role", myRole ? myRole.toUpperCase() : "");
55+
5456
return (
5557
<Box sx={{ mt: 5, mb: 2 }}>
5658
<Typography variant="h5" gutterBottom>

frontend/src/components/files/FileUploadDrop.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export default function FileUploadDrop(props: FileUploadDropProps) {
9898
multiple
9999
/>
100100
<Typography className={classes.fileDropText}>
101-
<br></br>
101+
<br />
102102
</Typography>
103103
</div>
104104
</FileDrop>

frontend/src/components/files/PublicFile.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export const PublicFile = (): JSX.Element => {
231231
</Grid>
232232
</Grid>
233233
<Grid container spacing={2}>
234-
<Grid item xs={10}>
234+
<Grid item xs={12} sm={12} md={10} lg={10} xl={10}>
235235
<Tabs
236236
value={selectedTabIndex}
237237
onChange={handleTabChange}
@@ -314,7 +314,7 @@ export const PublicFile = (): JSX.Element => {
314314
{/* <Listeners fileId={fileId} datasetId={datasetId} />*/}
315315
{/*</TabPanel>*/}
316316
</Grid>
317-
<Grid item xs={2}>
317+
<Grid item xs={12} sm={12} md={2} lg={2} xl={2}>
318318
{latestVersionNum == selectedVersionNum ? (
319319
// latest version
320320
<>

frontend/src/components/files/UploadFileDragAndDrop.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useEffect, useRef, useState} from "react";
1+
import React, { useEffect, useRef, useState } from "react";
22

33
import {
44
Box,
@@ -35,7 +35,7 @@ type UploadFileDragAndDropProps = {
3535
export const UploadFileDragAndDrop: React.FC<UploadFileDragAndDropProps> = (
3636
props: UploadFileDragAndDropProps
3737
) => {
38-
const { selectedDatasetId, folderId} = props;
38+
const { selectedDatasetId, folderId } = props;
3939
const [selectedFiles, setSelectedFiles] = useState<File[]>([]);
4040
const [metadataRequestForms, setMetadataRequestForms] = useState({});
4141
const [allFilled, setAllFilled] = React.useState<boolean>(false);
@@ -87,22 +87,22 @@ export const UploadFileDragAndDrop: React.FC<UploadFileDragAndDropProps> = (
8787
};
8888

8989
const onFileInputChange = (event) => {
90-
const fileList : File[] = Array.from(event.target.files);
91-
let newArray = selectedFiles.slice();
92-
fileList.forEach(f => newArray.push(f));
90+
const fileList: File[] = Array.from(event.target.files);
91+
const newArray = selectedFiles.slice();
92+
fileList.forEach((f) => newArray.push(f));
9393
setSelectedFiles(newArray);
9494
};
9595

9696
const onDrop = (fileList) => {
97-
let newFileList : File[] = Array.from(fileList);
98-
let newArray = selectedFiles.slice();
99-
newFileList.forEach(f => newArray.push(f));
97+
const newFileList: File[] = Array.from(fileList);
98+
const newArray = selectedFiles.slice();
99+
newFileList.forEach((f) => newArray.push(f));
100100
setSelectedFiles(newArray);
101101
};
102102

103103
const onDeleteClick = (element) => {
104-
let newFileList : File[] = selectedFiles;
105-
let newArray = newFileList.slice();
104+
const newFileList: File[] = selectedFiles;
105+
const newArray = newFileList.slice();
106106
newArray.pop(element);
107107
setSelectedFiles(newArray);
108108
};
@@ -204,7 +204,7 @@ export const UploadFileDragAndDrop: React.FC<UploadFileDragAndDropProps> = (
204204
Next
205205
</Button>
206206
</Grid>
207-
<Grid xs={1}></Grid>
207+
<Grid xs={1} />
208208
</Grid>
209209
</StepContent>
210210
</Step>

frontend/src/reducers/file.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
CHANGE_SELECTED_VERSION,
23
DOWNLOAD_FILE,
34
RECEIVE_FILE_EXTRACTED_METADATA,
45
RECEIVE_FILE_METADATA_JSONLD,
@@ -7,11 +8,10 @@ import {
78
RECEIVE_PREVIEWS,
89
RECEIVE_VERSIONS,
910
RESET_FILE_PRESIGNED_URL,
10-
CHANGE_SELECTED_VERSION,
1111
} from "../actions/file";
1212
import { DataAction } from "../types/action";
1313
import { FileState } from "../types/data";
14-
import { AuthorizationBase, FileOut as FileSummary } from "../openapi/v2";
14+
import { FileOut as FileSummary } from "../openapi/v2";
1515
import { RECEIVE_FILE_ROLE } from "../actions/authorization";
1616

1717
const defaultState: FileState = {
@@ -20,7 +20,7 @@ const defaultState: FileState = {
2020
metadataJsonld: [],
2121
previews: [],
2222
fileVersions: [],
23-
fileRole: <AuthorizationBase>{},
23+
fileRole: "",
2424
blob: new Blob([]),
2525
presignedUrl: "",
2626
selected_version_num: 1,

0 commit comments

Comments
 (0)