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-results): add button to display 'digest' file in result list #2103

Merged
merged 3 commits into from
Jul 26, 2024
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
3 changes: 2 additions & 1 deletion webapp/public/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"global.error.failedtoretrievejobs": "Failed to retrieve job information",
"global.error.failedtoretrievelogs": "Failed to retrieve job logs",
"global.error.failedtoretrievedownloads": "Failed to retrieve downloads list",
"global.error.fileNotFound": "File not found",
"global.error.create": "Creation failed",
"global.error.delete": "Deletion failed",
"global.area.add": "Add an area",
Expand Down Expand Up @@ -112,7 +113,7 @@
"button.save": "Save",
"button.explore": "Explore",
"button.newCommand": "New command",
"common.nocontent": "No content",
"common.noContent": "No content",
"common.underConstruction": "Page under construction",
"common.dialog.import.dropzoneText": "Drop a file here, or click to select a file",
"common.dialog.import.importSuccess": "File imported successfully",
Expand Down
3 changes: 2 additions & 1 deletion webapp/public/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"global.error.failedtoretrievejobs": "Échec de la récupération des tâches",
"global.error.failedtoretrievelogs": "Échec de la récupération des logs",
"global.error.failedtoretrievedownloads": "Échec de la récupération des exports",
"global.error.fileNotFound": "Fichier introuvable",
"global.error.create": "La création a échoué",
"global.error.delete": "La suppression a échoué",
"global.area.add": "Ajouter une zone",
Expand Down Expand Up @@ -112,7 +113,7 @@
"button.save": "Sauvegarder",
"button.explore": "Explorer",
"button.newCommand": "Nouvelle commande",
"common.nocontent": "Pas de contenu",
"common.noContent": "Pas de contenu",
"common.underConstruction": "Page en construction",
"common.dialog.import.dropzoneText": "Glisser un fichier ici, ou cliquer pour en sélectionner un",
"common.dialog.import.importSuccess": "Fichier importé avec succès",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
} from "../../../../../services/webSockets";
import ConfirmationDialog from "../../../../common/dialogs/ConfirmationDialog";
import CheckBoxFE from "../../../../common/fieldEditors/CheckBoxFE";
import SimpleContent from "../../../../common/page/SimpleContent";
import EmptyView from "../../../../common/page/SimpleContent";

const logError = debug("antares:variantedition:error");

Expand Down Expand Up @@ -118,7 +118,7 @@
}
};

const onDelete = async (index: number) => {

Check warning on line 121 in webapp/src/components/App/Singlestudy/Commands/Edition/index.tsx

View workflow job for this annotation

GitHub Actions / npm-test (ubuntu-20.04)

Async arrow function has no 'await' expression
setOpenDeleteCommandDialog(index);
};

Expand Down Expand Up @@ -506,7 +506,7 @@
loaded && (
<Body sx={{ alignItems: "left" }}>
<Box height="85%">
<SimpleContent title="variants.error.noCommands" />
<EmptyView title="variants.error.noCommands" />
</Box>
</Body>
)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
} from "./style";
import ConfirmationDialog from "../../../../../common/dialogs/ConfirmationDialog";
import LinearProgressWithLabel from "../../../../../common/LinearProgressWithLabel";
import DigestDialog from "./DigestDialog";
import DigestDialog from "../../../../../common/dialogs/DigestDialog";
import type { EmptyObject } from "../../../../../../utils/tsUtils";

