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 }) {
) : (
<>
-
}
- Delete
+
+ Delete
+
Cancel
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
+
+ Delete
+
Cancel
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
- {
-
- onConfirm(name);
- }}>ok
- cancel
+ onClick={
+ async () => {
+ await onConfirm(name);
+ }
+ }>OK
+
+ Cancel
+
);
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
Date: Thu, 2 Nov 2023 13:57:24 -0400
Subject: [PATCH 17/21] lint.
---
src/components/instance/functions/index.js | 1 -
src/components/shared/ButtonWithLoader.js | 2 +-
src/components/shared/webide/windows/DeleteFileWindow.js | 4 ----
3 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/src/components/instance/functions/index.js b/src/components/instance/functions/index.js
index 729bdcb6e..31a4ca24e 100644
--- a/src/components/instance/functions/index.js
+++ b/src/components/instance/functions/index.js
@@ -52,7 +52,6 @@ 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/ButtonWithLoader.js b/src/components/shared/ButtonWithLoader.js
index 276cb3946..0fbe714bc 100644
--- a/src/components/shared/ButtonWithLoader.js
+++ b/src/components/shared/ButtonWithLoader.js
@@ -10,7 +10,7 @@ export default function ButtonWithLoader({ className, onClick, disabled, childre
disabled={disabled}
type="button"
onClick={
- async (event) => {
+ async () => {
setLoading(true);
diff --git a/src/components/shared/webide/windows/DeleteFileWindow.js b/src/components/shared/webide/windows/DeleteFileWindow.js
index ae9b1b693..ebec03b17 100644
--- a/src/components/shared/webide/windows/DeleteFileWindow.js
+++ b/src/components/shared/webide/windows/DeleteFileWindow.js
@@ -1,13 +1,9 @@
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;
}
From b44a3e4798012106ac8110d81c5fc93451a63260 Mon Sep 17 00:00:00 2001
From: Alex Ramsdell
Date: Thu, 2 Nov 2023 14:03:53 -0400
Subject: [PATCH 18/21] lint.
---
src/components/shared/webide/windows/DeleteFileWindow.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/shared/webide/windows/DeleteFileWindow.js b/src/components/shared/webide/windows/DeleteFileWindow.js
index ebec03b17..d73f0534e 100644
--- a/src/components/shared/webide/windows/DeleteFileWindow.js
+++ b/src/components/shared/webide/windows/DeleteFileWindow.js
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React from 'react';
import { Card, CardTitle, CardBody } from 'reactstrap';
import ButtonWithLoader from '../../ButtonWithLoader';
From 5467e1cc0983c1994e87184287a547120d6a8cb1 Mon Sep 17 00:00:00 2001
From: Alex Ramsdell
Date: Thu, 2 Nov 2023 14:05:01 -0400
Subject: [PATCH 19/21] lint.
---
src/components/shared/webide/windows/DeleteFileWindow.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/shared/webide/windows/DeleteFileWindow.js b/src/components/shared/webide/windows/DeleteFileWindow.js
index ebec03b17..d73f0534e 100644
--- a/src/components/shared/webide/windows/DeleteFileWindow.js
+++ b/src/components/shared/webide/windows/DeleteFileWindow.js
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React from 'react';
import { Card, CardTitle, CardBody } from 'reactstrap';
import ButtonWithLoader from '../../ButtonWithLoader';
From 5699aaf409618b5fde3ac9bd39c55e9d34e68c1a Mon Sep 17 00:00:00 2001
From: Alex Ramsdell
Date: Thu, 2 Nov 2023 14:24:59 -0400
Subject: [PATCH 20/21] await addProject callback to see loader in confirm
button
---
src/components/shared/webide/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/shared/webide/index.js b/src/components/shared/webide/index.js
index 09d050be6..bba8f80f8 100644
--- a/src/components/shared/webide/index.js
+++ b/src/components/shared/webide/index.js
@@ -83,7 +83,7 @@ function WebIDE({
}
async function addProject(newProjectName) {
- onAddProject(newProjectName);
+ await onAddProject(newProjectName);
updateActiveEditorWindow(previousActiveEditorWindow, activeEditorWindow);
}
From 37a895226964d519c5fd75726335ac25cb7a398b Mon Sep 17 00:00:00 2001
From: Alex Ramsdell
Date: Tue, 7 Nov 2023 11:06:32 -0500
Subject: [PATCH 21/21] v4.3.3.
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 27465f31c..951a0d77d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "harperdb-studio",
- "version": "4.3.2",
+ "version": "4.3.3",
"description": "A UI for HarperDB",
"deploymentUrl": "studio.harperdb.io",
"private": true,