chore: one more deprecations

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-02-25 11:27:37 +01:00
parent 4618350aa8
commit 6ce323aa55
6 changed files with 21 additions and 13 deletions
+1
View File
@@ -6,6 +6,7 @@ Added some deprecations as follows:
- **DEPRECATED**: `TemplateCardComponent` and `TaskPageComponent` props have been deprecated, and moved to a `components` prop instead. You can pass them in through there instead.
- **DEPRECATED**: `TemplateList` and `TemplateListProps` has been deprecated. Please use the `TemplateCard` to create your own list component instead.
- **DEPRECATED**: `setSecret` has been deprecated in favour of `setSecrets` when calling `useTemplateSecrets`
Other notable changes:
+3 -3
View File
@@ -465,10 +465,10 @@ export type TemplateParameterSchema = {
// @public (undocumented)
export const TemplateTypePicker: () => JSX.Element | null;
// Warning: (ae-forgotten-export) The symbol "ScaffolderUseTemplateSecrets" needs to be exported by the entry point index.d.ts
//
// @public
export const useTemplateSecrets: () => {
setSecret: (input: Record<string, string>) => void;
};
export const useTemplateSecrets: () => ScaffolderUseTemplateSecrets;
// Warnings were encountered during analysis:
//
@@ -56,7 +56,7 @@ export const RepoUrlPicker = (
);
const integrationApi = useApi(scmIntegrationsApiRef);
const scmAuthApi = useApi(scmAuthApiRef);
const { setSecret } = useTemplateSecrets();
const { setSecrets } = useTemplateSecrets();
const allowedHosts = useMemo(
() => uiSchema?.['ui:options']?.allowedHosts ?? [],
[uiSchema],
@@ -114,7 +114,7 @@ export const RepoUrlPicker = (
// set the secret using the key provided in the the ui:options for use
// in the templating the manifest with ${{ secrets[secretsKey] }}
setSecret({ [requestUserCredentials.secretsKey]: token });
setSecrets({ [requestUserCredentials.secretsKey]: token });
},
500,
[state, uiSchema],
@@ -36,7 +36,7 @@ describe('SecretsContext', () => {
);
expect(result.current.context?.secrets.foo).toEqual(undefined);
act(() => result.current.hook.setSecret({ foo: 'bar' }));
act(() => result.current.hook.setSecrets({ foo: 'bar' }));
expect(result.current.context?.secrets.foo).toEqual('bar');
});
@@ -48,11 +48,17 @@ export const SecretsContextProvider = ({ children }: PropsWithChildren<{}>) => {
);
};
export interface ScaffolderUseTemplateSecrets {
/** @deprecated use setSecrets instead */
setSecret: (input: Record<string, string>) => void;
setSecrets: (input: Record<string, string>) => void;
}
/**
* Hook to access the secrets context.
* @public
*/
export const useTemplateSecrets = () => {
export const useTemplateSecrets = (): ScaffolderUseTemplateSecrets => {
const value = useContext(SecretsContext);
if (!value) {
throw new Error(
@@ -60,14 +66,14 @@ export const useTemplateSecrets = () => {
);
}
const { setSecrets } = value;
const { setSecrets: updateSecrets } = value;
const setSecret = useCallback(
const setSecrets = useCallback(
(input: Record<string, string>) => {
setSecrets(currentSecrets => ({ ...currentSecrets, ...input }));
updateSecrets(currentSecrets => ({ ...currentSecrets, ...input }));
},
[setSecrets],
[updateSecrets],
);
return { setSecret };
return { setSecret: setSecrets, setSecrets };
};
+2 -1
View File
@@ -48,7 +48,8 @@ export function createScaffolderFieldExtension<
};
}
export const ScaffolderFieldExtensions: React.ComponentType = () => null;
export const ScaffolderFieldExtensions: React.ComponentType =
(): JSX.Element | null => null;
attachComponentData(
ScaffolderFieldExtensions,