export const ColorStatus = {

Check warning on line 36 in webapp/src/components/App/Singlestudy/HomeView/InformationView/LauncherHistory/JobStepper.tsx

View workflow job for this annotation

GitHub Actions / npm-test (ubuntu-20.04)

Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components
running: "warning.main",
pending: "grey.400",
success: "success.main",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
updateScenarioBuilderConfig,
} from "./utils";
import { SubmitHandlerPlus } from "../../../../../../../common/Form/types";
import SimpleContent from "../../../../../../../common/page/SimpleContent";
import EmptyView from "../../../../../../../common/page/SimpleContent";
import useEnqueueErrorSnackbar from "../../../../../../../../hooks/useEnqueueErrorSnackbar";
import { toError } from "../../../../../../../../utils/fnUtils";
import { useOutletContext } from "react-router";
Expand Down Expand Up @@ -53,7 +53,7 @@ function Table({ config, type, areaId }: Props) {
////////////////////////////////////////////////////////////////

if (Object.keys(config).length === 0) {
return <SimpleContent title="No scenario configuration." />;
return <EmptyView title="No scenario configuration." />;
}

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useOutletContext } from "react-router";
import { StudyMetadata } from "../../../../../../common/types";
import SimpleContent from "../../../../../common/page/SimpleContent";
import EmptyView from "../../../../../common/page/SimpleContent";
import AreaPropsView from "./AreaPropsView";
import AreasTab from "./AreasTab";
import useStudySynthesis from "../../../../../../redux/hooks/useStudySynthesis";
Expand Down Expand Up @@ -54,7 +54,7 @@ function Areas() {
renewablesClustering={renewablesClustering !== "aggregated"}
/>
) : (
<SimpleContent title="No areas" />
<EmptyView title="No areas" />
)
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box } from "@mui/material";
import { useOutletContext } from "react-router";
import { StudyMetadata } from "../../../../../../common/types";
import SimpleLoader from "../../../../../common/loaders/SimpleLoader";
import SimpleContent from "../../../../../common/page/SimpleContent";
import EmptyView from "../../../../../common/page/SimpleContent";
import BindingConstPropsView from "./BindingConstPropsView";
import {
getBindingConst,
Expand Down Expand Up @@ -75,12 +75,12 @@ function BindingConstraints() {
{data.length > 0 && currentConstraintId ? (
<BindingConstView constraintId={currentConstraintId} />
) : (
<SimpleContent title="No Binding Constraints" />
<EmptyView title="No Binding Constraints" />
)}
</Box>
</SplitView>
)}
ifRejected={(error) => <SimpleContent title={error?.toString()} />}
ifRejected={(error) => <EmptyView title={error?.toString()} />}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useOutletContext } from "react-router";
import { StudyMetadata } from "../../../../../../common/types";
import SimpleContent from "../../../../../common/page/SimpleContent";
import EmptyView from "../../../../../common/page/SimpleContent";
import LinkPropsView from "./LinkPropsView";
import useStudySynthesis from "../../../../../../redux/hooks/useStudySynthesis";
import { getCurrentLink } from "../../../../../../redux/selectors";
Expand Down Expand Up @@ -44,7 +44,7 @@ function Links() {
currentLink ? (
<LinkView link={currentLink} />
) : (
<SimpleContent title="No Links" />
<EmptyView title="No Links" />
)
}
/>
Expand Down
100 changes: 70 additions & 30 deletions webapp/src/components/App/Singlestudy/explore/Results/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import ArchiveIcon from "@mui/icons-material/Archive";
import UnarchiveIcon from "@mui/icons-material/Unarchive";
import DownloadIcon from "@mui/icons-material/Download";
import DeleteForeverIcon from "@mui/icons-material/DeleteForever";
import EqualizerIcon from "@mui/icons-material/Equalizer";
import * as R from "ramda";
import { useNavigate, useOutletContext } from "react-router-dom";
import { grey } from "@mui/material/colors";
Expand All @@ -43,6 +44,8 @@ import { convertUTCToLocalTime } from "../../../../../services/utils";
import LaunchJobLogView from "../../../Tasks/LaunchJobLogView";
import useEnqueueErrorSnackbar from "../../../../../hooks/useEnqueueErrorSnackbar";
import ConfirmationDialog from "../../../../common/dialogs/ConfirmationDialog";
import type { EmptyObject } from "../../../../../utils/tsUtils";
import DigestDialog from "../../../../common/dialogs/DigestDialog";

