diff --git a/frontend/libs/console/legacy-ce/src/lib/features/Actions/components/OASGenerator/OASGeneratorForm.tsx b/frontend/libs/console/legacy-ce/src/lib/features/Actions/components/OASGenerator/OASGeneratorForm.tsx index 8c1fb38c242..22fd47f5d6a 100644 --- a/frontend/libs/console/legacy-ce/src/lib/features/Actions/components/OASGenerator/OASGeneratorForm.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/features/Actions/components/OASGenerator/OASGeneratorForm.tsx @@ -268,7 +268,6 @@ export const OasGeneratorForm = (props: OasGeneratorFormProps) => { noErrorPlaceholder name="oas" placeholder="1. Paste OpenAPI spec in raw text (JSON / YAML) here" - tooltip="Enter a sample request in JSON or YAML format to generate the input type" editorOptions={editorOptions} editorProps={{ className: 'rounded`-r-none', diff --git a/frontend/libs/console/legacy-ce/src/lib/new-components/Form/FieldWrapper.stories.tsx b/frontend/libs/console/legacy-ce/src/lib/new-components/Form/FieldWrapper.stories.tsx index 6a74f47a817..7748618c72c 100644 --- a/frontend/libs/console/legacy-ce/src/lib/new-components/Form/FieldWrapper.stories.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/new-components/Form/FieldWrapper.stories.tsx @@ -125,6 +125,26 @@ VariantWithDescriptionAndTooltipAndKnwMoreLink.parameters = { }, }; +export const VariantWithDescriptionAndTooltipAndKnowMoreLink: ComponentStory< + typeof FieldWrapper +> = () => ( + + + +); +VariantWithDescriptionAndTooltipAndKnowMoreLink.storyName = + '🎭 Variant - With description, tooltip, and know more link'; +VariantWithDescriptionAndTooltipAndKnowMoreLink.parameters = { + docs: { + source: { state: 'open' }, + }, +}; + export const StateLoading: ComponentStory = () => ( ; +type FieldWrapperProps = FieldWrapperPassThroughProps & { + /** + * The field class + */ + className?: string; + /** + * The field children + */ + children: React.ReactNode; + /** + * The field error + */ + error?: FieldError | undefined; +}; + export const ErrorComponentTemplate = (props: { label: React.ReactNode; ariaLabel?: string; diff --git a/frontend/libs/console/legacy-ce/src/lib/new-components/Form/GraphQLSanitizedInputField.tsx b/frontend/libs/console/legacy-ce/src/lib/new-components/Form/GraphQLSanitizedInputField.tsx index 474ef8d7d45..68aac3cd7bb 100644 --- a/frontend/libs/console/legacy-ce/src/lib/new-components/Form/GraphQLSanitizedInputField.tsx +++ b/frontend/libs/console/legacy-ce/src/lib/new-components/Form/GraphQLSanitizedInputField.tsx @@ -6,10 +6,10 @@ import React from 'react'; import { z } from 'zod'; import { InputField, InputFieldProps, Schema } from './InputField'; -export interface GraphQLSanitizedInputFieldProps> - extends InputFieldProps { - hideTips?: boolean; -} +export type GraphQLSanitizedInputFieldProps> = + InputFieldProps & { + hideTips?: boolean; + }; export const GraphQLSanitizedInputField = >({ hideTips, diff --git a/frontend/libs/console/legacy-ce/src/lib/types.ts b/frontend/libs/console/legacy-ce/src/lib/types.ts index 31048f55820..c4e0fa193a1 100644 --- a/frontend/libs/console/legacy-ce/src/lib/types.ts +++ b/frontend/libs/console/legacy-ce/src/lib/types.ts @@ -91,3 +91,44 @@ export type NullableProps = { [K in keyof T]: T[K] | null }; export type DeepNullableProps = { [K in keyof T]: DeepNullableProps | null; }; + +/** + * Set all keys in an object to Never. Useful for writing custom types. + * To grasp it: + * Given { a: string; b: number } + * called like this MakeNever + * It will output { a: never; b: never } + */ +export type MakeNever = { + [P in keyof T]: never; +}; + +/** + * Makes a discriminated union + * Useful if you have part of the object where you need + * + * To grasp it: + * Given { buttonLabel: string, buttonIcon?: string; onClick: () => void } + * Called like this DiscriminatedTypes + * It will output { buttonLabel?: string; buttonIcon?: never; onClick?: never } | { buttonLabel: string; buttonIcon?: string: onClick: () => void; } + * This way : + * If buttonLabel is not set, buttonIcon and onClick cannot be set + * If buttonLabel is set, buttonIcon can be set and onClick is mandatory + * + * @example Here you prevent `labelIcon` and `labelColor` to be passed without `label`, + * but you can pass just `label` if you want. + * type FieldWrapperProps = + * | { + * id: string; + * } & DiscriminatedTypes< + * { + * label: string; + * labelColor: string; + * labelIcon?: React.ReactElement; + * }, + * 'label' + * >; + */ +export type DiscriminatedTypes = + | MakeNever> & Partial>> + | (Required> & Omit);