From c650902d57c989fb444cd46f593ea7b0f121d820 Mon Sep 17 00:00:00 2001 From: Dion Date: Tue, 7 Nov 2023 21:24:33 +0100 Subject: [PATCH] code smells --- .../Helpers/WindowsShellTrashBindingHelper.cs | 1 + .../organisms/menu-archive/menu-archive.tsx | 50 +++---- .../menu-detail-view/menu-detail-view.tsx | 54 +++---- .../organisms/menu-search/menu-search.tsx | 12 +- .../organisms/menu-trash/menu-trash.tsx | 8 +- .../modal-archive-mkdir.tsx | 12 +- .../modal-archive-rename.tsx | 12 +- .../modal-detailview-rename-file.tsx | 16 +-- .../modal-display-options.spec.tsx | 19 +-- .../modal-display-options.tsx | 5 +- .../modal-download/modal-download.tsx | 14 +- .../organisms/modal-publish/modal-publish.tsx | 16 ++- .../preferences-app-settings.tsx | 10 +- .../src/containers/account-register.tsx | 4 +- .../clientapp/src/containers/archive.tsx | 2 +- .../src/containers/detailview/detailview.tsx | 14 +- .../clientapp/src/containers/login.tsx | 136 +++++++++--------- .../src/contexts-wrappers/archive-wrapper.tsx | 6 +- .../contexts-wrappers/detailview-wrapper.tsx | 6 +- .../src/contexts/archive-context.tsx | 2 +- .../src/contexts/detailview-context.tsx | 2 +- .../clientapp/src/style/css/10-menu.css | 1 - .../src/style/css/21-archive-folder.css | 8 -- .../src/style/css/26-colorfilter.css | 11 -- .../clientapp/src/style/css/39-select.css | 2 - 25 files changed, 198 insertions(+), 225 deletions(-) diff --git a/starsky/starsky.foundation.native/Trash/Helpers/WindowsShellTrashBindingHelper.cs b/starsky/starsky.foundation.native/Trash/Helpers/WindowsShellTrashBindingHelper.cs index e49c6e6e71..965534e6d2 100644 --- a/starsky/starsky.foundation.native/Trash/Helpers/WindowsShellTrashBindingHelper.cs +++ b/starsky/starsky.foundation.native/Trash/Helpers/WindowsShellTrashBindingHelper.cs @@ -11,6 +11,7 @@ namespace starsky.foundation.native.Trash.Helpers; /// [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("Usage", "S101: Rename struct 'SHFILEOPSTRUCT' to match pascal case naming rules, consider using 'Shfileopstruct'.")] +[SuppressMessage("Usage", "S1075: Refactor your code not to use hardcoded absolute paths or URIs.")] public static class WindowsShellTrashBindingHelper { /// diff --git a/starsky/starsky/clientapp/src/components/organisms/menu-archive/menu-archive.tsx b/starsky/starsky/clientapp/src/components/organisms/menu-archive/menu-archive.tsx index 974c7b0aeb..7ca771daca 100644 --- a/starsky/starsky/clientapp/src/components/organisms/menu-archive/menu-archive.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/menu-archive/menu-archive.tsx @@ -85,8 +85,8 @@ const MenuArchive: React.FunctionComponent = memo(() => { const toggleLabels = () => new Sidebar(setSidebar, history).toggleSidebar(); - const [isModalExportOpen, setModalExportOpen] = useState(false); - const [isModalPublishOpen, setModalPublishOpen] = useState(false); + const [isModalExportOpen, setIsModalExportOpen] = useState(false); + const [isModalPublishOpen, setIsModalPublishOpen] = useState(false); // Selection const [select, setSelect] = React.useState( @@ -96,11 +96,11 @@ const MenuArchive: React.FunctionComponent = memo(() => { setSelect(new URLPath().StringToIUrl(history.location.search).select); }, [history.location.search]); - const [isDisplayOptionsOpen, setDisplayOptionsOpen] = React.useState(false); - const [isSynchronizeManuallyOpen, setSynchronizeManuallyOpen] = + const [isDisplayOptionsOpen, setIsDisplayOptionsOpen] = React.useState(false); + const [isSynchronizeManuallyOpen, setIsSynchronizeManuallyOpen] = React.useState(false); - const [isModalMkdirOpen, setModalMkdirOpen] = React.useState(false); - const [isModalRenameFolder, setModalRenameFolder] = React.useState(false); + const [isModalMkdirOpen, setIsModalMkdirOpen] = React.useState(false); + const [isModalRenameFolder, setIsModalRenameFolder] = React.useState(false); const [dropAreaUploadFilesList, setDropAreaUploadFilesList] = React.useState( newIFileIndexItemArray() ); @@ -134,7 +134,7 @@ const MenuArchive: React.FunctionComponent = memo(() => { {/* Modal download */} {isModalExportOpen ? ( setModalExportOpen(!isModalExportOpen)} + handleExit={() => setIsModalExportOpen(!isModalExportOpen)} select={new URLPath().MergeSelectParent( select, new URLPath().StringToIUrl(history.location.search).f @@ -150,8 +150,7 @@ const MenuArchive: React.FunctionComponent = memo(() => { {/* Modal Display options */} {isDisplayOptionsOpen ? ( setDisplayOptionsOpen(!isDisplayOptionsOpen)} + handleExit={() => setIsDisplayOptionsOpen(!isDisplayOptionsOpen)} isOpen={isDisplayOptionsOpen} /> ) : null} @@ -161,7 +160,7 @@ const MenuArchive: React.FunctionComponent = memo(() => { - setSynchronizeManuallyOpen(!isSynchronizeManuallyOpen) + setIsSynchronizeManuallyOpen(!isSynchronizeManuallyOpen) } isOpen={isSynchronizeManuallyOpen} /> @@ -172,7 +171,7 @@ const MenuArchive: React.FunctionComponent = memo(() => { setModalMkdirOpen(!isModalMkdirOpen)} + handleExit={() => setIsModalMkdirOpen(!isModalMkdirOpen)} isOpen={isModalMkdirOpen} /> ) : null} @@ -182,7 +181,7 @@ const MenuArchive: React.FunctionComponent = memo(() => { subPath={state.subPath} dispatch={dispatch} handleExit={() => { - setModalRenameFolder(!isModalRenameFolder); + setIsModalRenameFolder(!isModalRenameFolder); }} isOpen={isModalRenameFolder} /> @@ -203,7 +202,7 @@ const MenuArchive: React.FunctionComponent = memo(() => { select={select} stateFileIndexItems={state.fileIndexItems} isModalPublishOpen={isModalPublishOpen} - setModalPublishOpen={setModalPublishOpen} + setModalPublishOpen={setIsModalPublishOpen} /> {/* Menu */} @@ -258,9 +257,10 @@ const MenuArchive: React.FunctionComponent = memo(() => { className={!readOnly ? "menu-option" : "menu-option disabled"} data-test="mkdir" tabIndex={0} - onClick={() => setModalMkdirOpen(!isModalMkdirOpen)} + onClick={() => setIsModalMkdirOpen(!isModalMkdirOpen)} onKeyDown={(event) => { - event.key === "Enter" && setModalMkdirOpen(!isModalMkdirOpen); + event.key === "Enter" && + setIsModalMkdirOpen(!isModalMkdirOpen); }} > {MessageMkdir} @@ -269,10 +269,10 @@ const MenuArchive: React.FunctionComponent = memo(() => { className="menu-option" data-test="display-options" tabIndex={0} - onClick={() => setDisplayOptionsOpen(!isDisplayOptionsOpen)} + onClick={() => setIsDisplayOptionsOpen(!isDisplayOptionsOpen)} onKeyDown={(event) => { event.key === "Enter" && - setDisplayOptionsOpen(!isDisplayOptionsOpen); + setIsDisplayOptionsOpen(!isDisplayOptionsOpen); }} > {MessageDisplayOptions} @@ -281,7 +281,7 @@ const MenuArchive: React.FunctionComponent = memo(() => { isReadOnly={false} testName="synchronize-manually" isSet={isSynchronizeManuallyOpen} - set={setSynchronizeManuallyOpen} + set={setIsSynchronizeManuallyOpen} localization={localization.MessageSynchronizeManually} /> {state ? : null} @@ -292,10 +292,10 @@ const MenuArchive: React.FunctionComponent = memo(() => { : "menu-option disabled" } data-test="rename" - onClick={() => setModalRenameFolder(!isModalRenameFolder)} + onClick={() => setIsModalRenameFolder(!isModalRenameFolder)} onKeyDown={(event) => { event.key === "Enter" && - setModalRenameFolder(!isModalRenameFolder); + setIsModalRenameFolder(!isModalRenameFolder); }} > {MessageRenameDir} @@ -334,14 +334,14 @@ const MenuArchive: React.FunctionComponent = memo(() => { isReadOnly={false} testName="export" isSet={isModalExportOpen} - set={setModalExportOpen} + set={setIsModalExportOpen} localization={localization.MessageDownload} /> = memo(() => {
  • setDisplayOptionsOpen(!isDisplayOptionsOpen)} + onClick={() => setIsDisplayOptionsOpen(!isDisplayOptionsOpen)} onKeyDown={(event) => { event.key === "Enter" && - setDisplayOptionsOpen(!isDisplayOptionsOpen); + setIsDisplayOptionsOpen(!isDisplayOptionsOpen); }} > {MessageDisplayOptions} @@ -369,7 +369,7 @@ const MenuArchive: React.FunctionComponent = memo(() => { isReadOnly={false} testName="synchronize-manually" isSet={isSynchronizeManuallyOpen} - set={setSynchronizeManuallyOpen} + set={setIsSynchronizeManuallyOpen} localization={localization.MessageSynchronizeManually} /> {state ? : null} diff --git a/starsky/starsky/clientapp/src/components/organisms/menu-detail-view/menu-detail-view.tsx b/starsky/starsky/clientapp/src/components/organisms/menu-detail-view/menu-detail-view.tsx index f79bd18b15..717c932c00 100644 --- a/starsky/starsky/clientapp/src/components/organisms/menu-detail-view/menu-detail-view.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/menu-detail-view/menu-detail-view.tsx @@ -109,56 +109,56 @@ const MenuDetailView: React.FunctionComponent = ({ }, [history.location.search]); /* show marker with 'Saved' */ - const [isRecentEdited, setRecentEdited] = React.useState( + const [isRecentEdited, setIsRecentEdited] = React.useState( IsEditedNow(state?.fileIndexItem?.lastEdited) ); useEffect(() => { if (!state?.fileIndexItem?.lastEdited) return; const isEditedNow = IsEditedNow(state.fileIndexItem.lastEdited); if (!isEditedNow) { - setRecentEdited(false); + setIsRecentEdited(false); return; } - setRecentEdited(isEditedNow); + setIsRecentEdited(isEditedNow); }, [state?.fileIndexItem?.lastEdited]); function toggleLabels() { const urlObject = new URLPath().StringToIUrl(history.location.search); urlObject.details = !details; setDetails(urlObject.details); - setRecentEdited(false); // disable to avoid animation + setIsRecentEdited(false); // disable to avoid animation history.navigate(new URLPath().IUrlToString(urlObject), { replace: true }); } - const [isMarkedAsDeleted, setMarkedAsDeleted] = React.useState( + const [isMarkedAsDeleted, setIsMarkedAsDeleted] = React.useState( state?.fileIndexItem?.status === IExifStatus.Deleted ); const [enableMoreMenu, setEnableMoreMenu] = React.useState(false); /* only update when the state is changed */ useEffect(() => { - setMarkedAsDeleted(state.fileIndexItem.status === IExifStatus.Deleted); + setIsMarkedAsDeleted(state.fileIndexItem.status === IExifStatus.Deleted); }, [state.fileIndexItem.status, history.location.search]); - const [isSourceMissing, setSourceMissing] = React.useState( + const [isSourceMissing, setIsSourceMissing] = React.useState( state.fileIndexItem.status === IExifStatus.NotFoundSourceMissing ); useEffect(() => { - setSourceMissing( + setIsSourceMissing( state.fileIndexItem.status === IExifStatus.NotFoundSourceMissing ); - setReadOnly( + setIsReadOnly( state.fileIndexItem.status === IExifStatus.NotFoundSourceMissing ); }, [state.fileIndexItem.status, history.location.search]); /* only update when the state is changed */ - const [isReadOnly, setReadOnly] = React.useState(state.isReadOnly); + const [isReadOnly, setIsReadOnly] = React.useState(state.isReadOnly); useEffect(() => { if (state.fileIndexItem.status === IExifStatus.NotFoundSourceMissing) return; - setReadOnly(state.isReadOnly); + setIsReadOnly(state.isReadOnly); }, [state.isReadOnly, state.fileIndexItem.status]); // preloading icon @@ -317,10 +317,11 @@ const MenuDetailView: React.FunctionComponent = ({ TrashFile(); }); - const [isModalExportOpen, setModalExportOpen] = React.useState(false); - const [isModalRenameFileOpen, setModalRenameFileOpen] = React.useState(false); - const [isModalMoveFile, setModalMoveFile] = React.useState(false); - const [isModalPublishOpen, setModalPublishOpen] = useState(false); + const [isModalExportOpen, setIsModalExportOpen] = React.useState(false); + const [isModalRenameFileOpen, setIsModalRenameFileOpen] = + React.useState(false); + const [isModalMoveFile, setIsModalMoveFile] = React.useState(false); + const [isModalPublishOpen, setIsModalPublishOpen] = useState(false); return ( <> @@ -330,7 +331,7 @@ const MenuDetailView: React.FunctionComponent = ({ {isModalExportOpen && state && !isSourceMissing ? ( setModalExportOpen(!isModalExportOpen)} + handleExit={() => setIsModalExportOpen(!isModalExportOpen)} select={[state.subPath]} isOpen={isModalExportOpen} /> @@ -338,7 +339,7 @@ const MenuDetailView: React.FunctionComponent = ({ {isModalRenameFileOpen && state && !isReadOnly ? ( setModalRenameFileOpen(!isModalRenameFileOpen)} + handleExit={() => setIsModalRenameFileOpen(!isModalRenameFileOpen)} isOpen={isModalRenameFileOpen} /> ) : null} @@ -346,7 +347,7 @@ const MenuDetailView: React.FunctionComponent = ({ setModalMoveFile(!isModalMoveFile)} + handleExit={() => setIsModalMoveFile(!isModalMoveFile)} isOpen={isModalMoveFile} /> ) : null} @@ -355,7 +356,7 @@ const MenuDetailView: React.FunctionComponent = ({ select={[state.fileIndexItem.fileName]} stateFileIndexItems={[state.fileIndexItem]} isModalPublishOpen={isModalPublishOpen} - setModalPublishOpen={setModalPublishOpen} + setModalPublishOpen={setIsModalPublishOpen} />
    @@ -419,9 +420,10 @@ const MenuDetailView: React.FunctionComponent = ({ !isSourceMissing ? "menu-option" : "menu-option disabled" } data-test="export" - onClick={() => setModalExportOpen(!isModalExportOpen)} + onClick={() => setIsModalExportOpen(!isModalExportOpen)} onKeyDown={(event) => { - event.key === "Enter" && setModalExportOpen(!isModalExportOpen); + event.key === "Enter" && + setIsModalExportOpen(!isModalExportOpen); }} > Download @@ -443,9 +445,9 @@ const MenuDetailView: React.FunctionComponent = ({ tabIndex={0} className={!isReadOnly ? "menu-option" : "menu-option disabled"} data-test="move" - onClick={() => setModalMoveFile(!isModalMoveFile)} + onClick={() => setIsModalMoveFile(!isModalMoveFile)} onKeyDown={(event) => { - event.key === "Enter" && setModalMoveFile(!isModalMoveFile); + event.key === "Enter" && setIsModalMoveFile(!isModalMoveFile); }} > {MessageMove} @@ -454,10 +456,10 @@ const MenuDetailView: React.FunctionComponent = ({ tabIndex={0} className={!isReadOnly ? "menu-option" : "menu-option disabled"} data-test="rename" - onClick={() => setModalRenameFileOpen(!isModalRenameFileOpen)} + onClick={() => setIsModalRenameFileOpen(!isModalRenameFileOpen)} onKeyDown={(event) => { event.key === "Enter" && - setModalRenameFileOpen(!isModalRenameFileOpen); + setIsModalRenameFileOpen(!isModalRenameFileOpen); }} > {MessageRenameFileName} @@ -501,7 +503,7 @@ const MenuDetailView: React.FunctionComponent = ({ isReadOnly={false} testName="publish" isSet={isModalPublishOpen} - set={setModalPublishOpen} + set={setIsModalPublishOpen} localization={localization.MessagePublish} /> diff --git a/starsky/starsky/clientapp/src/components/organisms/menu-search/menu-search.tsx b/starsky/starsky/clientapp/src/components/organisms/menu-search/menu-search.tsx index b5fac98502..113058a478 100644 --- a/starsky/starsky/clientapp/src/components/organisms/menu-search/menu-search.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/menu-search/menu-search.tsx @@ -76,16 +76,16 @@ export const MenuSearch: React.FunctionComponent = ({ const toggleLabels = () => new Sidebar(setSidebar, history).toggleSidebar(); // download modal - const [isModalExportOpen, setModalExportOpen] = useState(false); + const [isModalExportOpen, setIsModalExportOpen] = useState(false); // publish modal - const [isModalPublishOpen, setModalPublishOpen] = useState(false); + const [isModalPublishOpen, setIsModalPublishOpen] = useState(false); return ( <> {/* Modal download */} {isModalExportOpen ? ( setModalExportOpen(!isModalExportOpen)} + handleExit={() => setIsModalExportOpen(!isModalExportOpen)} select={ select ? new URLPath().MergeSelectFileIndexItem( @@ -103,7 +103,7 @@ export const MenuSearch: React.FunctionComponent = ({ select={select} stateFileIndexItems={state.fileIndexItems} isModalPublishOpen={isModalPublishOpen} - setModalPublishOpen={setModalPublishOpen} + setModalPublishOpen={setIsModalPublishOpen} />
    @@ -195,14 +195,14 @@ export const MenuSearch: React.FunctionComponent = ({ isReadOnly={false} testName="export" isSet={isModalExportOpen} - set={setModalExportOpen} + set={setIsModalExportOpen} localization={localization.MessageDownload} /> = ({ ); } - const [isModalDeleteOpen, setModalDeleteOpen] = React.useState(false); + const [isModalDeleteOpen, setIsModalDeleteOpen] = React.useState(false); return ( <> @@ -117,7 +117,7 @@ const MenuTrash: React.FunctionComponent = ({ select={select} dispatch={dispatch} setIsLoading={setIsLoading} - handleExit={() => setModalDeleteOpen(!isModalDeleteOpen)} + handleExit={() => setIsModalDeleteOpen(!isModalDeleteOpen)} /> ) : null} @@ -214,10 +214,10 @@ const MenuTrash: React.FunctionComponent = ({
  • setModalDeleteOpen(true)} + onClick={() => setIsModalDeleteOpen(true)} tabIndex={0} onKeyDown={(event) => { - event.key === "Enter" && setModalDeleteOpen(true); + event.key === "Enter" && setIsModalDeleteOpen(true); }} > {MessageDeleteImmediately} diff --git a/starsky/starsky/clientapp/src/components/organisms/modal-archive-mkdir/modal-archive-mkdir.tsx b/starsky/starsky/clientapp/src/components/organisms/modal-archive-mkdir/modal-archive-mkdir.tsx index e36728d1bd..44dc8cfed0 100644 --- a/starsky/starsky/clientapp/src/components/organisms/modal-archive-mkdir/modal-archive-mkdir.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/modal-archive-mkdir/modal-archive-mkdir.tsx @@ -51,7 +51,7 @@ const ModalArchiveMkdir: React.FunctionComponent = ({ const [error, setError] = useState(useErrorHandler(null)); // when you are waiting on the API - const [loading, setIsLoading] = useState(false); + const [isLoading, setIsLoading] = useState(false); // The directory name to submit const [directoryName, setDirectoryName] = useState(""); @@ -59,7 +59,7 @@ const ModalArchiveMkdir: React.FunctionComponent = ({ // allow summit const [buttonState, setButtonState] = useState(false); - const [isFormEnabled, setFormEnabled] = useState(true); + const [isFormEnabled, setIsFormEnabled] = useState(true); function handleUpdateChange( event: @@ -88,7 +88,7 @@ const ModalArchiveMkdir: React.FunctionComponent = ({ async function pushRenameChange() { // Show icon with load ++ disable forms - setFormEnabled(false); + setIsFormEnabled(false); setIsLoading(true); const newDirectorySubPath = `${state.subPath}/${directoryName}`; @@ -110,7 +110,7 @@ const ModalArchiveMkdir: React.FunctionComponent = ({ ); // and renewable setIsLoading(false); - setFormEnabled(true); + setIsFormEnabled(true); return; } @@ -160,12 +160,12 @@ const ModalArchiveMkdir: React.FunctionComponent = ({ )} diff --git a/starsky/starsky/clientapp/src/components/organisms/modal-archive-rename/modal-archive-rename.tsx b/starsky/starsky/clientapp/src/components/organisms/modal-archive-rename/modal-archive-rename.tsx index 242eeb196f..a3bf4529fe 100644 --- a/starsky/starsky/clientapp/src/components/organisms/modal-archive-rename/modal-archive-rename.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/modal-archive-rename/modal-archive-rename.tsx @@ -43,14 +43,14 @@ const ModalArchiveRename: React.FunctionComponent = ( const [error, setError] = useState(useErrorHandler(null)); // when you are waiting on the API - const [loading, setIsLoading] = useState(false); + const [isLoading, setIsLoading] = useState(false); // The Updated that is send to the api const [folderName, setFolderName] = useState( new FileExtensions().GetFileName(props.subPath) ); - const [isFormEnabled, setFormEnabled] = useState(true); + const [isFormEnabled, setIsFormEnabled] = useState(true); // to know where you are const history = useLocation(); @@ -94,7 +94,7 @@ const ModalArchiveRename: React.FunctionComponent = ( */ async function pushRenameChange() { // Show icon with load ++ disable forms - setFormEnabled(false); + setIsFormEnabled(false); setIsLoading(true); // subPath style including parent folder @@ -124,7 +124,7 @@ const ModalArchiveRename: React.FunctionComponent = ( setError(MessageGeneralError); // and renewable setIsLoading(false); - setFormEnabled(true); + setIsFormEnabled(true); return; } @@ -175,13 +175,13 @@ const ModalArchiveRename: React.FunctionComponent = ( disabled={ new FileExtensions().GetFileName(props.subPath) === folderName || !!error || - loading + isLoading } data-test="modal-archive-rename-btn-default" className="btn btn--default" onClick={pushRenameChange} > - {loading ? "Loading..." : MessageRenameFolder} + {isLoading ? "Loading..." : MessageRenameFolder} diff --git a/starsky/starsky/clientapp/src/components/organisms/modal-detailview-rename-file/modal-detailview-rename-file.tsx b/starsky/starsky/clientapp/src/components/organisms/modal-detailview-rename-file/modal-detailview-rename-file.tsx index 35e7791dd9..3d9c4f2d66 100644 --- a/starsky/starsky/clientapp/src/components/organisms/modal-detailview-rename-file/modal-detailview-rename-file.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/modal-detailview-rename-file/modal-detailview-rename-file.tsx @@ -54,7 +54,7 @@ const ModalDetailviewRenameFile: React.FunctionComponent< const history = useLocation(); // For the display - const [isFormEnabled, setFormEnabled] = React.useState(true); + const [isFormEnabled, setIsFormEnabled] = React.useState(true); useEffect(() => { if (!state.fileIndexItem.status) return; switch (state.fileIndexItem.status) { @@ -62,10 +62,10 @@ const ModalDetailviewRenameFile: React.FunctionComponent< case IExifStatus.ReadOnly: case IExifStatus.ServerError: case IExifStatus.NotFoundSourceMissing: - setFormEnabled(false); + setIsFormEnabled(false); break; default: - setFormEnabled(true); + setIsFormEnabled(true); break; } }, [state.fileIndexItem.status]); @@ -77,7 +77,7 @@ const ModalDetailviewRenameFile: React.FunctionComponent< const [error, setError] = React.useState(useErrorHandler(null)); // when you are waiting on the API - const [loading, setIsLoading] = React.useState(false); + const [isLoading, setIsLoading] = React.useState(false); // The Updated that is send to the api const [fileName, setFileName] = React.useState(state.fileIndexItem.fileName); @@ -115,7 +115,7 @@ const ModalDetailviewRenameFile: React.FunctionComponent< async function pushRenameChange() { // Show icon with load ++ disable forms - setFormEnabled(false); + setIsFormEnabled(false); setIsLoading(true); const filePathAfterChange = state.fileIndexItem.filePath.replace( @@ -141,7 +141,7 @@ const ModalDetailviewRenameFile: React.FunctionComponent< setError(MessageGeneralError); // and renewable setIsLoading(false); - setFormEnabled(true); + setIsFormEnabled(true); return; } @@ -190,14 +190,14 @@ const ModalDetailviewRenameFile: React.FunctionComponent< disabled={ state.fileIndexItem.fileName === fileName || !isFormEnabled || - loading || + isLoading || !buttonState } data-test="modal-detailview-rename-file-btn-default" className="btn btn--default" onClick={pushRenameChange} > - {loading ? "Loading..." : MessageRenameFileName} + {isLoading ? "Loading..." : MessageRenameFileName} diff --git a/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.spec.tsx b/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.spec.tsx index e6c6b2f36a..07aae396bd 100644 --- a/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.spec.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.spec.tsx @@ -13,7 +13,6 @@ describe("ModalDisplayOptions", () => { render( {}} > ); @@ -24,11 +23,7 @@ describe("ModalDisplayOptions", () => { let modal: RenderResult; beforeEach(() => { modal = render( - {}} - /> + {}} /> ); }); @@ -59,11 +54,7 @@ describe("ModalDisplayOptions", () => { beforeEach(() => { jest.useFakeTimers(); modal = render( - {}} - /> + {}} /> ); }); @@ -168,11 +159,7 @@ describe("ModalDisplayOptions", () => { const handleExitSpy = jest.fn(); const component = render( - + ); expect(handleExitSpy).toBeCalled(); diff --git a/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.tsx b/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.tsx index 14cbc0e007..f80fcb496f 100644 --- a/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/modal-display-options/modal-display-options.tsx @@ -11,7 +11,6 @@ import SwitchButton from "../../atoms/switch-button/switch-button"; interface IModalDisplayOptionsProps { isOpen: boolean; handleExit: Function; - parentFolder?: string; } const ModalDisplayOptions: React.FunctionComponent< @@ -81,12 +80,12 @@ const ModalDisplayOptions: React.FunctionComponent< setIsAlwaysLoadImage(!isAlwaysLoadImage); } - const [isUseSockets, setUseSockets] = React.useState( + const [isUseSockets, setIsUseSockets] = React.useState( localStorage.getItem("use-sockets") === "false" ); function toggleSockets() { - setUseSockets(!isUseSockets); + setIsUseSockets(!isUseSockets); if (isUseSockets) { localStorage.removeItem("use-sockets"); return; diff --git a/starsky/starsky/clientapp/src/components/organisms/modal-download/modal-download.tsx b/starsky/starsky/clientapp/src/components/organisms/modal-download/modal-download.tsx index df5b903867..74c88dbfcc 100644 --- a/starsky/starsky/clientapp/src/components/organisms/modal-download/modal-download.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/modal-download/modal-download.tsx @@ -57,12 +57,14 @@ const ModalDownload: React.FunctionComponent = (props) => { "One moment please" ); - const [isProcessing, setProcessing] = React.useState(ProcessingState.default); + const [isProcessing, setIsProcessing] = React.useState( + ProcessingState.default + ); const [createZipKey, setCreateZipKey] = React.useState(""); async function postZip(isThumbnail: boolean) { if (!props.select) { - setProcessing(ProcessingState.fail); + setIsProcessing(ProcessingState.fail); return; } /* @@ -80,7 +82,7 @@ const ModalDownload: React.FunctionComponent = (props) => { bodyParams.set("json", "true"); bodyParams.set("thumbnail", isThumbnail.toString()); bodyParams.set("collections", props.collections.toString()); - setProcessing(ProcessingState.server); + setIsProcessing(ProcessingState.server); const zipKeyResult = await FetchPost( new UrlQuery().UrlExportPostZipApi(), @@ -88,16 +90,16 @@ const ModalDownload: React.FunctionComponent = (props) => { ); if (zipKeyResult.statusCode !== 200 || !zipKeyResult.data) { - setProcessing(ProcessingState.fail); + setIsProcessing(ProcessingState.fail); return; } setCreateZipKey(zipKeyResult.data); - await ExportIntervalUpdate(zipKeyResult.data, setProcessing); + await ExportIntervalUpdate(zipKeyResult.data, setIsProcessing); } useInterval(async () => { if (isProcessing !== ProcessingState.server) return; - await ExportIntervalUpdate(createZipKey, setProcessing); + await ExportIntervalUpdate(createZipKey, setIsProcessing); }, 3000); const [singleFileThumbnailStatus, setSingleFileThumbnailStatus] = diff --git a/starsky/starsky/clientapp/src/components/organisms/modal-publish/modal-publish.tsx b/starsky/starsky/clientapp/src/components/organisms/modal-publish/modal-publish.tsx index 078e2fd148..894f2f810e 100644 --- a/starsky/starsky/clientapp/src/components/organisms/modal-publish/modal-publish.tsx +++ b/starsky/starsky/clientapp/src/components/organisms/modal-publish/modal-publish.tsx @@ -70,7 +70,9 @@ const ModalPublish: React.FunctionComponent = (props) => { "Profile setting: {publishProfileNames} contains filepath errors" ); - const [isProcessing, setProcessing] = React.useState(ProcessingState.default); + const [isProcessing, setIsProcessing] = React.useState( + ProcessingState.default + ); const [createZipKey, setCreateZipKey] = React.useState(""); const [itemName, setItemName] = React.useState(""); const [existItemName, setExistItemName] = React.useState(false); @@ -80,7 +82,7 @@ const ModalPublish: React.FunctionComponent = (props) => { setExistItemName(false); if (!props.select) { - setProcessing(ProcessingState.fail); + setIsProcessing(ProcessingState.fail); return; } @@ -93,7 +95,7 @@ const ModalPublish: React.FunctionComponent = (props) => { bodyParams.set("publishProfileName", publishProfileName); bodyParams.set("force", "true"); - setProcessing(ProcessingState.server); + setIsProcessing(ProcessingState.server); const zipKeyResult = await FetchPost( new UrlQuery().UrlPublishCreate(), @@ -101,11 +103,11 @@ const ModalPublish: React.FunctionComponent = (props) => { ); if (zipKeyResult.statusCode !== 200 || !zipKeyResult.data) { - setProcessing(ProcessingState.fail); + setIsProcessing(ProcessingState.fail); return; } setCreateZipKey(zipKeyResult.data); - await ExportIntervalUpdate(zipKeyResult.data, setProcessing); + await ExportIntervalUpdate(zipKeyResult.data, setIsProcessing); } const allPublishProfiles = useFetch(new UrlQuery().UrlPublish(), "get") @@ -119,7 +121,7 @@ const ModalPublish: React.FunctionComponent = (props) => { useInterval(async () => { if (isProcessing !== ProcessingState.server) return; - await ExportIntervalUpdate(createZipKey, setProcessing); + await ExportIntervalUpdate(createZipKey, setIsProcessing); }, 9000); function updateItemName(event: React.ChangeEvent) { @@ -225,7 +227,7 @@ const ModalPublish: React.FunctionComponent = (props) => { <> {MessageGenericExportFail}