Skip to content

Commit 38b312a

Browse files
committed
fix(pf4): make wizard more translatable
- name of step is used as key - substepOf can be now object
1 parent d1b8eac commit 38b312a

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

packages/common/src/wizard/reducer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ const createSchema = ({ formOptions, fields }) => {
1313
schema = [
1414
...schema,
1515
{
16+
name: field.name,
1617
title: field.title,
17-
substepOf: field.substepOf,
18+
substepOf: field.substepOf?.name || field.substepOf,
19+
substepOfTitle: field.substepOf?.title || field.substepOf,
1820
index,
1921
primary: !schema[schema.length - 1] || !field.substepOf || field.substepOf !== schema[schema.length - 1].substepOf
2022
}

packages/pf4-component-mapper/demo/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const fieldArrayState = { schema: arraySchemaDDF, additionalOptions: {
2424
class App extends React.Component {
2525
constructor(props) {
2626
super(props);
27-
this.state = {schema: selectSchema, additionalOptions: {}}
27+
this.state = {schema: wizardSchema, additionalOptions: {}}
2828
}
2929

3030
render() {

packages/pf4-component-mapper/src/files/wizard.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,16 @@ export interface WizardButtonsProps {
4747
selectNext: SelectNextFunction;
4848
}
4949

50+
export interface SubstepOfObject {
51+
name: string;
52+
title?: ReactNode;
53+
}
54+
5055
export interface WizardField {
5156
name: string | number;
5257
fields: Field[];
5358
nextStep?: WizardNextStep;
54-
substepOf?: string | number;
59+
substepOf?: string | number | SubstepOfObject;
5560
title?: ReactNode;
5661
showTitle?: boolean;
5762
customTitle?: ReactNode;

packages/pf4-component-mapper/src/files/wizard/wizard-nav.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ const WizardNavigationInternal = React.memo(
3030

3131
return (
3232
<WizardNavItem
33-
key={step.substepOf || step.title}
34-
content={step.substepOf || step.title}
33+
key={step.substepOf || step.name}
34+
content={step.substepOfTitle || step.title}
3535
isCurrent={substeps ? activeStepIndex >= step.index && activeStepIndex < step.index + substeps.length : activeStepIndex === step.index}
3636
isDisabled={isValid ? maxStepIndex < step.index : step.index > activeStepIndex}
3737
onNavItemClick={(ind) => jumpToStep(ind, isValid)}
@@ -41,7 +41,7 @@ const WizardNavigationInternal = React.memo(
4141
<WizardNav returnList>
4242
{substeps.map((substep) => (
4343
<WizardNavItem
44-
key={substep.title}
44+
key={substep.name}
4545
content={substep.title}
4646
isCurrent={activeStepIndex === substep.index}
4747
isDisabled={isValid ? maxStepIndex < substep.index : substep.index > activeStepIndex}

0 commit comments

Comments
 (0)