From 9781ce17caa093a947d935f103cd328ef0fca65f Mon Sep 17 00:00:00 2001 From: Wes Date: Wed, 20 Nov 2024 09:40:52 -0700 Subject: [PATCH] feat: stub out each decl panel (#3441) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just stubbing out these pages so we have somewhere to add content once we figure out what we need. ![Screenshot 2024-11-20 at 9 16 24 AM](https://github.com/user-attachments/assets/12364c14-4505-4f6e-b90b-38e070ad2419) ![Screenshot 2024-11-20 at 9 16 26 AM](https://github.com/user-attachments/assets/3a76ef55-24b8-44cc-9167-1a686375e631) ![Screenshot 2024-11-20 at 9 16 28 AM](https://github.com/user-attachments/assets/98f1fd10-6f1b-483e-9b0b-54e2d6b5ce2d) ![Screenshot 2024-11-20 at 9 16 33 AM](https://github.com/user-attachments/assets/3e17097d-9280-4874-8585-3aae4b51c6fc) ![Screenshot 2024-11-20 at 9 16 35 AM](https://github.com/user-attachments/assets/1e532398-dc09-495b-ad74-9d40fb302da9) --- .../modules/decls/RightPanelHeader.tsx | 2 +- .../modules/decls/database/DatabasePanel.tsx | 33 ++++++++++++++---- .../decls/database/DatabaseRightPanels.tsx | 16 +++++++++ .../features/modules/decls/enum/EnumPanel.tsx | 29 +++++++++++----- .../modules/decls/enum/EnumRightPanels.tsx | 16 +++++++++ .../modules/decls/secret/SecretPanel.tsx | 20 ++++++++--- .../decls/subscription/SubscriptionPanel.tsx | 2 +- .../subscription/SubscriptionRightPanels.tsx | 5 ++- .../modules/decls/topic/TopicPanel.tsx | 2 +- .../modules/decls/topic/TopicRightPanels.tsx | 5 ++- .../decls/typealias/TypeAliasPanel.tsx | 34 +++++++++++++++---- .../decls/typealias/TypeAliasRightPanels.tsx | 16 +++++++++ 12 files changed, 148 insertions(+), 32 deletions(-) create mode 100644 frontend/console/src/features/modules/decls/database/DatabaseRightPanels.tsx create mode 100644 frontend/console/src/features/modules/decls/enum/EnumRightPanels.tsx create mode 100644 frontend/console/src/features/modules/decls/typealias/TypeAliasRightPanels.tsx diff --git a/frontend/console/src/features/modules/decls/RightPanelHeader.tsx b/frontend/console/src/features/modules/decls/RightPanelHeader.tsx index 90f58cad60..951a060244 100644 --- a/frontend/console/src/features/modules/decls/RightPanelHeader.tsx +++ b/frontend/console/src/features/modules/decls/RightPanelHeader.tsx @@ -1,7 +1,7 @@ export const RightPanelHeader = ({ Icon, title }: { Icon?: React.ElementType; title?: string }) => { return (
- {Icon && } + {Icon && } {title &&
{title}
}
) diff --git a/frontend/console/src/features/modules/decls/database/DatabasePanel.tsx b/frontend/console/src/features/modules/decls/database/DatabasePanel.tsx index ec48c31131..a3d7c23ae5 100644 --- a/frontend/console/src/features/modules/decls/database/DatabasePanel.tsx +++ b/frontend/console/src/features/modules/decls/database/DatabasePanel.tsx @@ -1,16 +1,35 @@ +import { ResizablePanels } from '../../../../components/ResizablePanels' import type { Database } from '../../../../protos/xyz/block/ftl/v1/console/console_pb' +import { declIcon } from '../../module.utils' import { Schema } from '../../schema/Schema' +import { DeclDefaultPanels } from '../DeclDefaultPanels' import { PanelHeader } from '../PanelHeader' -import { References } from '../References' +import { RightPanelHeader } from '../RightPanelHeader' +import { databasePanels } from './DatabaseRightPanels' export const DatabasePanel = ({ value, schema, moduleName, declName }: { value: Database; schema: string; moduleName: string; declName: string }) => { + const decl = value.database + if (!decl) { + return + } + return ( -
- -
- -
- +
+ +
+ +
+ +
+
+
+ } + rightPanelHeader={} + rightPanelPanels={[...databasePanels(value), ...DeclDefaultPanels(schema, value.references)]} + storageKeyPrefix='databasePanel' + />
) } diff --git a/frontend/console/src/features/modules/decls/database/DatabaseRightPanels.tsx b/frontend/console/src/features/modules/decls/database/DatabaseRightPanels.tsx new file mode 100644 index 0000000000..c4cb27264c --- /dev/null +++ b/frontend/console/src/features/modules/decls/database/DatabaseRightPanels.tsx @@ -0,0 +1,16 @@ +import { RightPanelAttribute } from '../../../../components/RightPanelAttribute' +import type { Database } from '../../../../protos/xyz/block/ftl/v1/console/console_pb' +import type { ExpandablePanelProps } from '../../../console/ExpandablePanel' + +export const databasePanels = (database: Database) => { + return [ + { + title: 'Details', + expanded: true, + children: [ + , + , + ], + }, + ] as ExpandablePanelProps[] +} diff --git a/frontend/console/src/features/modules/decls/enum/EnumPanel.tsx b/frontend/console/src/features/modules/decls/enum/EnumPanel.tsx index e3c2426671..c0ec9919c8 100644 --- a/frontend/console/src/features/modules/decls/enum/EnumPanel.tsx +++ b/frontend/console/src/features/modules/decls/enum/EnumPanel.tsx @@ -1,8 +1,11 @@ +import { ResizablePanels } from '../../../../components/ResizablePanels' import type { Enum } from '../../../../protos/xyz/block/ftl/v1/console/console_pb' +import { declIcon } from '../../module.utils' import { Schema } from '../../schema/Schema' +import { DeclDefaultPanels } from '../DeclDefaultPanels' import { PanelHeader } from '../PanelHeader' -import { References } from '../References' -import { enumType } from './enum.utils' +import { RightPanelHeader } from '../RightPanelHeader' +import { enumPanels } from './EnumRightPanels' export const EnumPanel = ({ value, schema, moduleName, declName }: { value: Enum; schema: string; moduleName: string; declName: string }) => { if (!value || !schema) { @@ -13,12 +16,22 @@ export const EnumPanel = ({ value, schema, moduleName, declName }: { value: Enum return } return ( -
- -
- -
- +
+ +
+ +
+ +
+
+
+ } + rightPanelHeader={} + rightPanelPanels={[...enumPanels(value), ...DeclDefaultPanels(schema, value.references)]} + storageKeyPrefix='enumPanel' + />
) } diff --git a/frontend/console/src/features/modules/decls/enum/EnumRightPanels.tsx b/frontend/console/src/features/modules/decls/enum/EnumRightPanels.tsx new file mode 100644 index 0000000000..41b1bd9a2c --- /dev/null +++ b/frontend/console/src/features/modules/decls/enum/EnumRightPanels.tsx @@ -0,0 +1,16 @@ +import { RightPanelAttribute } from '../../../../components/RightPanelAttribute' +import type { Enum } from '../../../../protos/xyz/block/ftl/v1/console/console_pb' +import type { ExpandablePanelProps } from '../../../console/ExpandablePanel' + +export const enumPanels = (enumDecl: Enum) => { + return [ + { + title: 'Details', + expanded: true, + children: [ + , + , + ], + }, + ] as ExpandablePanelProps[] +} diff --git a/frontend/console/src/features/modules/decls/secret/SecretPanel.tsx b/frontend/console/src/features/modules/decls/secret/SecretPanel.tsx index 008aff4a09..f13d811d84 100644 --- a/frontend/console/src/features/modules/decls/secret/SecretPanel.tsx +++ b/frontend/console/src/features/modules/decls/secret/SecretPanel.tsx @@ -1,5 +1,5 @@ -import { Button } from '@headlessui/react' import { useContext, useEffect, useState } from 'react' +import { Button } from '../../../../components/Button' import { CodeEditor } from '../../../../components/CodeEditor' import { ResizablePanels } from '../../../../components/ResizablePanels' import { useClient } from '../../../../hooks/use-client' @@ -24,10 +24,20 @@ export const SecretPanel = ({ value, schema, moduleName, declName }: { value: Se const handleGetSecret = () => { setIsLoading(true) - client.getSecret({ module: moduleName, name: declName }).then((resp) => { - setSecretValue(new TextDecoder().decode(resp.value)) - setIsLoading(false) - }) + client + .getSecret({ module: moduleName, name: declName }) + .then((resp) => { + setSecretValue(new TextDecoder().decode(resp.value)) + setIsLoading(false) + }) + .catch((error) => { + setIsLoading(false) + notification?.showNotification({ + title: 'Failed to get secret', + message: error.message, + type: NotificationType.Error, + }) + }) } const handleSetSecret = () => { diff --git a/frontend/console/src/features/modules/decls/subscription/SubscriptionPanel.tsx b/frontend/console/src/features/modules/decls/subscription/SubscriptionPanel.tsx index c817dc5ba7..08f8ef483b 100644 --- a/frontend/console/src/features/modules/decls/subscription/SubscriptionPanel.tsx +++ b/frontend/console/src/features/modules/decls/subscription/SubscriptionPanel.tsx @@ -23,7 +23,7 @@ export const SubscriptionPanel = ({ value, schema, moduleName, declName }: { val mainContent={
- +
diff --git a/frontend/console/src/features/modules/decls/subscription/SubscriptionRightPanels.tsx b/frontend/console/src/features/modules/decls/subscription/SubscriptionRightPanels.tsx index aecab63d76..6a90e676f6 100644 --- a/frontend/console/src/features/modules/decls/subscription/SubscriptionRightPanels.tsx +++ b/frontend/console/src/features/modules/decls/subscription/SubscriptionRightPanels.tsx @@ -7,7 +7,10 @@ export const subscriptionPanels = (subscription: Subscription) => { { title: 'Details', expanded: true, - children: [], + children: [ + , + , + ], }, ] as ExpandablePanelProps[] } diff --git a/frontend/console/src/features/modules/decls/topic/TopicPanel.tsx b/frontend/console/src/features/modules/decls/topic/TopicPanel.tsx index 01307c5c6b..fc0ba1480a 100644 --- a/frontend/console/src/features/modules/decls/topic/TopicPanel.tsx +++ b/frontend/console/src/features/modules/decls/topic/TopicPanel.tsx @@ -23,7 +23,7 @@ export const TopicPanel = ({ value, schema, moduleName, declName }: { value: Top mainContent={
- +
diff --git a/frontend/console/src/features/modules/decls/topic/TopicRightPanels.tsx b/frontend/console/src/features/modules/decls/topic/TopicRightPanels.tsx index 8e486086e5..9d8105fa03 100644 --- a/frontend/console/src/features/modules/decls/topic/TopicRightPanels.tsx +++ b/frontend/console/src/features/modules/decls/topic/TopicRightPanels.tsx @@ -7,7 +7,10 @@ export const topicPanels = (topic: Topic) => { { title: 'Details', expanded: true, - children: [], + children: [ + , + , + ], }, ] as ExpandablePanelProps[] } diff --git a/frontend/console/src/features/modules/decls/typealias/TypeAliasPanel.tsx b/frontend/console/src/features/modules/decls/typealias/TypeAliasPanel.tsx index e04e6e34c4..deffc12a93 100644 --- a/frontend/console/src/features/modules/decls/typealias/TypeAliasPanel.tsx +++ b/frontend/console/src/features/modules/decls/typealias/TypeAliasPanel.tsx @@ -1,19 +1,39 @@ +import { ResizablePanels } from '../../../../components/ResizablePanels' import type { TypeAlias } from '../../../../protos/xyz/block/ftl/v1/console/console_pb' +import { declIcon } from '../../module.utils' import { Schema } from '../../schema/Schema' +import { DeclDefaultPanels } from '../DeclDefaultPanels' import { PanelHeader } from '../PanelHeader' -import { References } from '../References' +import { RightPanelHeader } from '../RightPanelHeader' +import { typeAliasPanels } from './TypeAliasRightPanels' export const TypeAliasPanel = ({ value, schema, moduleName, declName }: { value: TypeAlias; schema: string; moduleName: string; declName: string }) => { if (!value || !schema) { return } + + const decl = value.typealias + if (!decl) { + return + } + return ( -
- -
- -
- +
+ +
+ +
+ +
+
+
+ } + rightPanelHeader={} + rightPanelPanels={[...typeAliasPanels(value), ...DeclDefaultPanels(schema, value.references)]} + storageKeyPrefix='typeAliasPanel' + />
) } diff --git a/frontend/console/src/features/modules/decls/typealias/TypeAliasRightPanels.tsx b/frontend/console/src/features/modules/decls/typealias/TypeAliasRightPanels.tsx new file mode 100644 index 0000000000..f1507624d5 --- /dev/null +++ b/frontend/console/src/features/modules/decls/typealias/TypeAliasRightPanels.tsx @@ -0,0 +1,16 @@ +import { RightPanelAttribute } from '../../../../components/RightPanelAttribute' +import type { TypeAlias } from '../../../../protos/xyz/block/ftl/v1/console/console_pb' +import type { ExpandablePanelProps } from '../../../console/ExpandablePanel' + +export const typeAliasPanels = (typeAlias: TypeAlias) => { + return [ + { + title: 'Details', + expanded: true, + children: [ + , + , + ], + }, + ] as ExpandablePanelProps[] +}