@@ -59,6 +59,7 @@ export type StepperProps = {
|
||||
extensions: NextFieldExtensionOptions<any, any>[];
|
||||
templateName?: string;
|
||||
FormProps?: FormProps;
|
||||
initialState?: Record<string, JsonValue>;
|
||||
|
||||
onComplete: (values: Record<string, JsonValue>) => Promise<void>;
|
||||
};
|
||||
@@ -77,7 +78,7 @@ export const Stepper = (props: StepperProps) => {
|
||||
const { steps } = useTemplateSchema(props.manifest);
|
||||
const apiHolder = useApiHolder();
|
||||
const [activeStep, setActiveStep] = useState(0);
|
||||
const [formState, setFormState] = useFormDataFromQuery();
|
||||
const [formState, setFormState] = useFormDataFromQuery(props.initialState);
|
||||
|
||||
const [errors, setErrors] = useState<
|
||||
undefined | Record<string, FieldValidation>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { JsonValue } from '@backstage/types';
|
||||
import qs from 'qs';
|
||||
import { useState } from 'react';
|
||||
|
||||
@@ -21,8 +22,14 @@ import { useState } from 'react';
|
||||
* This hook is used to get the formData from the query string.
|
||||
* @alpha
|
||||
*/
|
||||
export const useFormDataFromQuery = () => {
|
||||
export const useFormDataFromQuery = (
|
||||
initialState?: Record<string, JsonValue>,
|
||||
) => {
|
||||
return useState<Record<string, any>>(() => {
|
||||
if (initialState) {
|
||||
return initialState;
|
||||
}
|
||||
|
||||
const query = qs.parse(window.location.search, {
|
||||
ignoreQueryPrefix: true,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user