diff --git a/frontend/src/concepts/connectionTypes/types.ts b/frontend/src/concepts/connectionTypes/types.ts new file mode 100644 index 0000000000..8d52ca26af --- /dev/null +++ b/frontend/src/concepts/connectionTypes/types.ts @@ -0,0 +1,101 @@ +import { K8sResourceCommon } from '@openshift/dynamic-plugin-sdk-utils'; +import { DashboardLabels, DisplayNameAnnotations } from '~/k8sTypes'; + +export enum ConnectionTypeFieldType { + Boolean = 'boolean', + Dropdown = 'dropdown', + File = 'file', + Hidden = 'hidden', + Numeric = 'numeric', + Paragraph = 'paragraph', + Section = 'section', + ShortText = 'short-text', + URI = 'uri', +} + +// exclude 'section' +export const connectionTypeDataFields = [ + ConnectionTypeFieldType.Boolean, + ConnectionTypeFieldType.Dropdown, + ConnectionTypeFieldType.File, + ConnectionTypeFieldType.Hidden, + ConnectionTypeFieldType.Numeric, + ConnectionTypeFieldType.Paragraph, + ConnectionTypeFieldType.ShortText, + ConnectionTypeFieldType.URI, +]; + +type Field = { + type: T; + name: string; + description: string; +}; + +type DataField = Field & { + envVar: string; + required?: boolean; + properties: P; +}; + +type TextProps = { + defaultValue?: string; + defaultReadyOnly?: boolean; +}; + +export type Section = Field; + +export type HiddenField = DataField; +export type ParagraphField = DataField; +export type FileField = DataField; +export type ShortTextField = DataField; +export type UriField = DataField; +export type BooleanField = DataField< + ConnectionTypeFieldType.Boolean | 'boolean', + { + label?: string; + defaultValue?: boolean; + defaultReadOnly?: boolean; + } +>; +export type DropdownField = DataField< + ConnectionTypeFieldType.Dropdown | 'dropdown', + { + variant: 'single' | 'multi'; + items: { key: string; value: string }[]; + defaultItem?: string[]; + } +>; +export type NumericField = DataField< + ConnectionTypeFieldType.Numeric | 'numeric', + { + defaultValue?: number; + defaultReadyOnly?: boolean; + } +>; + +export type ConnectionTypeField = + | BooleanField + | DropdownField + | FileField + | HiddenField + | NumericField + | ParagraphField + | Section + | ShortTextField + | UriField; + +export type ConnectionTypeConfigMap = K8sResourceCommon & { + metadata: { + name: string; + annotations: DisplayNameAnnotations & { + 'opendatahub.io/enabled'?: 'true' | 'false'; + 'opendatahub.io/username'?: string; + }; + labels: DashboardLabels & { + 'opendatahub.io/connection-type': 'true'; + }; + }; + data: { + fields?: ConnectionTypeField[]; + }; +}; diff --git a/frontend/src/concepts/connectionTypes/useConnectionTypesEnabled.ts b/frontend/src/concepts/connectionTypes/useConnectionTypesEnabled.ts deleted file mode 100644 index 0106da69be..0000000000 --- a/frontend/src/concepts/connectionTypes/useConnectionTypesEnabled.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { SupportedArea, useIsAreaAvailable } from '~/concepts/areas'; - -const useConnectionTypesEnabled = (): boolean => - useIsAreaAvailable(SupportedArea.DATA_CONNECTIONS_TYPES).status; - -export default useConnectionTypesEnabled; diff --git a/frontend/src/k8sTypes.ts b/frontend/src/k8sTypes.ts index 4805772c98..5c5b918ffc 100644 --- a/frontend/src/k8sTypes.ts +++ b/frontend/src/k8sTypes.ts @@ -39,7 +39,7 @@ export type K8sVerb = * Annotations that we will use to allow the user flexibility in describing items outside of the * k8s structure. */ -type DisplayNameAnnotations = Partial<{ +export type DisplayNameAnnotations = Partial<{ 'openshift.io/description': string; // the description provided by the user 'openshift.io/display-name': string; // the name provided by the user }>;