interface OutputDetail {
name: string;
Expand All @@ -53,6 +56,17 @@ interface OutputDetail {
archived?: boolean;
}

type DialogState =
| {
type: "confirmDelete";
data: string;
}
| {
type: "digest";
data: LaunchJob;
}
| EmptyObject;

const combineJobsAndOutputs = (
jobs: LaunchJob[],
outputs: StudyOutput[],
Expand Down Expand Up @@ -90,12 +104,19 @@ const combineJobsAndOutputs = (
return runningJobs.concat(outputDetails);
};

const iconStyle = {
fontSize: 22,
color: "action.active",
cursor: "pointer",
"&:hover": { color: "action.hover" },
};

function Results() {
const { study } = useOutletContext<{ study: StudyMetadata }>();
const { t } = useTranslation();
const navigate = useNavigate();
const enqueueErrorSnackbar = useEnqueueErrorSnackbar();
const [outputToDelete, setOutputToDelete] = useState<string>();
const [dialogState, setDialogState] = useState<DialogState>({});

const { data: studyJobs, isLoading: studyJobsLoading } =
usePromiseWithSnackbarError(() => getStudyJobs(study.id), {
Expand Down Expand Up @@ -150,12 +171,7 @@ function Results() {
<Box sx={{ height: "24px", margin: 0.5 }}>
<Tooltip title={t(title) as string}>
<Component
sx={{
fontSize: 22,
color: "action.active",
cursor: "pointer",
"&:hover": { color: "action.hover" },
}}
sx={iconStyle}
onClick={async () => {
handler().catch((e) => {
enqueueErrorSnackbar(
Expand All @@ -170,6 +186,12 @@ function Results() {
);
};

////////////////////////////////////////////////////////////////
// Utils
////////////////////////////////////////////////////////////////

const closeDialog = () => setDialogState({});

////////////////////////////////////////////////////////////////
// Event Handlers
////////////////////////////////////////////////////////////////
Expand All @@ -180,12 +202,10 @@ function Results() {
});
};

const handleDeleteOutput = async () => {
if (outputToDelete) {
await deleteOutput(study.id, outputToDelete);
setOutputToDelete(undefined);
reloadOutputs();
}
const handleDeleteOutput = async (outputName: string) => {
closeDialog();
await deleteOutput(study.id, outputName);
reloadOutputs();
};

////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -350,12 +370,7 @@ function Results() {
<Box sx={{ height: "24px", margin: 0.5 }}>
<Tooltip title={t("global.download") as string}>
<DownloadIcon
sx={{
fontSize: 22,
color: "action.active",
cursor: "pointer",
"&:hover": { color: "action.hover" },
}}
sx={iconStyle}
onClick={() => {
if (row.job) {
downloadJobOutput(row.job.id);
Expand All @@ -365,24 +380,39 @@ function Results() {
</Tooltip>
</Box>
)}

{row.job && (
<LaunchJobLogView
job={row.job}
logButton
logErrorButton
/>
)}
{row.job?.status === "success" && (
<Tooltip title="Digest">
<EqualizerIcon
onClick={() => {
setDialogState({
type: "digest",
data: row.job as LaunchJob,
});
}}
sx={iconStyle}
/>
</Tooltip>
)}
<Box sx={{ height: "24px", margin: 0.5 }}>
<Tooltip title={t("global.delete") as string}>
<DeleteForeverIcon
sx={{
fontSize: 22,
color: "action.active",
cursor: "pointer",
...iconStyle,
"&:hover": { color: "error.light" },
}}
onClick={() => {
setOutputToDelete(row.name);
setDialogState({
type: "confirmDelete",
data: row.name,
});
}}
/>
</Tooltip>
Expand Down Expand Up @@ -420,13 +450,23 @@ function Results() {
</TableBody>
</Table>
</TableContainer>
<ConfirmationDialog
open={!!outputToDelete}
onConfirm={handleDeleteOutput}
onCancel={() => setOutputToDelete(undefined)}
>
{t("results.question.deleteOutput", { outputname: outputToDelete })}
</ConfirmationDialog>
{dialogState.type === "confirmDelete" && (
<ConfirmationDialog
open
onConfirm={() => handleDeleteOutput(dialogState.data)}
onCancel={closeDialog}
>
{t("results.question.deleteOutput", { outputname: dialogState.data })}
</ConfirmationDialog>
)}
{dialogState.type === "digest" && (
<DigestDialog
open
studyId={dialogState.data.studyId}
outputId={dialogState.data.outputId}
onOk={closeDialog}
/>
)}
</Box>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import CreateCandidateDialog from "./CreateCandidateDialog";
import CandidateForm from "./CandidateForm";
import usePromiseWithSnackbarError from "../../../../../../hooks/usePromiseWithSnackbarError";
import DataViewerDialog from "../../../../../common/dialogs/DataViewerDialog";
import SimpleContent from "../../../../../common/page/SimpleContent";
import EmptyView from "../../../../../common/page/SimpleContent";
import SplitView from "../../../../../common/SplitView";

function Candidates() {
Expand Down Expand Up @@ -210,7 +210,7 @@ function Candidates() {
};

if (isRejected) {
return <SimpleContent title={t("xpansion.error.loadConfiguration")} />;
return <EmptyView title={t("xpansion.error.loadConfiguration")} />;
}

return (
Expand Down
Loading
Loading