+ >(preflightResultReducer, preflightResultInit);
return (
{
- }}
+ handleClose={() => {}}
preflightResult={preflightResult}
setPreflightResultDispatch={setPreflightResultDispatch}
- fsItemIdToUpload="1"/>
+ fsItemIdToUpload="1"
+ />
);
diff --git a/src/components/pages/filesytem/upload/UploadDecisionsModalContent.tsx b/src/components/pages/filesytem/upload/UploadDecisionsModalContent.tsx
index 341aa542..961edbba 100644
--- a/src/components/pages/filesytem/upload/UploadDecisionsModalContent.tsx
+++ b/src/components/pages/filesytem/upload/UploadDecisionsModalContent.tsx
@@ -1,226 +1,330 @@
import React, { ReactElement, useState } from "react";
import { Button, Form, ListGroup, Modal, Row, Table } from "react-bootstrap";
import UploadDecisionsTableRow from "./UploadDecisionsTableRow";
-import { EditableFileWithPreflightInfo, EditablePreflightEntityOrFile, PeflightEntiesActionTypes, PREFLIGHT_ADD_ENTITIES, PREFLIGHT_TOGGLE_ALL, PreflightEntity } from "./preflightTypes";
-import { uploadFiles, uploadPreflight } from "../../../../background/api/filesystem";
+import {
+ EditableFileWithPreflightInfo,
+ EditablePreflightEntityOrFile,
+ PeflightEntiesActionTypes,
+ PREFLIGHT_ADD_ENTITIES,
+ PREFLIGHT_TOGGLE_ALL,
+ PreflightEntity
+} from "./preflightTypes";
+import {
+ uploadFiles,
+ uploadPreflight
+} from "../../../../background/api/filesystem";
import { preflightResultCombine } from "./preflightResponseParser";
import { FFLoading } from "../../../basicElements/Loading";
interface Props {
- handleClose: () => void;
- preflightResult: EditablePreflightEntityOrFile[];
- setPreflightResultDispatch: (a: PeflightEntiesActionTypes) => void;
- fsItemIdToUpload: string
+ handleClose: () => void;
+ preflightResult: EditablePreflightEntityOrFile[];
+ setPreflightResultDispatch: (a: PeflightEntiesActionTypes) => void;
+ fsItemIdToUpload: string;
}
export const UploadDecisionsModalContent = ({
- handleClose,
- preflightResult,
- setPreflightResultDispatch,
- fsItemIdToUpload
- }: Props): ReactElement => {
- const [currentPage, setCurrentPage] = useState(0);
- const [showAllFiles, setShowAllFiles] = useState(false)
- const [showAllFolders, setShowAllFolders] = useState(false)
- const [loading, setLoading] = useState(false);
- const nextPage = () => setCurrentPage(currentPage + 1);
- const [selectAllFolders, setSelectAllFolders] = useState(false);
- const [selectAllFiles, setSelectAllFiles] = useState(false);
- const listLimitForFilesAndFolder = 2;
+ handleClose,
+ preflightResult,
+ setPreflightResultDispatch,
+ fsItemIdToUpload
+}: Props): ReactElement => {
+ const [currentPage, setCurrentPage] = useState(0);
+ const [showAllFiles, setShowAllFiles] = useState(false);
+ const [showAllFolders, setShowAllFolders] = useState(false);
+ const [loading, setLoading] = useState(false);
+ const nextPage = () => setCurrentPage(currentPage + 1);
+ const [selectAllFolders, setSelectAllFolders] = useState(false);
+ const [selectAllFiles, setSelectAllFiles] = useState(false);
+ const listLimitForFilesAndFolder = 2;
- const updateSelectAll = (isFolder: boolean) => {
- let newValue;
- if (isFolder) {
- setSelectAllFolders(!selectAllFolders);
- newValue = !selectAllFolders;
- } else {
- setSelectAllFiles(!selectAllFiles);
- newValue = !selectAllFiles;
- }
- setPreflightResultDispatch({
- type: PREFLIGHT_TOGGLE_ALL,
- payload: { isFolders: isFolder, newValue: newValue }
- });
- };
-
- const handleApply = () => {
- setLoading(true);
- uploadPreflight(preflightResult.filter((e: EditablePreflightEntityOrFile) => e.isFile) as EditableFileWithPreflightInfo[], fsItemIdToUpload)
- .then((response: PreflightEntity[]) => {
- const combined = preflightResultCombine(preflightResult, response);
-
- const actionsNeeded = combined.some((e: EditablePreflightEntityOrFile) => !e.permissionIsSufficient || !e.nameIsValid || (e.nameAlreadyInUse && !e.overwrite));
-
- if (actionsNeeded) {
- setPreflightResultDispatch({ type: PREFLIGHT_ADD_ENTITIES, payload: combined });
+ const updateSelectAll = (isFolder: boolean) => {
+ let newValue;
+ if (isFolder) {
+ setSelectAllFolders(!selectAllFolders);
+ newValue = !selectAllFolders;
} else {
- uploadFiles(combined.filter(
- (f: EditablePreflightEntityOrFile) => f.isFile) as EditableFileWithPreflightInfo[], fsItemIdToUpload);
- handleClose();
- setPreflightResultDispatch({ type: PREFLIGHT_ADD_ENTITIES, payload: [] });
+ setSelectAllFiles(!selectAllFiles);
+ newValue = !selectAllFiles;
}
- setLoading(false);
- });
- };
+ setPreflightResultDispatch({
+ type: PREFLIGHT_TOGGLE_ALL,
+ payload: { isFolders: isFolder, newValue: newValue }
+ });
+ };
- const handleOverWriteAll = () => {
- uploadFiles(preflightResult.filter(
- (f: EditablePreflightEntityOrFile) => f.isFile) as EditableFileWithPreflightInfo[], fsItemIdToUpload);
- handleClose();
- setPreflightResultDispatch({ type: PREFLIGHT_ADD_ENTITIES, payload: [] });
- }
+ const handleApply = () => {
+ setLoading(true);
+ uploadPreflight(
+ preflightResult.filter(
+ (e: EditablePreflightEntityOrFile) => e.isFile
+ ) as EditableFileWithPreflightInfo[],
+ fsItemIdToUpload
+ ).then((response: PreflightEntity[]) => {
+ const combined = preflightResultCombine(preflightResult, response);
- const foldersToMerge = preflightResult.filter(
- (f: EditablePreflightEntityOrFile) => !f.isFile && f.nameAlreadyInUse
- );
- const entitiesWithInvalidName = preflightResult.filter(
- (f: EditablePreflightEntityOrFile) => !f.nameIsValid
- );
- const filesToOverwrite = preflightResult.filter(
- (f: EditablePreflightEntityOrFile) => f.isFile && f.nameAlreadyInUse
- );
- const insufficientPermission = preflightResult.filter(
- (f: EditablePreflightEntityOrFile) => !f.permissionIsSufficient
- );
+ const actionsNeeded = combined.some(
+ (e: EditablePreflightEntityOrFile) =>
+ !e.permissionIsSufficient ||
+ !e.nameIsValid ||
+ (e.nameAlreadyInUse && !e.overwrite)
+ );
- const smallFileList = (files: EditablePreflightEntityOrFile[]) => {
- return (
-
- {files.map((f: EditablePreflightEntityOrFile) => (
- {f.path}
- ))}
-
- );
- };
+ if (actionsNeeded) {
+ setPreflightResultDispatch({
+ type: PREFLIGHT_ADD_ENTITIES,
+ payload: combined
+ });
+ } else {
+ uploadFiles(
+ combined.filter(
+ (f: EditablePreflightEntityOrFile) => f.isFile
+ ) as EditableFileWithPreflightInfo[],
+ fsItemIdToUpload
+ );
+ handleClose();
+ setPreflightResultDispatch({
+ type: PREFLIGHT_ADD_ENTITIES,
+ payload: []
+ });
+ }
+ setLoading(false);
+ });
+ };
+
+ const handleOverWriteAll = () => {
+ uploadFiles(
+ preflightResult.filter(
+ (f: EditablePreflightEntityOrFile) => f.isFile
+ ) as EditableFileWithPreflightInfo[],
+ fsItemIdToUpload
+ );
+ handleClose();
+ setPreflightResultDispatch({
+ type: PREFLIGHT_ADD_ENTITIES,
+ payload: []
+ });
+ };
- const changeNamesOrOverwriteTable = (
- files: EditablePreflightEntityOrFile[],
- isFolders: boolean
- ) => {
- return (
-
-
-
- relative Path
- New Name
-
- {isFolders ? "Merge" : "Overwrite"}
-
- updateSelectAll(isFolders)}
- />
-
-
-
-
-
- {files.map((f: EditablePreflightEntityOrFile) => {
- return (
-
- );
- })}
-
-
+ const foldersToMerge = preflightResult.filter(
+ (f: EditablePreflightEntityOrFile) => !f.isFile && f.nameAlreadyInUse
+ );
+ const entitiesWithInvalidName = preflightResult.filter(
+ (f: EditablePreflightEntityOrFile) => !f.nameIsValid
+ );
+ const filesToOverwrite = preflightResult.filter(
+ (f: EditablePreflightEntityOrFile) => f.isFile && f.nameAlreadyInUse
+ );
+ const insufficientPermission = preflightResult.filter(
+ (f: EditablePreflightEntityOrFile) => !f.permissionIsSufficient
);
- };
- if (loading) {
- return ;
- }
+ const smallFileList = (files: EditablePreflightEntityOrFile[]) => {
+ return (
+
+ {files.map((f: EditablePreflightEntityOrFile) => (
+
+ {f.path}{" "}
+
+ ))}
+
+ );
+ };
+ const changeNamesOrOverwriteTable = (
+ files: EditablePreflightEntityOrFile[],
+ isFolders: boolean
+ ) => {
+ return (
+
+
+
+ relative Path
+ New Name
+
+ {isFolders ? "Merge" : "Overwrite"}
+
+ updateSelectAll(isFolders)}
+ />
+
+
+
+
+
+ {files.map((f: EditablePreflightEntityOrFile) => {
+ return (
+
+ );
+ })}
+
+
+ );
+ };
- if (currentPage === 0)
- return (
- <>
-
- Uploading
-
-
- {!!foldersToMerge.length && (
-
- Folders that would be merged:
- {smallFileList(showAllFolders ? foldersToMerge : foldersToMerge.slice(0,listLimitForFilesAndFolder))}
- {(foldersToMerge.length > listLimitForFilesAndFolder && !showAllFolders) && setShowAllFolders(true)}>Show all ({foldersToMerge.length}) }
-
- )}
- {!!filesToOverwrite.length && (
-
- Files that would be overwritten:
- {smallFileList(showAllFiles ? filesToOverwrite: filesToOverwrite.slice(0,listLimitForFilesAndFolder))}
- {(filesToOverwrite.length > listLimitForFilesAndFolder && !showAllFiles )&& setShowAllFiles(true)}>Show all ({filesToOverwrite.length}) }
-
- )}
-
-
- {(!!insufficientPermission.length || !!entitiesWithInvalidName.length) &&
- Some files or folders need to be renamed, because their name is invalid or you have not the permission to overwrite them
}
-
-
- Cancel
-
-
-
- Decide for each one
-
-
- Merge and overwrite
-
-
-
-
- >
- );
- else
- return (
- <>
-
- Merge Folders and overwrite files?
-
-
- {!!foldersToMerge.length && (
-
- Folders that would be merged:
- {changeNamesOrOverwriteTable(foldersToMerge, true)}
-
- )}
- {!!filesToOverwrite.length && (
-
- Files that would be overwritten:
- {changeNamesOrOverwriteTable(filesToOverwrite, false)}
-
- )}
- {(!!entitiesWithInvalidName.length || !!insufficientPermission.length) && (
-
- Files that must be renamed:
- {changeNamesOrOverwriteTable([...entitiesWithInvalidName,...insufficientPermission], false)}
-
- )}
-
-
- All other files will be uploaded with their current name.
-
-
- Abort Upload
-
-
- Upload with new Names
-
-
-
+ if (loading) {
+ return ;
+ }
- >
- );
+ if (currentPage === 0)
+ return (
+ <>
+
+ Uploading
+
+
+ {!!foldersToMerge.length && (
+
+ Folders that would be merged:
+ {smallFileList(
+ showAllFolders
+ ? foldersToMerge
+ : foldersToMerge.slice(
+ 0,
+ listLimitForFilesAndFolder
+ )
+ )}
+ {foldersToMerge.length >
+ listLimitForFilesAndFolder &&
+ !showAllFolders && (
+ setShowAllFolders(true)}
+ >
+ Show all ({foldersToMerge.length}){" "}
+
+ )}
+
+ )}
+ {!!filesToOverwrite.length && (
+
+ Files that would be overwritten:
+ {smallFileList(
+ showAllFiles
+ ? filesToOverwrite
+ : filesToOverwrite.slice(
+ 0,
+ listLimitForFilesAndFolder
+ )
+ )}
+ {filesToOverwrite.length >
+ listLimitForFilesAndFolder &&
+ !showAllFiles && (
+ setShowAllFiles(true)}
+ >
+ Show all ({filesToOverwrite.length}){" "}
+
+ )}
+
+ )}
+
+
+ {(!!insufficientPermission.length ||
+ !!entitiesWithInvalidName.length) && (
+
+ Some files or folders need to be renamed, because
+ their name is invalid or you have not the permission
+ to overwrite them{" "}
+
+ )}
+
+
+ Cancel
+
+
+
+ Decide for each one
+
+
+ Merge and overwrite
+
+
+
+
+ >
+ );
+ else
+ return (
+ <>
+
+
+ Merge Folders and overwrite files?
+
+
+
+ {!!foldersToMerge.length && (
+
+ Folders that would be merged:
+ {changeNamesOrOverwriteTable(foldersToMerge, true)}
+
+ )}
+ {!!filesToOverwrite.length && (
+
+ Files that would be overwritten:
+ {changeNamesOrOverwriteTable(
+ filesToOverwrite,
+ false
+ )}
+
+ )}
+ {(!!entitiesWithInvalidName.length ||
+ !!insufficientPermission.length) && (
+
+ Files that must be renamed:
+ {changeNamesOrOverwriteTable(
+ [
+ ...entitiesWithInvalidName,
+ ...insufficientPermission
+ ],
+ false
+ )}
+
+ )}
+
+
+
+ {" "}
+ All other files will be uploaded with their current
+ name.
+
+
+
+ Abort Upload
+
+
+ Upload with new Names
+
+
+
+ >
+ );
};
diff --git a/src/components/pages/filesytem/upload/UploadDecisionsTableRow.tsx b/src/components/pages/filesytem/upload/UploadDecisionsTableRow.tsx
index 1edc4f47..3b0e19f1 100644
--- a/src/components/pages/filesytem/upload/UploadDecisionsTableRow.tsx
+++ b/src/components/pages/filesytem/upload/UploadDecisionsTableRow.tsx
@@ -1,115 +1,121 @@
import React, { useCallback } from "react";
import { Form } from "react-bootstrap";
import {
- EditablePreflightEntityOrFile,
- PeflightEntiesActionTypes,
- PREFLIGHT_CHANGE_NAME,
- PREFLIGHT_TOGGLE_OVERWRITE,
- PREFLIGHT_UPDATE_NAME,
- PreflightChangeName,
- PreflightToggleOverwrite,
- PreflightUpdateName
+ EditablePreflightEntityOrFile,
+ PeflightEntiesActionTypes,
+ PREFLIGHT_CHANGE_NAME,
+ PREFLIGHT_TOGGLE_OVERWRITE,
+ PREFLIGHT_UPDATE_NAME,
+ PreflightChangeName,
+ PreflightToggleOverwrite,
+ PreflightUpdateName
} from "./preflightTypes";
interface Props {
- preflightEntity: EditablePreflightEntityOrFile;
- setPreflightResultDispatch: (a: PeflightEntiesActionTypes) => void;
+ preflightEntity: EditablePreflightEntityOrFile;
+ setPreflightResultDispatch: (a: PeflightEntiesActionTypes) => void;
}
const UploadDecisionsTableRow = ({
- preflightEntity,
- setPreflightResultDispatch
+ preflightEntity,
+ setPreflightResultDispatch
}: Props) => {
- const onNameChange = useCallback(
- (event: React.ChangeEvent) => {
- let val = event.target.value;
+ const onNameChange = useCallback(
+ (event: React.ChangeEvent) => {
+ let val = event.target.value;
- const change: PreflightChangeName = {
- type: PREFLIGHT_CHANGE_NAME,
- payload: {
- path: preflightEntity.path,
- newName: val
- }
- };
- setPreflightResultDispatch(change);
- },
- [preflightEntity.path, setPreflightResultDispatch]
- );
- const onNameInputLeaver = useCallback(
- (event: React.ChangeEvent) => {
- console.log("onNameInputLeaver");
- let val = event.target.value;
+ const change: PreflightChangeName = {
+ type: PREFLIGHT_CHANGE_NAME,
+ payload: {
+ path: preflightEntity.path,
+ newName: val
+ }
+ };
+ setPreflightResultDispatch(change);
+ },
+ [preflightEntity.path, setPreflightResultDispatch]
+ );
+ const onNameInputLeaver = useCallback(
+ (event: React.ChangeEvent) => {
+ console.log("onNameInputLeaver");
+ let val = event.target.value;
- const change: PreflightUpdateName = {
- type: PREFLIGHT_UPDATE_NAME,
- payload: {
- path: preflightEntity.path,
- newName: val
- }
- };
- setPreflightResultDispatch(change);
- },
- [preflightEntity.path, setPreflightResultDispatch]
- );
- const onSelectedChange = useCallback(() => {
- const change: PreflightToggleOverwrite = {
- type: PREFLIGHT_TOGGLE_OVERWRITE,
- payload: {
- path: preflightEntity.path,
- overwrite: !preflightEntity.overwrite
- }
- };
- setPreflightResultDispatch(change);
- }, [preflightEntity, setPreflightResultDispatch]);
-
- let requiresNameChange =
- (!preflightEntity.nameIsValid ||
- (!preflightEntity.permissionIsSufficient && preflightEntity.overwrite)) &&
- !preflightEntity.newName;
- return (
-
-
- {preflightEntity.overwrite
- ? preflightEntity.path
- : preflightEntity.newPath ?? preflightEntity.path}
-
-
-
-
-
- {preflightEntity.error && (
- {preflightEntity.error}
- )}
- {requiresNameChange && (
- Name must be changed
- )}
-
-
-
- {
+ const change: PreflightToggleOverwrite = {
+ type: PREFLIGHT_TOGGLE_OVERWRITE,
+ payload: {
+ path: preflightEntity.path,
+ overwrite: !preflightEntity.overwrite
}
- type="checkbox"
- checked={preflightEntity.overwrite}
- onChange={onSelectedChange}
- />
-
-
-
- );
+ };
+ setPreflightResultDispatch(change);
+ }, [preflightEntity, setPreflightResultDispatch]);
+
+ let requiresNameChange =
+ (!preflightEntity.nameIsValid ||
+ (!preflightEntity.permissionIsSufficient &&
+ preflightEntity.overwrite)) &&
+ !preflightEntity.newName;
+ return (
+
+
+ {preflightEntity.overwrite
+ ? preflightEntity.path
+ : preflightEntity.newPath ?? preflightEntity.path}
+
+
+
+
+
+ {preflightEntity.error && (
+
+ {preflightEntity.error}
+
+ )}
+ {requiresNameChange && (
+
+ Name must be changed
+
+ )}
+
+
+
+
+
+
+
+ );
};
export default UploadDecisionsTableRow;
diff --git a/src/components/pages/filesytem/upload/preflightTypes.ts b/src/components/pages/filesytem/upload/preflightTypes.ts
index 778da24b..eb28b6da 100644
--- a/src/components/pages/filesytem/upload/preflightTypes.ts
+++ b/src/components/pages/filesytem/upload/preflightTypes.ts
@@ -1,48 +1,48 @@
export interface PreflightEntity {
- name: string;
- path: string;
- permissionIsSufficient: boolean; // can upload and can overwrite
- nameAlreadyInUse: boolean;
- nameIsValid: boolean;
- isFile: boolean;
+ name: string;
+ path: string;
+ permissionIsSufficient: boolean; // can upload and can overwrite
+ nameAlreadyInUse: boolean;
+ nameIsValid: boolean;
+ isFile: boolean;
}
export type EditablePreflightEntityOrFile =
- | EditableFileWithPreflightInfo
- | EditablePreflightEntity;
+ | EditableFileWithPreflightInfo
+ | EditablePreflightEntity;
export interface EditableFileWithPreflightInfo
- extends File,
- EditableEntity,
- PreflightEntity {
- webkitRelativePath?: string;
- readonly name: string;
+ extends File,
+ EditableEntity,
+ PreflightEntity {
+ webkitRelativePath?: string;
+ readonly name: string;
}
export interface EditablePreflightEntity
- extends PreflightEntity,
- EditableEntity {}
+ extends PreflightEntity,
+ EditableEntity {}
interface EditableEntity {
- newName?: string;
- newPath?: string;
- overwrite?: boolean;
- prefNewPath?: string;
- prefNewName?: string;
- error?: EditableEntityError;
+ newName?: string;
+ newPath?: string;
+ overwrite?: boolean;
+ prefNewPath?: string;
+ prefNewName?: string;
+ error?: EditableEntityError;
}
export enum EditableEntityError {
- "ALREADYEXITS" = "Name already exits",
- "INVALIDNAME" = "Name is invalid"
+ "ALREADYEXITS" = "Name already exits",
+ "INVALIDNAME" = "Name is invalid"
}
export type PeflightEntiesActionTypes =
- | PreflightChangeName
- | PreflightToggleOverwrite
- | PreflightUpdateName
- | PreflightToggleAll
- | PreflightAddEntities;
+ | PreflightChangeName
+ | PreflightToggleOverwrite
+ | PreflightUpdateName
+ | PreflightToggleAll
+ | PreflightAddEntities;
export const PREFLIGHT_CHANGE_NAME = "PREFLIGHT_CHANGE_NAME";
export const PREFLIGHT_TOGGLE_OVERWRITE = "PREFLIGHT_TOGGLE_OVERWRITE";
export const PREFLIGHT_UPDATE_NAME = "PREFLIGHT_UPDATE_NAME";
@@ -50,41 +50,41 @@ export const PREFLIGHT_TOGGLE_ALL = "PREFLIGHT_TOGGLE_ALL";
export const PREFLIGHT_ADD_ENTITIES = "PREFLIGHT_ADD_ENTITIES";
export interface PreflightChangeName {
- type: typeof PREFLIGHT_CHANGE_NAME;
- payload: NameChangePayload;
+ type: typeof PREFLIGHT_CHANGE_NAME;
+ payload: NameChangePayload;
}
export interface PreflightToggleOverwrite {
- type: typeof PREFLIGHT_TOGGLE_OVERWRITE;
- payload: OverwriteTogglePayload;
+ type: typeof PREFLIGHT_TOGGLE_OVERWRITE;
+ payload: OverwriteTogglePayload;
}
export interface PreflightUpdateName {
- type: typeof PREFLIGHT_UPDATE_NAME;
- payload: NameChangePayload;
+ type: typeof PREFLIGHT_UPDATE_NAME;
+ payload: NameChangePayload;
}
export interface PreflightToggleAll {
- type: typeof PREFLIGHT_TOGGLE_ALL;
- payload: ToggleAllPayload;
+ type: typeof PREFLIGHT_TOGGLE_ALL;
+ payload: ToggleAllPayload;
}
export interface PreflightAddEntities {
- type: typeof PREFLIGHT_ADD_ENTITIES;
- payload: EditablePreflightEntityOrFile[];
+ type: typeof PREFLIGHT_ADD_ENTITIES;
+ payload: EditablePreflightEntityOrFile[];
}
interface NameChangePayload {
- path: string;
- newName: string;
+ path: string;
+ newName: string;
}
interface OverwriteTogglePayload {
- path: string;
- overwrite: boolean;
+ path: string;
+ overwrite: boolean;
}
interface ToggleAllPayload {
- isFolders: boolean;
- newValue: boolean;
+ isFolders: boolean;
+ newValue: boolean;
}
diff --git a/src/components/pages/health/Health.stories.tsx b/src/components/pages/health/Health.stories.tsx
index 53892d74..d3666f6d 100644
--- a/src/components/pages/health/Health.stories.tsx
+++ b/src/components/pages/health/Health.stories.tsx
@@ -14,10 +14,10 @@ const mock = new MockAdapter(axios);
const API_REQUEST = hostname + "/health";
storiesOf("Health", module).add("default", () => {
- mock.onGet(API_REQUEST).reply(200, healthApiMock);
- return (
-
-
-
- );
+ mock.onGet(API_REQUEST).reply(200, healthApiMock);
+ return (
+
+
+
+ );
});
diff --git a/src/components/pages/health/Health.tsx b/src/components/pages/health/Health.tsx
index ac1802d6..d7d793a0 100644
--- a/src/components/pages/health/Health.tsx
+++ b/src/components/pages/health/Health.tsx
@@ -1,8 +1,15 @@
import React, { useEffect, useState } from "react";
import logo from "../../../assets/images/logos/logo.png";
import { Container, OverlayTrigger, Table, Tooltip } from "react-bootstrap";
-import { callBackendHealth, DataIntegrity, SystemHealthData } from "../../../background/api/api";
-import { audioOnOff, setAudioVolumeByID } from "../../../background/methods/sound";
+import {
+ callBackendHealth,
+ DataIntegrity,
+ SystemHealthData
+} from "../../../background/api/api";
+import {
+ audioOnOff,
+ setAudioVolumeByID
+} from "../../../background/methods/sound";
import { getDurationAsString } from "../../../background/methods/dataTypes/time";
import { hasKey } from "../../../background/methods/dataTypes/objects/ObjectKeysTS";
import { formatBytes } from "../../../background/methods/dataTypes/bytes";
@@ -10,7 +17,9 @@ import { FFLoading } from "../../basicElements/Loading";
import traffic_light from "../../../assets/images/icons/material.io/traffic_light.svg";
export default function Health() {
- const [systemHealthData, setSystemHealthData] = useState("loading");
+ const [systemHealthData, setSystemHealthData] = useState<
+ SystemHealthData | null | "loading"
+ >("loading");
const errorMsg = "not reachable";
useEffect(() => {
@@ -54,55 +63,64 @@ export default function Health() {
-
- System Health
-
+
+ System Health
+
-
- Deployment Type
- {systemHealthData.deployment}
-
-
- Version
- {systemHealthData.version}
-
-
- Uptime
-
- {getDurationAsString(systemHealthData.uptimeInSeconds)}
-
-
-
- Usercount
- {systemHealthData.userCount}
-
-
- Used Storage
- {formatBytes(systemHealthData.usedStorageInBytes)}
-
-
- Data Integrity
-
-
- {systemHealthData.dataIntegrity}
-
- }
- >
-
-
-
-
+
+ Deployment Type
+ {systemHealthData.deployment}
+
+
+ Version
+ {systemHealthData.version}
+
+
+ Uptime
+
+ {getDurationAsString(
+ systemHealthData.uptimeInSeconds
+ )}
+
+
+
+ Usercount
+ {systemHealthData.userCount}
+
+
+ Used Storage
+
+ {formatBytes(
+ systemHealthData.usedStorageInBytes
+ )}
+
+
+
+ Data Integrity
+
+
+ {systemHealthData.dataIntegrity}
+
+ }
+ >
+
+
+
+
diff --git a/src/dev/testUtils/RouterWrapper.tsx b/src/dev/testUtils/RouterWrapper.tsx
index a36e14a9..80fdc15e 100644
--- a/src/dev/testUtils/RouterWrapper.tsx
+++ b/src/dev/testUtils/RouterWrapper.tsx
@@ -3,7 +3,7 @@ import { createMemoryHistory } from "history";
import { Router } from "react-router-dom";
export const RouterWrapper: React.FC = ({ children }) => {
- const history = createMemoryHistory();
+ const history = createMemoryHistory();
- return {children} ;
+ return {children} ;
};
diff --git a/src/index.tsx b/src/index.tsx
index 762cf407..1993fd1b 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,14 +1,14 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import './style/custom.scss';
-import * as serviceWorker from './serviceWorker';
+import React from "react";
+import ReactDOM from "react-dom";
+import "./style/custom.scss";
+import * as serviceWorker from "./serviceWorker";
import Constants from "./components/Constants";
ReactDOM.render(
-
-
- ,
- document.getElementById('root')
+
+
+ ,
+ document.getElementById("root")
);
// If you want your app to work offline and load faster, you can change
diff --git a/src/serviceWorker.ts b/src/serviceWorker.ts
index e461ff58..d518244c 100644
--- a/src/serviceWorker.ts
+++ b/src/serviceWorker.ts
@@ -11,13 +11,13 @@
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
- window.location.hostname === 'localhost' ||
- // [::1] is the IPv6 localhost address.
- window.location.hostname === '[::1]' ||
- // 127.0.0.0/8 are considered localhost for IPv4.
- window.location.hostname.match(
- /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
- )
+ window.location.hostname === "localhost" ||
+ // [::1] is the IPv6 localhost address.
+ window.location.hostname === "[::1]" ||
+ // 127.0.0.0/8 are considered localhost for IPv4.
+ window.location.hostname.match(
+ /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
+ )
);
type Config = {
@@ -26,12 +26,9 @@ type Config = {
};
export function register(config?: Config) {
- if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
+ if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
// The URL constructor is available in all browsers that support SW.
- const publicUrl = new URL(
- process.env.PUBLIC_URL,
- window.location.href
- );
+ const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
@@ -39,7 +36,7 @@ export function register(config?: Config) {
return;
}
- window.addEventListener('load', () => {
+ window.addEventListener("load", () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (!isLocalhost) {
@@ -54,8 +51,8 @@ export function register(config?: Config) {
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
- 'This web app is being served cache-first by a service ' +
- 'worker. To learn more, visit https://bit.ly/CRA-PWA'
+ "This web app is being served cache-first by a service " +
+ "worker. To learn more, visit https://bit.ly/CRA-PWA"
);
});
});
@@ -65,62 +62,62 @@ export function register(config?: Config) {
function registerValidSW(swUrl: string, config?: Config) {
navigator.serviceWorker
.register(swUrl)
- .then(registration => {
+ .then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
- if (installingWorker.state === 'installed') {
+ if (installingWorker.state === "installed") {
if (!navigator.serviceWorker.controller) {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
- console.log('Content is cached for offline use.');
+ console.log("Content is cached for offline use.");
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
- return
+ return;
}
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
- 'New content is available and will be used when all ' +
- 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
+ "New content is available and will be used when all " +
+ "tabs for this page are closed. See https://bit.ly/CRA-PWA."
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
-
}
};
};
})
- .catch(error => {
- console.error('Error during service worker registration:', error);
+ .catch((error) => {
+ console.error("Error during service worker registration:", error);
});
}
function checkValidServiceWorker(swUrl: string, config?: Config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, {
- headers: {'Service-Worker': 'script'}
+ headers: { "Service-Worker": "script" }
})
- .then(response => {
+ .then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
- const contentType = response.headers.get('content-type');
+ const contentType = response.headers.get("content-type");
if (
response.status === 404 ||
- (contentType != null && contentType.indexOf('javascript') === -1)
+ (contentType != null &&
+ contentType.indexOf("javascript") === -1)
) {
// No service worker found. Probably a different app. Reload the page.
- navigator.serviceWorker.ready.then(registration => {
+ navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
@@ -132,18 +129,18 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
})
.catch(() => {
console.log(
- 'No internet connection found. App is running in offline mode.'
+ "No internet connection found. App is running in offline mode."
);
});
}
export function unregister() {
- if ('serviceWorker' in navigator) {
+ if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready
- .then(registration => {
+ .then((registration) => {
registration.unregister();
})
- .catch(error => {
+ .catch((error) => {
console.error(error.message);
});
}
diff --git a/src/setupTests.ts b/src/setupTests.ts
index 74b1a275..5fdf0016 100644
--- a/src/setupTests.ts
+++ b/src/setupTests.ts
@@ -2,4 +2,4 @@
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
-import '@testing-library/jest-dom/extend-expect';
+import "@testing-library/jest-dom/extend-expect";
diff --git a/src/sonar-scanner.js b/src/sonar-scanner.js
index f49af2c4..4eafccd7 100644
--- a/src/sonar-scanner.js
+++ b/src/sonar-scanner.js
@@ -1,16 +1,16 @@
// sorry but this doesnt work in TypeScript pls dont kill me.
-const scanner = require('sonarqube-scanner');
+const scanner = require("sonarqube-scanner");
scanner(
{
- serverUrl: 'https://sonar.filefighter.de',
+ serverUrl: "https://sonar.filefighter.de",
options: {
- 'sonar.projectKey': "de.filefighter.frontend",
- 'sonar.projectName': "Frontend",
- 'sonar.projectDescription': "Frontend for FileFighter",
- 'sonar.login': process.env.SONAR_LOGIN,
- 'sonar.password': process.env.SONAR_PASSWORD
+ "sonar.projectKey": "de.filefighter.frontend",
+ "sonar.projectName": "Frontend",
+ "sonar.projectDescription": "Frontend for FileFighter",
+ "sonar.login": process.env.SONAR_LOGIN,
+ "sonar.password": process.env.SONAR_PASSWORD
}
},
() => process.exit()
-)
+);