chore: moving the secrets handling to the react package
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -202,6 +202,28 @@ export const scaffolderListTaskRouteRef: SubRouteRef<undefined>;
|
||||
// @public (undocumented)
|
||||
export const scaffolderTaskRouteRef: SubRouteRef<PathParams<'/tasks/:taskId'>>;
|
||||
|
||||
// @public
|
||||
export interface ScaffolderUseTemplateSecrets {
|
||||
// (undocumented)
|
||||
setSecrets: (input: Record<string, string>) => void;
|
||||
}
|
||||
|
||||
// @public
|
||||
export const SecretsContext: React_2.Context<
|
||||
SecretsContextContents | undefined
|
||||
>;
|
||||
|
||||
// @public
|
||||
export type SecretsContextContents = {
|
||||
secrets: Record<string, string>;
|
||||
setSecrets: React_2.Dispatch<React_2.SetStateAction<Record<string, string>>>;
|
||||
};
|
||||
|
||||
// @public
|
||||
export const SecretsContextProvider: ({
|
||||
children,
|
||||
}: PropsWithChildren<{}>) => JSX.Element;
|
||||
|
||||
// @public (undocumented)
|
||||
export const selectedTemplateRouteRef: SubRouteRef<
|
||||
PathParams<'/templates/:namespace/:templateName'>
|
||||
@@ -266,6 +288,9 @@ export const useTemplateSchema: (manifest: TemplateParameterSchema) => {
|
||||
steps: ParsedTemplateSchema[];
|
||||
};
|
||||
|
||||
// @public
|
||||
export const useTemplateSecrets: () => ScaffolderUseTemplateSecrets;
|
||||
|
||||
// @public (undocumented)
|
||||
export const viewTechDocRouteRef: ExternalRouteRef<
|
||||
{
|
||||
|
||||
@@ -16,5 +16,7 @@
|
||||
|
||||
export * from './routes';
|
||||
export * from './extensions';
|
||||
export * from './next';
|
||||
export * from './types';
|
||||
export * from './secrets';
|
||||
|
||||
export * from './next';
|
||||
|
||||
+9
-4
@@ -21,13 +21,18 @@ import React, {
|
||||
PropsWithChildren,
|
||||
} from 'react';
|
||||
|
||||
type SecretsContextContents = {
|
||||
/**
|
||||
* The contents of the {@link SecretsContext}.
|
||||
* @public
|
||||
*/
|
||||
export type SecretsContextContents = {
|
||||
secrets: Record<string, string>;
|
||||
setSecrets: React.Dispatch<React.SetStateAction<Record<string, string>>>;
|
||||
};
|
||||
|
||||
/**
|
||||
* The actual context object.
|
||||
* The context to hold the Secrets.
|
||||
* @public
|
||||
*/
|
||||
export const SecretsContext = createContext<SecretsContextContents | undefined>(
|
||||
undefined,
|
||||
@@ -35,7 +40,6 @@ export const SecretsContext = createContext<SecretsContextContents | undefined>(
|
||||
|
||||
/**
|
||||
* The Context Provider that holds the state for the secrets.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export const SecretsContextProvider = ({ children }: PropsWithChildren<{}>) => {
|
||||
@@ -57,7 +61,8 @@ export interface ScaffolderUseTemplateSecrets {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to access the secrets context.
|
||||
* Hook to access the secrets context to be able to set secrets that are
|
||||
* passed to the Scaffolder backend.
|
||||
* @public
|
||||
*/
|
||||
export const useTemplateSecrets = (): ScaffolderUseTemplateSecrets => {
|
||||
+7
-2
@@ -13,5 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { useTemplateSecrets } from './SecretsContext';
|
||||
export type { ScaffolderUseTemplateSecrets } from './SecretsContext';
|
||||
export {
|
||||
useTemplateSecrets,
|
||||
SecretsContext,
|
||||
SecretsContextProvider,
|
||||
type ScaffolderUseTemplateSecrets,
|
||||
type SecretsContextContents,
|
||||
} from './SecretsContext';
|
||||
@@ -22,7 +22,6 @@ import { ScaffolderPage } from './ScaffolderPage';
|
||||
import { TemplatePage } from './TemplatePage';
|
||||
import { TaskPage } from './TaskPage';
|
||||
import { ActionsPage } from './ActionsPage';
|
||||
import { SecretsContextProvider } from './secrets/SecretsContext';
|
||||
import { TemplateEditorPage } from './TemplateEditorPage';
|
||||
import { DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS } from '../extensions/default';
|
||||
import {
|
||||
@@ -40,6 +39,7 @@ import {
|
||||
FIELD_EXTENSION_KEY,
|
||||
FIELD_EXTENSION_WRAPPER_KEY,
|
||||
FieldExtensionOptions,
|
||||
SecretsContextProvider,
|
||||
} from '@backstage/plugin-scaffolder-react';
|
||||
import { ListTasksPage } from './ListTasksPage';
|
||||
import { LayoutOptions, LAYOUTS_KEY, LAYOUTS_WRAPPER_KEY } from '../layouts';
|
||||
|
||||
@@ -20,12 +20,12 @@ import React, { ComponentType, useCallback, useContext, useState } from 'react';
|
||||
import { Navigate, useNavigate } from 'react-router-dom';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
import { scaffolderApiRef } from '../../api';
|
||||
import { SecretsContext } from '../secrets/SecretsContext';
|
||||
import {
|
||||
rootRouteRef,
|
||||
scaffolderTaskRouteRef,
|
||||
selectedTemplateRouteRef,
|
||||
FieldExtensionOptions,
|
||||
SecretsContext,
|
||||
} from '@backstage/plugin-scaffolder-react';
|
||||
import { MultistepJsonForm } from '../MultistepJsonForm';
|
||||
import { createValidator } from './createValidator';
|
||||
|
||||
@@ -29,7 +29,7 @@ import { ScaffolderApi } from '../../../types';
|
||||
import {
|
||||
SecretsContextProvider,
|
||||
SecretsContext,
|
||||
} from '../../secrets/SecretsContext';
|
||||
} from '@backstage/plugin-scaffolder-react';
|
||||
import { act, fireEvent } from '@testing-library/react';
|
||||
|
||||
describe('RepoUrlPicker', () => {
|
||||
|
||||
@@ -30,7 +30,7 @@ import { parseRepoPickerUrl, serializeRepoPickerUrl } from './utils';
|
||||
import { RepoUrlPickerProps } from './schema';
|
||||
import { RepoUrlPickerState } from './types';
|
||||
import useDebounce from 'react-use/lib/useDebounce';
|
||||
import { useTemplateSecrets } from '../../secrets';
|
||||
import { useTemplateSecrets } from '@backstage/plugin-scaffolder-react';
|
||||
|
||||
export { RepoUrlPickerSchema } from './schema';
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
export * from './fields';
|
||||
export type { RepoUrlPickerUiOptions } from './fields';
|
||||
export { TemplateTypePicker } from './TemplateTypePicker';
|
||||
export * from './secrets';
|
||||
export { TaskPage } from './TaskPage';
|
||||
export type { RouterProps } from './Router';
|
||||
export type { ReviewStepProps } from './types';
|
||||
|
||||
@@ -22,14 +22,14 @@ import {
|
||||
FIELD_EXTENSION_KEY,
|
||||
NextFieldExtensionOptions,
|
||||
FieldExtensionOptions,
|
||||
nextSelectedTemplateRouteRef,
|
||||
SecretsContextProvider,
|
||||
type FormProps,
|
||||
} from '@backstage/plugin-scaffolder-react';
|
||||
|
||||
import { useElementFilter } from '@backstage/core-plugin-api';
|
||||
import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common';
|
||||
import { TemplateGroupFilter } from '../TemplateListPage/TemplateGroups';
|
||||
import { nextSelectedTemplateRouteRef } from '@backstage/plugin-scaffolder-react';
|
||||
import { SecretsContextProvider } from '../../components/secrets/SecretsContext';
|
||||
import { DEFAULT_SCAFFOLDER_FIELD_EXTENSIONS } from '../../extensions/default';
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,9 +41,9 @@ import {
|
||||
selectedTemplateRouteRef,
|
||||
Stepper,
|
||||
NextFieldExtensionOptions,
|
||||
SecretsContext,
|
||||
type FormProps,
|
||||
} from '@backstage/plugin-scaffolder-react';
|
||||
import { SecretsContext } from '../../components/secrets/SecretsContext';
|
||||
import { JsonValue } from '@backstage/types';
|
||||
|
||||
export type TemplateWizardPageProps = {
|
||||
|
||||
Reference in New Issue
Block a user