From 293c5318ec07255b31fb9718ac217337b8d77a5e Mon Sep 17 00:00:00 2001 From: Alex Ramsdell Date: Wed, 5 Jul 2023 11:01:33 -0400 Subject: [PATCH 01/21] hash_values / primary keys can look like uris, so encode hash value as a uriComponent when embedding it in a url and decode it after its been parsed as a url param. --- src/components/instance/browse/BrowseDatatable.js | 8 ++++++-- src/components/instance/browse/JSONEditor.js | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/instance/browse/BrowseDatatable.js b/src/components/instance/browse/BrowseDatatable.js index 89947fe5c..da79a90b9 100644 --- a/src/components/instance/browse/BrowseDatatable.js +++ b/src/components/instance/browse/BrowseDatatable.js @@ -143,10 +143,14 @@ function BrowseDatatable({ tableState, setTableState, activeTable }) { onPageChange={(value) => setTableState({ ...tableState, page: value })} onPageSizeChange={(value) => setTableState({ ...tableState, page: 0, pageSize: value })} onRowClick={(rowData) => { + const hashValue = rowData[tableState.hashAttribute]; - navigate(`/o/${customer_id}/i/${compute_stack_id}/browse/${schema}/${table}/edit/${rowData[tableState.hashAttribute]}`, { + const encodedHash = encodeURIComponent(hashValue); // encode because the hashValue can contain url components + + navigate(`/o/${customer_id}/i/${compute_stack_id}/browse/${schema}/${table}/edit/${encodedHash}`, { state: { hashValue } - }) + }); + }} /> diff --git a/src/components/instance/browse/JSONEditor.js b/src/components/instance/browse/JSONEditor.js index 8774d7d24..02050b8ec 100644 --- a/src/components/instance/browse/JSONEditor.js +++ b/src/components/instance/browse/JSONEditor.js @@ -16,6 +16,7 @@ import ErrorFallback from '../../shared/ErrorFallback'; function JSONEditor({ newEntityAttributes, hashAttribute }) { const { customer_id, schema, table, hash, action, compute_stack_id } = useParams(); + const decodedHash = decodeURIComponent(hash); // hash can have uri components const alert = useAlert(); const { state: locationState } = useLocation(); const navigate = useNavigate(); @@ -72,7 +73,7 @@ function JSONEditor({ newEntityAttributes, hashAttribute }) { } else { // request both integer as string and integer as integer values if it's ambiguous // since we have to guess at the moment. - hash_values = isAmbiguousNumber(hash) ? [ `${hash}`, parseInt(hash, 10) ] : [ hash ]; + hash_values = isAmbiguousNumber(hash) ? [ `${decodedHash}`, parseInt(decodedHash, 10) ] : [ decodedHash ]; // TODO: we support floats, so how to disambiguate 4.0 from '4.0' here? } @@ -189,12 +190,12 @@ function JSONEditor({ newEntityAttributes, hashAttribute }) { useEffect(updateEditorTheme, [theme]); useAsyncEffect(navigateBack, []); - useAsyncEffect(initializeEditorContent, [hash]); + useAsyncEffect(initializeEditorContent, [decodedHash]); return ( addError({ error: { message: error.message, componentStack } })} FallbackComponent={ErrorFallback}> - {schema} {table && '>'} {table} {action === 'add' ? '> add new' : hash ? `> edit > ${hash}` : ''} + {schema} {table && '>'} {table} {action === 'add' ? '> add new' : decodedHash ? `> edit > ${decodedHash}` : ''}   @@ -270,7 +271,7 @@ function JSONEditor({ newEntityAttributes, hashAttribute }) { ) : ( <> - From 0e2735b22b4d8f03ce876ebce479607b9d90615d Mon Sep 17 00:00:00 2001 From: Alex Ramsdell Date: Fri, 7 Jul 2023 10:28:55 -0400 Subject: [PATCH 02/21] expand encode/decode logic from just hash value to table and schema --- .../instance/browse/BrowseDatatable.js | 14 +++++++++----- src/components/instance/browse/JSONEditor.js | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/components/instance/browse/BrowseDatatable.js b/src/components/instance/browse/BrowseDatatable.js index da79a90b9..712e394a4 100644 --- a/src/components/instance/browse/BrowseDatatable.js +++ b/src/components/instance/browse/BrowseDatatable.js @@ -143,13 +143,17 @@ function BrowseDatatable({ tableState, setTableState, activeTable }) { onPageChange={(value) => setTableState({ ...tableState, page: value })} onPageSizeChange={(value) => setTableState({ ...tableState, page: 0, pageSize: value })} onRowClick={(rowData) => { - + + // encode schema, table and hashValue because they can contain uri components const hashValue = rowData[tableState.hashAttribute]; - const encodedHash = encodeURIComponent(hashValue); // encode because the hashValue can contain url components + const encodedSchema = encodeURIComponent(schema); + const encodedTable = encodeURIComponent(table); + const encodedHash = encodeURIComponent(hashValue); + + const url = `/o/${customer_id}/i/${compute_stack_id}/browse/${encodedSchema}/${encodedTable}/edit/${encodedHash}`; + const navigateOptions = { state: { hashValue } }; - navigate(`/o/${customer_id}/i/${compute_stack_id}/browse/${schema}/${table}/edit/${encodedHash}`, { - state: { hashValue } - }); + navigate(url, navigateOptions); }} /> diff --git a/src/components/instance/browse/JSONEditor.js b/src/components/instance/browse/JSONEditor.js index 02050b8ec..c7917d3b8 100644 --- a/src/components/instance/browse/JSONEditor.js +++ b/src/components/instance/browse/JSONEditor.js @@ -15,8 +15,21 @@ import addError from '../../../functions/api/lms/addError'; import ErrorFallback from '../../shared/ErrorFallback'; function JSONEditor({ newEntityAttributes, hashAttribute }) { - const { customer_id, schema, table, hash, action, compute_stack_id } = useParams(); - const decodedHash = decodeURIComponent(hash); // hash can have uri components + + const { + customer_id, + schema: encodedSchema, + table: encodedTable, + hash: encodedHash, + action, + compute_stack_id + } = useParams(); + + // hash, table and schema can have uri components + const schema = decodeURIComponent(encodedSchema); + const table = decodeURIComponent(encodedTable); + const hash = decodeURIComponent(encodedHash); + const alert = useAlert(); const { state: locationState } = useLocation(); const navigate = useNavigate(); From 4ab232af5b85ebf7ecb0597ba27563c1c5fc9175 Mon Sep 17 00:00:00 2001 From: Alex Ramsdell Date: Fri, 7 Jul 2023 10:32:01 -0400 Subject: [PATCH 03/21] rename url to prevent shadowing lint error. --- src/components/instance/browse/BrowseDatatable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/instance/browse/BrowseDatatable.js b/src/components/instance/browse/BrowseDatatable.js index 712e394a4..fd4e70716 100644 --- a/src/components/instance/browse/BrowseDatatable.js +++ b/src/components/instance/browse/BrowseDatatable.js @@ -150,10 +150,10 @@ function BrowseDatatable({ tableState, setTableState, activeTable }) { const encodedTable = encodeURIComponent(table); const encodedHash = encodeURIComponent(hashValue); - const url = `/o/${customer_id}/i/${compute_stack_id}/browse/${encodedSchema}/${encodedTable}/edit/${encodedHash}`; + const recordViewUrl = `/o/${customer_id}/i/${compute_stack_id}/browse/${encodedSchema}/${encodedTable}/edit/${encodedHash}`; const navigateOptions = { state: { hashValue } }; - navigate(url, navigateOptions); + navigate(recordViewUrl, navigateOptions); }} /> From 5133c197352a7e5648c3c5c01e406c1a4e32bc0c Mon Sep 17 00:00:00 2001 From: Alex Ramsdell Date: Fri, 7 Jul 2023 10:32:13 -0400 Subject: [PATCH 04/21] revert decodedHash binding to just 'hash' --- src/components/instance/browse/JSONEditor.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/instance/browse/JSONEditor.js b/src/components/instance/browse/JSONEditor.js index c7917d3b8..1b5249180 100644 --- a/src/components/instance/browse/JSONEditor.js +++ b/src/components/instance/browse/JSONEditor.js @@ -86,7 +86,7 @@ function JSONEditor({ newEntityAttributes, hashAttribute }) { } else { // request both integer as string and integer as integer values if it's ambiguous // since we have to guess at the moment. - hash_values = isAmbiguousNumber(hash) ? [ `${decodedHash}`, parseInt(decodedHash, 10) ] : [ decodedHash ]; + hash_values = isAmbiguousNumber(hash) ? [ `${hash}`, parseInt(hash, 10) ] : [ hash ]; // TODO: we support floats, so how to disambiguate 4.0 from '4.0' here? } @@ -203,12 +203,12 @@ function JSONEditor({ newEntityAttributes, hashAttribute }) { useEffect(updateEditorTheme, [theme]); useAsyncEffect(navigateBack, []); - useAsyncEffect(initializeEditorContent, [decodedHash]); + useAsyncEffect(initializeEditorContent, [hash]); return ( addError({ error: { message: error.message, componentStack } })} FallbackComponent={ErrorFallback}> - {schema} {table && '>'} {table} {action === 'add' ? '> add new' : decodedHash ? `> edit > ${decodedHash}` : ''} + {schema} {table && '>'} {table} {action === 'add' ? '> add new' : hash ? `> edit > ${hash}` : ''}   @@ -284,7 +284,7 @@ function JSONEditor({ newEntityAttributes, hashAttribute }) { ) : ( <> - From 9a4e11a75ea16c3f445d3f229aef156fb7c66b0a Mon Sep 17 00:00:00 2001 From: Alex Ramsdell Date: Mon, 30 Oct 2023 14:22:01 -0400 Subject: [PATCH 05/21] wip: linting styles --- src/assets/styles/components/_web-ide.scss | 56 ++++++++++------------ 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/assets/styles/components/_web-ide.scss b/src/assets/styles/components/_web-ide.scss index 313f90172..b9c8a52b7 100644 --- a/src/assets/styles/components/_web-ide.scss +++ b/src/assets/styles/components/_web-ide.scss @@ -5,7 +5,7 @@ } } - color: white; + color: $color-white; .editor.current-file-path { border-bottom: 1px solid transparent; @@ -13,13 +13,12 @@ .default-window-option { span { - color: white; + color: $color-white; } } .name-input { - .validation-message { color: $color-danger; } @@ -51,7 +50,7 @@ } .file-browser button > span { - color: white !important; + color: $color-white !important; } .file-browser .file.file-selected > span { @@ -68,7 +67,6 @@ } .purple { - button[disabled]:hover, button[disabled] { color: #5e5e5e !important; @@ -76,23 +74,25 @@ .default-window-option span { - color: white !important; + color: $color-white !important; } .editor-window .default-window .default-window-container { background: $color-pureblack !important; - color: white; + color: $color-white; } .no-projects { - color: white; + color: $color-white; .docs-link { color: #ee81ee !important; } } - color: white; + color: $color-white; + + color: rgb(105, 105, 105); .name-input { .name-input-container { @@ -101,9 +101,10 @@ outline-color: #ea4c89 !important; } } + .validation-message { - margin-top: 8px; color: $color-danger; + margin-top: 8px; } & > input.invalid { @@ -125,20 +126,19 @@ .editor-window .cancel-button { color: rgb(105, 105, 105);; } + .editor-window .cancel-button:hover { - color: white; + color: $color-white; } .package-install-window { - background: white; + background: $color-white; } .editor.current-file-path { border-bottom: 1px solid lightgray; } - color: rgb(105, 105, 105); - .default-window-option { span { @@ -199,13 +199,11 @@ .akamai, .light { - .editor-window { border: 1px solid $color-lightergrey; } .name-input { - .validation-message { color: $color-danger; } @@ -230,7 +228,7 @@ color: rgb(105, 105, 105); .package-install-window { - background: white; + background: $color-white; } .editor.current-file-path { @@ -267,7 +265,7 @@ } .editor-window button:hover { - color: white; + color: $color-white; //rgb(105,105,105); } @@ -295,8 +293,6 @@ } .web-ide { - - .cancel-button { margin-left: 10px; } @@ -356,7 +352,7 @@ .add-file-icon { background: transparent; border: none; - color: white; + color: $color-white; margin: 0; outline: none !important; padding: 0; @@ -375,7 +371,7 @@ padding: 20px; .file-menu { - color: white; + color: $color-white; display: flex; flex-direction: row; @@ -506,7 +502,7 @@ .editor-menu { align-items: baseline; border-bottom: 1px solid #2e2e2e; - color: white; + color: $color-white; display: flex; flex-direction: row; justify-content: left; @@ -577,10 +573,10 @@ } .name-input-container { + align-items: center; display: flex; flex-direction: row; - align-items: center; .invalid-project-name { margin-left: 15px; @@ -735,16 +731,16 @@ } .package-install-window { - .install-package-button { - width: 105px; - display: inline-flex; align-items: center; + display: inline-flex; justify-content: center; + width: 105px; .install-package-status-icon { } } + &.github { line-height:0.5em; } @@ -807,8 +803,8 @@ .project-name-invalid-text { color: $color-danger !important; - margin-bottom: 20px; display: block; + margin-bottom: 20px; } @@ -832,11 +828,11 @@ width: 40px; i { - color: white; + color: $color-white; &.not-searching { - color: white; //rgba(0,255,0, 0.1); + color: $color-white; //rgba(0,255,0, 0.1); } From 3e5860a9c87b77a08d830a3105dceebb7ccdb2b3 Mon Sep 17 00:00:00 2001 From: Alex Ramsdell Date: Tue, 31 Oct 2023 10:37:34 -0400 Subject: [PATCH 06/21] store unsaved updates to editor files in local storage by compute_stack_id and filepath. when saved to instance, remove from local storage. --- .../instance/functions/manage/index.js | 49 +++++++++++++++---- src/components/shared/webide/Editor.js | 2 +- src/components/shared/webide/index.js | 26 +++++++--- src/functions/state/editorCache.js | 3 ++ 4 files changed, 62 insertions(+), 18 deletions(-) create mode 100644 src/functions/state/editorCache.js diff --git a/src/components/instance/functions/manage/index.js b/src/components/instance/functions/manage/index.js index 5c5ca5889..ae2c6c364 100644 --- a/src/components/instance/functions/manage/index.js +++ b/src/components/instance/functions/manage/index.js @@ -14,6 +14,7 @@ import deployComponent from '../../../../functions/api/instance/deployComponent' import restartInstance from '../../../../functions/api/instance/restartInstance'; import useInstanceAuth from '../../../../functions/state/instanceAuths'; +import useEditorCache from '../../../../functions/state/editorCache'; import ApplicationsEditor from '../../../shared/webide'; import CustomFunctionsEditor from './CustomFunctionsEditor'; @@ -45,19 +46,19 @@ function getDeployTargets(instanceList, instanceAuthList, thisCsId, auth) { return memo; } - const [ major, minor ] = deployTarget?.version.split('.') || []; + const [ major, minor ] = deployTarget?.version.split('.') || []; // exclude < 4.2 if (parseInt(major, 10) >= 4 && parseInt(minor, 10) >= 2) { - memo.push({ + memo.push({ isCurrentInstance: csId === thisCsId, auth, instance }); - } + } return memo; @@ -69,22 +70,50 @@ function ManageIndex({ refreshCustomFunctions, loading }) { const { compute_stack_id } = useParams(); const registration = useStoreState(instanceState, (s) => s.registration); - const { fileTree } = useStoreState(instanceState, (s) => s.custom_functions); + const { fileTree } = useStoreState(instanceState, (s) => s.custom_functions); const auth = useStoreState(instanceState, (s) => s.auth); const url = useStoreState(instanceState, (s) => s.url); const [majorVersion, minorVersion] = (registration?.version || '').split('.') || []; const supportsApplicationsAPI = parseFloat(`${majorVersion}.${minorVersion}`) >= 4.2; const instances = useStoreState(appState, (s) => s.instances); - const [instanceAuths] = useInstanceAuth({}); + const [ instanceAuths ] = useInstanceAuth({}); + const [ editorCache, setEditorCache ] = useEditorCache({}); const theme = useStoreState(appState, (s) => s.theme); const [ restartingInstance, setRestartingInstance ] = useState(false); const alert = useAlert(); + function removeFileFromLocalStorage({ path }) { + + const updatedCache = {...editorCache}; + const fileKey = `${compute_stack_id}-${path}`; + + if (fileKey in updatedCache) { + console.log('key exists. deleting from: ', updatedCache); + delete updatedCache[fileKey]; + console.log('updatedCache after delete:', updatedCache); + } + + setEditorCache({ + ...updatedCache + }); + } + + function saveFileToLocalStorage({ path, content }) { + + const fileKey = `${compute_stack_id}-${path}`; + + setEditorCache({ + ...editorCache, + [fileKey]: content + }); + + } + async function restartWithLoadingState({ auth: instanceAuth, url: instanceUrl }) { setRestartingInstance(true); - setTimeout(async () => { + setTimeout(async () => { await restartInstance({ auth: instanceAuth, url: instanceUrl }); setRestartingInstance(false); }, 100); @@ -94,7 +123,7 @@ function ManageIndex({ refreshCustomFunctions, loading }) { // save file to instance async function saveCodeToInstance(selectedFile, restartRequired) { - const filepathRelativeToProjectDir = selectedFile.path.split('/').slice(2).join('/'); + const filepathRelativeToProjectDir = selectedFile.path.split('/').slice(2).join('/'); const payload = { auth, url, @@ -109,11 +138,12 @@ function ManageIndex({ refreshCustomFunctions, loading }) { alert.error(message); } - if (restartRequired) { await restartWithLoadingState({ auth, url }); } + removeFileFromLocalStorage({ path: selectedFile.path }); + await refreshCustomFunctions(); } @@ -416,10 +446,11 @@ function ManageIndex({ refreshCustomFunctions, loading }) { return supportsApplicationsAPI ? ( - { @@ -269,7 +271,7 @@ function WebIDE({ ( ( { setSelectedPackage(null); @@ -313,12 +315,12 @@ function WebIDE({ } { @@ -341,7 +343,7 @@ function WebIDE({ /> { @@ -363,7 +365,7 @@ function WebIDE({ } /> { @@ -383,7 +385,15 @@ function WebIDE({ theme={theme} active={ activeEditorWindow === EDITOR_WINDOWS.CODE_EDITOR_WINDOW } file={ selectedFile } - onChange={ updateInMemoryCodeFile } /> + onChange={ + (fileContent) => { + updateInMemoryCodeFile(fileContent); + onChange({ + path: selectedFile.path, + content: fileContent + }); + } + } /> diff --git a/src/functions/state/editorCache.js b/src/functions/state/editorCache.js new file mode 100644 index 000000000..133d74be0 --- /dev/null +++ b/src/functions/state/editorCache.js @@ -0,0 +1,3 @@ +import createPersistedState from 'use-persisted-state'; + +export default createPersistedState('editorCache'); From d004d5695a9a5a72da71c3b443130f2d2918cc26 Mon Sep 17 00:00:00 2001 From: Alex Ramsdell Date: Tue, 31 Oct 2023 10:46:21 -0400 Subject: [PATCH 07/21] add revert file button to editor menu --- src/components/shared/webide/EditorMenu.js | 23 +++++++++++++++++++++- src/components/shared/webide/index.js | 8 +++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/components/shared/webide/EditorMenu.js b/src/components/shared/webide/EditorMenu.js index 3f09991d7..ce64d1e8c 100644 --- a/src/components/shared/webide/EditorMenu.js +++ b/src/components/shared/webide/EditorMenu.js @@ -3,6 +3,24 @@ import React, { useState } from 'react'; import cn from 'classnames'; +export function RevertFileButton({ disabled }) { + return ( + + ); +} + + diff --git a/src/components/shared/webide/index.js b/src/components/shared/webide/index.js index c382bc1c1..4111b8c30 100644 --- a/src/components/shared/webide/index.js +++ b/src/components/shared/webide/index.js @@ -384,8 +384,8 @@ function WebIDE({ active={ activeEditorWindow === EDITOR_WINDOWS.DELETE_FILE_WINDOW } selectedFile={ selectedFile } onConfirm={ - () => { - onDeleteFile(selectedFile); + async () => { + await onDeleteFile(selectedFile); setSelectedFile(null); setSelectedFolder(null); updateActiveEditorWindow(EDITOR_WINDOWS.DEFAULT_WINDOW, activeEditorWindow); diff --git a/src/components/shared/webide/windows/DeleteFileWindow.js b/src/components/shared/webide/windows/DeleteFileWindow.js index 54219e960..ae9b1b693 100644 --- a/src/components/shared/webide/windows/DeleteFileWindow.js +++ b/src/components/shared/webide/windows/DeleteFileWindow.js @@ -1,8 +1,13 @@ -import React from 'react'; +import React, { useState } from 'react'; +import cn from 'classnames'; import { Card, CardTitle, CardBody } from 'reactstrap'; +import { useAlert } from 'react-alert'; +import ButtonWithLoader from '../../ButtonWithLoader'; export default function DeleteFileWindow({ active, selectedFile, onConfirm, onCancel }) { + const [ loading, setLoading ] = useState(false); + if (!active) { return null; } @@ -10,14 +15,24 @@ export default function DeleteFileWindow({ active, selectedFile, onConfirm, onCa const {project} = selectedFile; const filepath = selectedFile.path.split(`/${project}/`)[1]; + return (
Delete Confirmation

Are you sure you want to delete file {filepath} from project { project } ?

- - + + Delete + +
diff --git a/src/components/shared/webide/windows/NameInput.js b/src/components/shared/webide/windows/NameInput.js index 413b86107..6503192e6 100644 --- a/src/components/shared/webide/windows/NameInput.js +++ b/src/components/shared/webide/windows/NameInput.js @@ -6,8 +6,6 @@ import cn from 'classnames'; export default function NameInput({ onCancel, onConfirm, onEnter, label='', placeholder='', value, validate=() => true }) { - - const [ name, setName ] = useState(value || ''); const [ isValidName, setIsValidName ] = useState(false); From 4592f3022e01ed3277ada5e6a539be2371192496 Mon Sep 17 00:00:00 2001 From: Alex Ramsdell Date: Thu, 2 Nov 2023 13:16:27 -0400 Subject: [PATCH 15/21] add disabled prop to button with loader, use in more windows. --- src/components/shared/ButtonWithLoader.js | 3 ++- .../webide/windows/DeleteFolderWindow.js | 7 ++++++- .../webide/windows/DeletePackageWindow.js | 7 ++++++- .../shared/webide/windows/NameInput.js | 20 ++++++++++++------- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/components/shared/ButtonWithLoader.js b/src/components/shared/ButtonWithLoader.js index 8f63e5db4..276cb3946 100644 --- a/src/components/shared/ButtonWithLoader.js +++ b/src/components/shared/ButtonWithLoader.js @@ -1,12 +1,13 @@ import React, { useState } from 'react'; import cn from 'classnames'; -export default function ButtonWithLoader({ text, className, onClick, children }) { +export default function ButtonWithLoader({ className, onClick, disabled, children }) { const [ loading, setLoading ] = useState(false); return ( + + Delete + diff --git a/src/components/shared/webide/windows/DeletePackageWindow.js b/src/components/shared/webide/windows/DeletePackageWindow.js index 6f88ade88..cdec8f499 100644 --- a/src/components/shared/webide/windows/DeletePackageWindow.js +++ b/src/components/shared/webide/windows/DeletePackageWindow.js @@ -1,5 +1,6 @@ import React from 'react'; import { Card, CardTitle, CardBody } from 'reactstrap'; +import ButtonWithLoader from '../../ButtonWithLoader'; export default function DeletePackageWindow({ active, selectedPackage, onConfirm, onCancel }) { @@ -15,7 +16,11 @@ export default function DeletePackageWindow({ active, selectedPackage, onConfirm
Delete Confirmation

Are you sure you want to delete package { packageName } ?

- + + Delete +
diff --git a/src/components/shared/webide/windows/NameInput.js b/src/components/shared/webide/windows/NameInput.js index 6503192e6..a2557af95 100644 --- a/src/components/shared/webide/windows/NameInput.js +++ b/src/components/shared/webide/windows/NameInput.js @@ -3,6 +3,7 @@ import React, { useState } from 'react'; import cn from 'classnames'; +import ButtonWithLoader from '../../ButtonWithLoader'; export default function NameInput({ onCancel, onConfirm, onEnter, label='', placeholder='', value, validate=() => true }) { @@ -59,15 +60,20 @@ export default function NameInput({ onCancel, onConfirm, onEnter, label='', plac
- - + onClick={ + async () => { + await onConfirm(name); + } + }>OK +
); From 15dd3d781a6e722341aae2458ae0bd398397e082 Mon Sep 17 00:00:00 2001 From: Alex Ramsdell Date: Thu, 2 Nov 2023 13:54:36 -0400 Subject: [PATCH 16/21] fix callbacks invoked by ButtonWithLoader --- src/components/instance/functions/index.js | 1 + src/components/shared/webide/index.js | 2 +- src/components/shared/webide/windows/NameInput.js | 9 +++------ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/instance/functions/index.js b/src/components/instance/functions/index.js index 31a4ca24e..729bdcb6e 100644 --- a/src/components/instance/functions/index.js +++ b/src/components/instance/functions/index.js @@ -52,6 +52,7 @@ function CustomFunctionsIndex() { if (configuring) refreshCustomFunctions(); }, 2000); + console.log('cf error: ', custom_functions?.error); return !custom_functions ? ( ) : custom_functions.error ? ( diff --git a/src/components/shared/webide/index.js b/src/components/shared/webide/index.js index 4111b8c30..09d050be6 100644 --- a/src/components/shared/webide/index.js +++ b/src/components/shared/webide/index.js @@ -88,7 +88,7 @@ function WebIDE({ } async function addProjectFolder(newFolderName) { - onAddProjectFolder(newFolderName, selectedFolder) + await onAddProjectFolder(newFolderName, selectedFolder) // go back to prev window updateActiveEditorWindow(previousActiveEditorWindow, activeEditorWindow); } diff --git a/src/components/shared/webide/windows/NameInput.js b/src/components/shared/webide/windows/NameInput.js index a2557af95..a053712d6 100644 --- a/src/components/shared/webide/windows/NameInput.js +++ b/src/components/shared/webide/windows/NameInput.js @@ -35,7 +35,7 @@ export default function NameInput({ onCancel, onConfirm, onEnter, label='', plac
- { label && } + { label && }
0 && !isValidName }) } @@ -63,11 +63,8 @@ export default function NameInput({ onCancel, onConfirm, onEnter, label='', plac { - await onConfirm(name); - } - }>OK + onClick={ () => onConfirm(name) } + >OK