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

feat(ui-debug): update the view #2093

Merged
merged 23 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ce0464f
feat(ui-debug): update the view
skamril Jul 16, 2024
1158076
chore(npm): add 'react-syntax-highlighter' package
skamril Jul 18, 2024
3bf134c
feat(ui-debug): enhance Text component
skamril Aug 1, 2024
af64f24
feat(ui-debug): add icon and a component for images
skamril Aug 1, 2024
2f9d1c5
refactor(ui-commons): update prop in MatrixInput
skamril Aug 6, 2024
f003bba
feat(ui-debug): enhance Matrix component
skamril Aug 6, 2024
3ff8ac6
feat(ui-common): add icon for empty matrix message in MatrixInput
skamril Sep 5, 2024
1f63588
feat(ui-debug): enhance Json component
skamril Sep 5, 2024
a653962
refactor(ui-debug): update data components props
skamril Sep 5, 2024
c71e71a
feat(ui-debug): add Folder component
skamril Sep 6, 2024
d38243a
fix(ui): type issues
skamril Sep 6, 2024
9ead89b
style(ui-common): update SplitView JSDoc
skamril Sep 6, 2024
64601b8
feat(ui-commons): add save feature in JSONEditor component
skamril Sep 10, 2024
7a8426a
feat(ui-commons): update style of SnackErrorMessage component
skamril Sep 10, 2024
d6cd6cb
feat(ui-debug): use save feature from JSONEditor in Json component
skamril Sep 10, 2024
a177ef6
feat(ui-commons): disable SplitButton when `options` are empty
skamril Sep 11, 2024
6c1b3ee
feat(ui-commons): create DownloadButton
skamril Sep 11, 2024
b0664ba
feat(ui-commons): use DownloadButton in DownloadMatrixButton
skamril Sep 11, 2024
ac2a2c4
feat(ui-debug): add export button for json and text files
skamril Sep 12, 2024
82db033
feat(ui-api): update `importFile` function
skamril Sep 15, 2024
5a0946a
feat(ui-commons): create UploadFileButton
skamril Sep 15, 2024
5ed44cb
feat(ui-hooks): create useConfirm hook
skamril Sep 16, 2024
7cebe24
feat(ui-debug): add import and export buttons on data views
skamril Sep 16, 2024
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
5,613 changes: 3,617 additions & 1,996 deletions webapp/package-lock.json

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
"scripts": {
"build": "tsc && vite build",
"clean": "rm -rf dist node_modules/.vite",
"coverage": "vitest run --coverage",
"dev": "vite",
"lint": "tsc --noEmit && eslint . --ext ts,tsx --report-unused-disable-directives",
"preview": "vite preview",
"test": "vitest",
"test:ui": "vitest --ui",
"coverage": "vitest run --coverage"
"test:ui": "vitest --ui"
},
"dependencies": {
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@glideapps/glide-data-grid": "6.0.3",
"@handsontable/react": "14.1.0",
"@mui/icons-material": "5.14.11",
"@mui/lab": "5.0.0-alpha.146",
"@mui/material": "5.14.11",
"@mui/x-date-pickers": "6.18.3",
"@mui/icons-material": "5.16.1",
"@mui/lab": "5.0.0-alpha.172",
"@mui/material": "5.16.1",
"@mui/x-tree-view": "7.10.0",
"@reduxjs/toolkit": "1.9.6",
"axios": "1.5.1",
"clsx": "2.0.0",
Expand Down Expand Up @@ -60,6 +60,7 @@
"react-router": "6.3.0",
"react-router-dom": "6.3.0",
"react-split": "2.0.14",
"react-syntax-highlighter": "15.5.0",
"react-use": "17.4.0",
"react-virtualized-auto-sizer": "1.0.20",
"react-window": "1.8.9",
Expand Down Expand Up @@ -92,6 +93,7 @@
"@types/react-d3-graph": "2.6.5",
"@types/react-dom": "18.2.8",
"@types/react-plotly.js": "2.6.1",
"@types/react-syntax-highlighter": "15.5.13",
"@types/react-virtualized-auto-sizer": "1.0.1",
"@types/react-window": "1.8.6",
"@types/redux-logger": "3.0.10",
Expand Down
6 changes: 5 additions & 1 deletion webapp/public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"global.archive": "Archive",
"global.unarchive": "Unarchive",
"global.export": "Export",
"global.export.error": "Export failed",
"global.filter": "Filter",
"global.apply": "Apply",
"global.change": "Change",
Expand All @@ -34,6 +35,8 @@
"global.import": "Import",
"global.import.fromFile": "From a file",
"global.import.fromDatabase": "From database",
"global.import.success": "Import successful",
"global.import.error": "Import failed",
"global.launch": "Launch",
"global.jobs": "Jobs",
"global.unknown": "Unknown",
Expand All @@ -49,7 +52,6 @@
"global.emptyString": "Empty string",
"global.edit": "Edit",
"global.download": "Download",
"global.download.error": "Download failed",
"global.generate": "Generate",
"global.user": "User",
"global.users": "Users",
Expand Down Expand Up @@ -239,6 +241,8 @@
"study.district": "District",
"study.bindingconstraints": "Binding Constraints",
"study.debug": "Debug",
"study.debug.file.image": "Image file",
"study.debug.folder.empty": "Folder is empty",
"study.failtofetchlogs": "Failed to fetch logs",
"study.failtokilltask": "Failed to kill task",
"study.publicMode": "Public mode",
Expand Down
6 changes: 5 additions & 1 deletion webapp/public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"global.archive": "Archiver",
"global.unarchive": "Désarchiver",
"global.export": "Exporter",
"global.export.error": "L'export a échoué",
"global.filter": "Filtrer",
"global.apply": "Appliquer",
"global.change": "Changer",
Expand All @@ -34,6 +35,8 @@
"global.import": "Importer",
"global.import.fromFile": "Depuis un fichier",
"global.import.fromDatabase": "Depuis la base de donnée",
"global.import.success": "Importation réussie",
"global.import.error": "Échec de l'importation",
"global.launch": "Lancer",
"global.jobs": "Tâches",
"global.unknown": "Inconnu",
Expand All @@ -49,7 +52,6 @@
"global.emptyString": "Chaine de caractères vide",
"global.edit": "Editer",
"global.download": "Télécharger",
"global.download.error": "Le téléchargement a échoué",
"global.generate": "Générer",
"global.user": "Utilisateur",
"global.users": "Utilisateurs",
Expand Down Expand Up @@ -239,6 +241,8 @@
"study.district": "District",
"study.bindingconstraints": "Contraintes Couplantes",
"study.debug": "Debug",
"study.debug.file.image": "Fichier image",
"study.debug.folder.empty": "Le dossier est vide",
"study.failtofetchlogs": "Échec du chargement des logs",
"study.failtokilltask": "Échec de l'annulation de l'étude",
"study.publicMode": "Mode public",
Expand Down
130 changes: 130 additions & 0 deletions webapp/src/components/App/Singlestudy/explore/Debug/Data/Folder.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import {
Divider,
List,
ListItemButton,
ListItemIcon,
ListItemText,
ListSubheader,
} from "@mui/material";
import FolderIcon from "@mui/icons-material/Folder";
import {
getFileIcon,
getFileType,
type TreeFolder,
type DataCompProps,
} from "../utils";
import { Fragment } from "react";
import EmptyView from "../../../../../common/page/SimpleContent";
import { useTranslation } from "react-i18next";
import { Filename, Menubar } from "./styles";
import UploadFileButton from "../../../../../common/buttons/UploadFileButton";
import ConfirmationDialog from "../../../../../common/dialogs/ConfirmationDialog";
import useConfirm from "../../../../../../hooks/useConfirm";

function Folder(props: DataCompProps) {
const {
filename,
filePath,
treeData,
enableImport,
setSelectedFile,
reloadTreeData,
studyId,
} = props;

const { t } = useTranslation();
const replaceFile = useConfirm();
const treeFolder = treeData as TreeFolder;
const list = Object.entries(treeFolder);

////////////////////////////////////////////////////////////////
// Event Handlers
////////////////////////////////////////////////////////////////

const handleValidateUpload = (file: File) => {
if (treeFolder[file.name]) {
return replaceFile.showConfirm();
}
};

////////////////////////////////////////////////////////////////
// JSX
////////////////////////////////////////////////////////////////

return (
<>
<List
subheader={
<ListSubheader>
<Menubar>
<Filename>{filename}</Filename>
{enableImport && (
<UploadFileButton
studyId={studyId}
path={(file) => `${filePath}/${file.name}`}
onUploadSuccessful={reloadTreeData}
validate={handleValidateUpload}
/>
)}
</Menubar>
</ListSubheader>
}
sx={{
height: 1,
overflow: "auto",
// Prevent scroll to display
...(list.length === 0 && {
display: "flex",
flexDirection: "column",
}),
}}
dense
>
{list.length > 0 ? (
list.map(([filename, data], index, arr) => {
const fileType = getFileType(data);
const Icon = getFileIcon(fileType);
const isLast = index === arr.length - 1;

return (
<Fragment key={filename}>
<ListItemButton
onClick={() =>
setSelectedFile({
fileType,
filename,
filePath: `${filePath}/${filename}`,
treeData: data,
})
}
>
<ListItemIcon>
<Icon />
</ListItemIcon>
<ListItemText primary={filename} />
</ListItemButton>
{!isLast && <Divider variant="fullWidth" />}
</Fragment>
);
})
) : (
<EmptyView title={t("study.debug.folder.empty")} icon={FolderIcon} />
)}
</List>
<ConfirmationDialog
title="Replace File?"
confirmButtonText="Replace"
cancelButtonText="Cancel"
maxWidth="xs"
open={replaceFile.isPending}
onConfirm={replaceFile.yes}
onCancel={replaceFile.no}
>
Another file with the same name already exists. Replacing it will
overwrite its content.
</ConfirmationDialog>
</>
);
}

export default Folder;
20 changes: 20 additions & 0 deletions webapp/src/components/App/Singlestudy/explore/Debug/Data/Image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useTranslation } from "react-i18next";
import EmptyView from "../../../../../common/page/SimpleContent";
import ImageIcon from "@mui/icons-material/Image";
import { Filename, Flex, Menubar } from "./styles";
import type { DataCompProps } from "../utils";

function Image({ filename }: DataCompProps) {
const { t } = useTranslation();

return (
<Flex>
<Menubar>
<Filename>{filename}</Filename>
</Menubar>
<EmptyView icon={ImageIcon} title={t("study.debug.file.image")} />
</Flex>
);
}

export default Image;
Loading
Loading