-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui-debug): add unsupported files handling
- Loading branch information
Showing
7 changed files
with
115 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
webapp/src/components/App/Singlestudy/explore/Debug/Data/Image.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
webapp/src/components/App/Singlestudy/explore/Debug/Data/Unsupported.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* Copyright (c) 2024, RTE (https://www.rte-france.com) | ||
* | ||
* See AUTHORS.txt | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
* | ||
* This file is part of the Antares project. | ||
*/ | ||
|
||
import { useTranslation } from "react-i18next"; | ||
import EmptyView from "../../../../../common/page/SimpleContent"; | ||
import BlockIcon from "@mui/icons-material/Block"; | ||
import { Filename, Flex, Menubar } from "./styles"; | ||
import type { DataCompProps } from "../utils"; | ||
import DownloadButton from "@/components/common/buttons/DownloadButton"; | ||
import UploadFileButton from "@/components/common/buttons/UploadFileButton"; | ||
import usePromiseWithSnackbarError from "@/hooks/usePromiseWithSnackbarError"; | ||
import { getStudyData } from "@/services/api/study"; | ||
import { downloadFile } from "@/utils/fileUtils"; | ||
|
||
function Unsupported({ studyId, filePath, filename }: DataCompProps) { | ||
const { t } = useTranslation(); | ||
|
||
const res = usePromiseWithSnackbarError( | ||
() => getStudyData<string>(studyId, filePath), | ||
{ | ||
errorMessage: t("studies.error.retrieveData"), | ||
deps: [studyId, filePath], | ||
}, | ||
); | ||
|
||
//////////////////////////////////////////////////////////////// | ||
// Event Handlers | ||
//////////////////////////////////////////////////////////////// | ||
|
||
const handleDownload = () => { | ||
if (res.data) { | ||
downloadFile( | ||
res.data, | ||
filename.endsWith(".txt") ? filename : `${filename}.txt`, | ||
); | ||
} | ||
}; | ||
|
||
const handleUploadSuccessful = () => { | ||
res.reload(); | ||
}; | ||
|
||
//////////////////////////////////////////////////////////////// | ||
// JSX | ||
//////////////////////////////////////////////////////////////// | ||
|
||
return ( | ||
<Flex> | ||
<Menubar> | ||
<Filename>{filename}</Filename> | ||
<UploadFileButton | ||
studyId={studyId} | ||
path={filePath} | ||
accept={{ "text/plain": [".txt"] }} | ||
onUploadSuccessful={handleUploadSuccessful} | ||
/> | ||
<DownloadButton onClick={handleDownload} /> | ||
</Menubar> | ||
<EmptyView icon={BlockIcon} title={t("study.debug.file.unsupported")} /> | ||
</Flex> | ||
); | ||
} | ||
|
||
export default Unsupported; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters