From 3a010a00a75f1329d473b9bc028c8a08e54d9b32 Mon Sep 17 00:00:00 2001 From: somebody1234 Date: Mon, 2 Oct 2023 20:52:26 +1000 Subject: [PATCH] Implement connector button and context menu action. (#7891) - Closes https://github.com/enso-org/cloud-v2/issues/686 # Important Notes For now they use the backend endpoints for secrets. --- app/ide-desktop/lib/assets/connector.svg | 5 + app/ide-desktop/lib/assets/secret.svg | 5 - .../dashboard/components/assetNameColumn.tsx | 4 +- .../src/dashboard/components/assetRow.tsx | 2 +- .../src/dashboard/components/assetsTable.tsx | 4 +- .../components/confirmDeleteModal.tsx | 16 +-- ...NameColumn.tsx => connectorNameColumn.tsx} | 25 ++-- .../components/directoryNameColumn.tsx | 2 +- .../src/dashboard/components/drive.tsx | 14 +++ .../src/dashboard/components/driveBar.tsx | 21 +++- .../dashboard/components/fileNameColumn.tsx | 2 +- .../components/globalContextMenu.tsx | 19 +++- .../src/dashboard/components/input.tsx | 2 +- .../components/newDataConnectorModal.tsx | 107 ++++++++++++++++++ .../src/dashboard/components/projectIcon.tsx | 2 +- .../components/projectNameColumn.tsx | 2 +- .../src/dashboard/events/assetEvent.ts | 9 +- .../src/dashboard/events/assetListEvent.ts | 9 +- 18 files changed, 197 insertions(+), 53 deletions(-) create mode 100644 app/ide-desktop/lib/assets/connector.svg delete mode 100644 app/ide-desktop/lib/assets/secret.svg rename app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/{secretNameColumn.tsx => connectorNameColumn.tsx} (88%) create mode 100644 app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/newDataConnectorModal.tsx diff --git a/app/ide-desktop/lib/assets/connector.svg b/app/ide-desktop/lib/assets/connector.svg new file mode 100644 index 000000000000..ce56723a8c8f --- /dev/null +++ b/app/ide-desktop/lib/assets/connector.svg @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/app/ide-desktop/lib/assets/secret.svg b/app/ide-desktop/lib/assets/secret.svg deleted file mode 100644 index d77454027db6..000000000000 --- a/app/ide-desktop/lib/assets/secret.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetNameColumn.tsx b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetNameColumn.tsx index 14e20521fa60..3ec16fffda79 100644 --- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetNameColumn.tsx +++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetNameColumn.tsx @@ -4,10 +4,10 @@ import * as React from 'react' import * as backendModule from '../backend' import * as column from '../column' +import ConnectorNameColumn from './connectorNameColumn' import DirectoryNameColumn from './directoryNameColumn' import FileNameColumn from './fileNameColumn' import ProjectNameColumn from './projectNameColumn' -import SecretNameColumn from './secretNameColumn' // ================= // === AssetName === @@ -30,7 +30,7 @@ export default function AssetNameColumn(props: AssetNameColumnProps) { return } case backendModule.AssetType.secret: { - return + return } case backendModule.AssetType.specialLoading: case backendModule.AssetType.specialEmpty: { diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetRow.tsx b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetRow.tsx index d72a94485b6d..65a2cebd4a68 100644 --- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetRow.tsx +++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetRow.tsx @@ -147,7 +147,7 @@ export default function AssetRow(props: AssetRowProps) { case assetEventModule.AssetEventType.newProject: case assetEventModule.AssetEventType.newFolder: case assetEventModule.AssetEventType.uploadFiles: - case assetEventModule.AssetEventType.newSecret: + case assetEventModule.AssetEventType.newDataConnector: case assetEventModule.AssetEventType.openProject: case assetEventModule.AssetEventType.closeProject: case assetEventModule.AssetEventType.cancelOpeningAllProjects: { diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetsTable.tsx b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetsTable.tsx index 01b3a55bcdab..b1a7b9a526de 100644 --- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetsTable.tsx +++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/assetsTable.tsx @@ -816,7 +816,7 @@ export default function AssetsTable(props: AssetsTableProps) { }) break } - case assetListEventModule.AssetListEventType.newSecret: { + case assetListEventModule.AssetListEventType.newDataConnector: { const placeholderItem: backendModule.SecretAsset = { id: backendModule.SecretId(uniqueString.uniqueString()), title: event.name, @@ -854,7 +854,7 @@ export default function AssetsTable(props: AssetsTableProps) { ) ) dispatchAssetEvent({ - type: assetEventModule.AssetEventType.newSecret, + type: assetEventModule.AssetEventType.newDataConnector, placeholderId: placeholderItem.id, value: event.value, }) diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/confirmDeleteModal.tsx b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/confirmDeleteModal.tsx index 1161b3cecb2f..ee7e641650de 100644 --- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/confirmDeleteModal.tsx +++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/confirmDeleteModal.tsx @@ -8,9 +8,9 @@ import * as modalProvider from '../../providers/modal' import Modal from './modal' -// ================= -// === Component === -// ================= +// ========================== +// === ConfirmDeleteModal === +// ========================== /** Props for a {@link ConfirmDeleteModal}. */ export interface ConfirmDeleteModalProps { @@ -61,19 +61,19 @@ export default function ConfirmDeleteModal(props: ConfirmDeleteModalProps) { // delete an important asset. onSubmit() }} - className="relative shadow-soft rounded-2xl w-96 px-4 py-2" + className="relative flex flex-col rounded-2xl gap-2 w-96 px-4 p-2" > -
Are you sure you want to delete {description}?
-
+
Are you sure you want to delete {description}?
+
diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/driveBar.tsx b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/driveBar.tsx index 72a40e0a4372..0fb4539e4bc7 100644 --- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/driveBar.tsx +++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/driveBar.tsx @@ -16,6 +16,7 @@ import * as shortcutsProvider from '../../providers/shortcuts' import * as categorySwitcher from './categorySwitcher' import Button from './button' +import NewDataConnectorModal from './newDataConnectorModal' // ================ // === DriveBar === @@ -26,6 +27,7 @@ export interface DriveBarProps { category: categorySwitcher.Category doCreateProject: (templateId: string | null) => void doCreateDirectory: () => void + doCreateDataConnector: (name: string, value: string) => void doUploadFiles: (files: File[]) => void dispatchAssetEvent: (event: assetEventModule.AssetEvent) => void } @@ -33,10 +35,16 @@ export interface DriveBarProps { /** Displays the current directory path and permissions, upload and download buttons, * and a column display mode switcher. */ export default function DriveBar(props: DriveBarProps) { - const { category, doCreateProject, doCreateDirectory, doUploadFiles, dispatchAssetEvent } = - props + const { + category, + doCreateProject, + doCreateDirectory, + doCreateDataConnector, + doUploadFiles, + dispatchAssetEvent, + } = props const { backend } = backendProvider.useBackend() - const { unsetModal } = modalProvider.useSetModal() + const { setModal, unsetModal } = modalProvider.useSetModal() const { shortcuts } = shortcutsProvider.useShortcuts() const uploadFilesRef = React.useRef(null) @@ -98,7 +106,7 @@ export default function DriveBar(props: DriveBarProps) { )} {backend.type !== backendModule.BackendType.local && ( + +
+ + + + ) +} diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/projectIcon.tsx b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/projectIcon.tsx index 1bf676595829..2d41048c597c 100644 --- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/projectIcon.tsx +++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/projectIcon.tsx @@ -239,7 +239,7 @@ export default function ProjectIcon(props: ProjectIconProps) { switch (event.type) { case assetEventModule.AssetEventType.newFolder: case assetEventModule.AssetEventType.uploadFiles: - case assetEventModule.AssetEventType.newSecret: + case assetEventModule.AssetEventType.newDataConnector: case assetEventModule.AssetEventType.deleteMultiple: case assetEventModule.AssetEventType.restoreMultiple: case assetEventModule.AssetEventType.downloadSelected: diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/projectNameColumn.tsx b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/projectNameColumn.tsx index 40df08070f7b..b9e4712ded37 100644 --- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/projectNameColumn.tsx +++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/components/projectNameColumn.tsx @@ -99,7 +99,7 @@ export default function ProjectNameColumn(props: ProjectNameColumnProps) { hooks.useEventHandler(assetEvents, async event => { switch (event.type) { case assetEventModule.AssetEventType.newFolder: - case assetEventModule.AssetEventType.newSecret: + case assetEventModule.AssetEventType.newDataConnector: case assetEventModule.AssetEventType.openProject: case assetEventModule.AssetEventType.closeProject: case assetEventModule.AssetEventType.cancelOpeningAllProjects: diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/events/assetEvent.ts b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/events/assetEvent.ts index 7bcde6be5633..c8e261aa3126 100644 --- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/events/assetEvent.ts +++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/events/assetEvent.ts @@ -21,7 +21,7 @@ export enum AssetEventType { newProject = 'new-project', newFolder = 'new-folder', uploadFiles = 'upload-files', - newSecret = 'new-secret', + newDataConnector = 'new-data-connector', openProject = 'open-project', closeProject = 'close-project', cancelOpeningAllProjects = 'cancel-opening-all-projects', @@ -41,7 +41,7 @@ interface AssetEvents { newProject: AssetNewProjectEvent newFolder: AssetNewFolderEvent uploadFiles: AssetUploadFilesEvent - newSecret: AssetNewSecretEvent + newDataConnector: AssetNewDataConnectorEvent openProject: AssetOpenProjectEvent closeProject: AssetCloseProjectEvent cancelOpeningAllProjects: AssetCancelOpeningAllProjectsEvent @@ -78,8 +78,9 @@ export interface AssetUploadFilesEvent extends AssetBaseEvent } -/** A signal to create a secret. */ -export interface AssetNewSecretEvent extends AssetBaseEvent { +/** A signal to create a data connector. */ +export interface AssetNewDataConnectorEvent + extends AssetBaseEvent { placeholderId: backendModule.SecretId value: string } diff --git a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/events/assetListEvent.ts b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/events/assetListEvent.ts index b1fb61c136a4..da314e917dff 100644 --- a/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/events/assetListEvent.ts +++ b/app/ide-desktop/lib/dashboard/src/authentication/src/dashboard/events/assetListEvent.ts @@ -17,7 +17,7 @@ export enum AssetListEventType { newFolder = 'new-folder', newProject = 'new-project', uploadFiles = 'upload-files', - newSecret = 'new-secret', + newDataConnector = 'new-data-connector', closeFolder = 'close-folder', willDelete = 'will-delete', delete = 'delete', @@ -34,7 +34,7 @@ interface AssetListEvents { newFolder: AssetListNewFolderEvent newProject: AssetListNewProjectEvent uploadFiles: AssetListUploadFilesEvent - newSecret: AssetListNewSecretEvent + newDataConnector: AssetListNewDataConnectorEvent closeFolder: AssetListCloseFolderEvent willDelete: AssetListWillDeleteEvent delete: AssetListDeleteEvent @@ -74,8 +74,9 @@ interface AssetListUploadFilesEvent extends AssetListBaseEvent { +/** A signal to create a new data connector. */ +interface AssetListNewDataConnectorEvent + extends AssetListBaseEvent { parentKey: backend.DirectoryId | null parentId: backend.DirectoryId | null name: string