From 35058933906a45f7700eb21f2949642242e4c114 Mon Sep 17 00:00:00 2001 From: somebody1234 Date: Tue, 19 Mar 2024 23:31:33 +1000 Subject: [PATCH] Dashboard fixes (#9467) - Close https://github.com/enso-org/cloud-v2/issues/1037 - Fix downloading files. The issue was that the S3 domain was not whitelisted. - Fix #9345 - Fix https://github.com/enso-org/cloud-v2/issues/1012 - Make "Update" button in assets panel (right panel) disabled until its value is updated. # Important Notes None --- app/ide-desktop/lib/client/src/security.ts | 1 + app/ide-desktop/lib/dashboard/src/App.tsx | 8 ++------ .../src/components/JSONSchemaInput.tsx | 6 +++--- .../dashboard/src/components/SelectionBrush.tsx | 5 ++--- .../dashboard/src/layouts/AssetProperties.tsx | 17 +++++++++++------ .../dashboard/src/layouts/AssetSearchBar.tsx | 4 +--- .../src/layouts/Settings/AccountSettingsTab.tsx | 17 +++++++++-------- .../lib/dashboard/src/utilities/event.ts | 10 ++++++++++ .../dashboard/src/utilities/inputBindings.ts | 6 +++++- 9 files changed, 44 insertions(+), 30 deletions(-) diff --git a/app/ide-desktop/lib/client/src/security.ts b/app/ide-desktop/lib/client/src/security.ts index 3084be1583d..92d30bbfdf3 100644 --- a/app/ide-desktop/lib/client/src/security.ts +++ b/app/ide-desktop/lib/client/src/security.ts @@ -15,6 +15,7 @@ const TRUSTED_HOSTS = [ 'production-enso-domain.auth.eu-west-1.amazoncognito.com', 'production-enso-organizations-files.s3.amazonaws.com', 'pb-enso-domain.auth.eu-west-1.amazoncognito.com', + 's3.eu-west-1.amazonaws.com', // This (`localhost`) is required to access Project Manager HTTP endpoints. // This should be changed appropriately if the Project Manager's port number becomes dynamic. '127.0.0.1:30535', diff --git a/app/ide-desktop/lib/dashboard/src/App.tsx b/app/ide-desktop/lib/dashboard/src/App.tsx index a3117f68a6b..78be6654001 100644 --- a/app/ide-desktop/lib/dashboard/src/App.tsx +++ b/app/ide-desktop/lib/dashboard/src/App.tsx @@ -66,6 +66,7 @@ import Subscribe from '#/pages/subscribe/Subscribe' import type Backend from '#/services/Backend' import LocalBackend from '#/services/LocalBackend' +import * as eventModule from '#/utilities/event' import LocalStorage from '#/utilities/LocalStorage' import * as object from '#/utilities/object' @@ -267,12 +268,7 @@ function AppRouter(props: AppProps) { isClick = true } const onMouseUp = (event: MouseEvent) => { - if ( - isClick && - !(event.target instanceof HTMLInputElement) && - !(event.target instanceof HTMLTextAreaElement) && - !(event.target instanceof HTMLElement && event.target.isContentEditable) - ) { + if (isClick && !eventModule.isElementTextInput(event.target)) { const selection = document.getSelection() const app = document.getElementById('app') const appContainsSelection = diff --git a/app/ide-desktop/lib/dashboard/src/components/JSONSchemaInput.tsx b/app/ide-desktop/lib/dashboard/src/components/JSONSchemaInput.tsx index 9d71f4bd8e5..53b61b610e3 100644 --- a/app/ide-desktop/lib/dashboard/src/components/JSONSchemaInput.tsx +++ b/app/ide-desktop/lib/dashboard/src/components/JSONSchemaInput.tsx @@ -158,7 +158,8 @@ export default function JSONSchemaInput(props: JSONSchemaInputProps) { readOnly={readOnly} checked={typeof value === 'boolean' && value} onChange={event => { - setValue(event.currentTarget.checked) + const newValue: boolean = event.currentTarget.checked + setValue(newValue) }} /> ) @@ -240,7 +241,7 @@ export default function JSONSchemaInput(props: JSONSchemaInputProps) { // This is SAFE; but there is no way to tell TypeScript that an object // has an index signature. // eslint-disable-next-line no-restricted-syntax - (oldValue as Record)[key] === newValue + (oldValue as Readonly>)[key] === newValue ? oldValue : { ...oldValue, [key]: newValue } ) @@ -300,7 +301,6 @@ export default function JSONSchemaInput(props: JSONSchemaInputProps) { setSelectedChildIndex(index) const newConstantValue = jsonSchema.constantValue(defs, childSchema, true) setValue(newConstantValue[0] ?? null) - setSelectedChildIndex(index) }} /> ) diff --git a/app/ide-desktop/lib/dashboard/src/components/SelectionBrush.tsx b/app/ide-desktop/lib/dashboard/src/components/SelectionBrush.tsx index 3c9f4dd3dac..072fdad122f 100644 --- a/app/ide-desktop/lib/dashboard/src/components/SelectionBrush.tsx +++ b/app/ide-desktop/lib/dashboard/src/components/SelectionBrush.tsx @@ -7,6 +7,7 @@ import * as animationHooks from '#/hooks/animationHooks' import * as modalProvider from '#/providers/ModalProvider' +import * as eventModule from '#/utilities/event' import type * as geometry from '#/utilities/geometry' // ====================== @@ -63,9 +64,7 @@ export default function SelectionBrush(props: SelectionBrushProps) { const onMouseDown = (event: MouseEvent) => { if ( modalRef.current == null && - !(event.target instanceof HTMLInputElement) && - !(event.target instanceof HTMLTextAreaElement) && - (!(event.target instanceof HTMLElement) || !event.target.isContentEditable) && + !eventModule.isElementTextInput(event.target) && !(event.target instanceof HTMLButtonElement) && !(event.target instanceof HTMLAnchorElement) ) { diff --git a/app/ide-desktop/lib/dashboard/src/layouts/AssetProperties.tsx b/app/ide-desktop/lib/dashboard/src/layouts/AssetProperties.tsx index 4272889eb79..b6fca831798 100644 --- a/app/ide-desktop/lib/dashboard/src/layouts/AssetProperties.tsx +++ b/app/ide-desktop/lib/dashboard/src/layouts/AssetProperties.tsx @@ -51,7 +51,7 @@ export default function AssetProperties(props: AssetPropertiesProps) { const [description, setDescription] = React.useState('') const [dataLinkValue, setDataLinkValue] = React.useState | null>(null) const [editedDataLinkValue, setEditedDataLinkValue] = React.useState | null>( - null + dataLinkValue ) const [isDataLinkFetched, setIsDataLinkFetched] = React.useState(false) const isDataLinkSubmittable = React.useMemo( @@ -75,6 +75,7 @@ export default function AssetProperties(props: AssetPropertiesProps) { self?.permission === permissions.PermissionAction.admin || self?.permission === permissions.PermissionAction.edit const isDataLink = item.item.type === backendModule.AssetType.dataLink + const isDataLinkDisabled = dataLinkValue === editedDataLinkValue || !isDataLinkSubmittable React.useEffect(() => { setDescription(item.item.description ?? '') @@ -85,7 +86,7 @@ export default function AssetProperties(props: AssetPropertiesProps) { if (item.item.type === backendModule.AssetType.dataLink) { const value = await backend.getConnector(item.item.id, item.item.title) setDataLinkValue(value) - setEditedDataLinkValue(structuredClone(value)) + setEditedDataLinkValue(value) setIsDataLinkFetched(true) } })() @@ -231,8 +232,11 @@ export default function AssetProperties(props: AssetPropertiesProps) {