From 37940a4527b68d5113bec5683692eba287086ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Ctan-nhu=E2=80=9D?= <“tan@harness.io”> Date: Mon, 1 May 2023 16:31:32 -0700 Subject: [PATCH] feat: Not showing confirmation when commit is done successfully --- .../RepositoryFileEdit/FileEditor/FileEditor.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/web/src/pages/RepositoryFileEdit/FileEditor/FileEditor.tsx b/web/src/pages/RepositoryFileEdit/FileEditor/FileEditor.tsx index 4631790a7..b534561fc 100644 --- a/web/src/pages/RepositoryFileEdit/FileEditor/FileEditor.tsx +++ b/web/src/pages/RepositoryFileEdit/FileEditor/FileEditor.tsx @@ -98,10 +98,11 @@ function Editor({ resourceContent, repoMetadata, gitRef, resourcePath, isReposit verifyFolder().then(() => setStartVerifyFolder(true)) }, [fileName, parentPath, language, content, verifyFolder]) const [selectedView, setSelectedView] = useState(VisualYamlSelectedView.VISUAL) - const disabled = useMemo( - () => !fileName || (isUpdate && content === originalContent), - [fileName, isUpdate, content, originalContent] - ) + const [dirty, setDirty] = useState(false) + + useEffect(() => { + setDirty(!(!fileName || (isUpdate && content === originalContent))) + }, [fileName, isUpdate, content, originalContent]) // Calculate file name input field width based on number of characters inside useEffect(() => { @@ -199,7 +200,7 @@ function Editor({ resourceContent, repoMetadata, gitRef, resourcePath, isReposit { + setDirty(false) + if (newBranch) { history.replace( routes.toCODECompare({ @@ -264,7 +267,7 @@ function Editor({ resourceContent, repoMetadata, gitRef, resourcePath, isReposit )} - + ) }