-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
define the connection type config map typescript types
- Loading branch information
1 parent
8e17ae3
commit afb75ec
Showing
2 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<T extends ConnectionTypeFieldType | string> = { | ||
type: T; | ||
name: string; | ||
description: string; | ||
}; | ||
|
||
type DataField<T extends ConnectionTypeFieldType | string, P> = Field<T> & { | ||
envVar: string; | ||
required?: boolean; | ||
properties: P; | ||
}; | ||
|
||
type TextProps = { | ||
defaultValue?: string; | ||
defaultReadOnly?: boolean; | ||
}; | ||
|
||
export type SectionField = Field<ConnectionTypeFieldType.Section | 'section'>; | ||
|
||
export type HiddenField = DataField<ConnectionTypeFieldType.Hidden | 'hidden', TextProps>; | ||
export type ParagraphField = DataField<ConnectionTypeFieldType.Paragraph | 'paragraph', TextProps>; | ||
export type FileField = DataField<ConnectionTypeFieldType.File | 'file', TextProps>; | ||
export type ShortTextField = DataField<ConnectionTypeFieldType.ShortText | 'short-text', TextProps>; | ||
export type UriField = DataField<ConnectionTypeFieldType.URI | 'uri', TextProps>; | ||
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; | ||
defaultReadOnly?: boolean; | ||
} | ||
>; | ||
|
||
export type ConnectionTypeField = | ||
| BooleanField | ||
| DropdownField | ||
| FileField | ||
| HiddenField | ||
| NumericField | ||
| ParagraphField | ||
| SectionField | ||
| 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[]; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters