Skip to content

Commit ead12c8

Browse files
committed
fix: update messages placeholders
1 parent 27f63b2 commit ead12c8

16 files changed

Lines changed: 209 additions & 210 deletions

src/ActionPanel.js

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import './ActionPanel.scss';
1515

1616
type ActionPanelProps = {
1717
focusedOptionName: ?string,
18-
selectedCommandName: ?string,
18+
selectedActionName: ?string,
1919
programSequence: ProgramSequence,
2020
pressedStepIndex: number,
2121
intl: IntlShape,
@@ -42,53 +42,53 @@ class ActionPanel extends React.Component<ActionPanelProps, {}> {
4242
stepNumber = cachedCurrentStepLoopData.getContainingLoopPosition();
4343
}
4444

45-
let stepName = '';
45+
let stepActionName = '';
4646
if (currentStep.block === 'startLoop' || currentStep.block === 'endLoop') {
47-
stepName = this.props.intl.formatMessage(
47+
stepActionName = this.props.intl.formatMessage(
4848
{ id: 'Command.loop.label' },
4949
{ loopLabel: currentStep.label }
5050
);
5151
} else {
52-
stepName = this.props.intl.formatMessage(
52+
stepActionName = this.props.intl.formatMessage(
5353
{ id: `Command.${currentStep.block}` }
5454
);
5555
}
5656

57-
const replaceStepAriaLabel = this.props.selectedCommandName != null ?
57+
const replaceStepAriaLabel = this.props.selectedActionName != null ?
5858
this.props.intl.formatMessage(
59-
{id:'ActionPanel.action.replace.withAction'},
60-
{ stepNumber, stepName, selectedCommandName: this.props.intl.formatMessage({id: `Command.${this.props.selectedCommandName}`}) }
59+
{id:'ActionPanel.action.replace.withSelectedAction'},
60+
{ stepNumber, stepActionName, selectedActionName: this.props.intl.formatMessage({id: `Command.${this.props.selectedActionName}`}) }
6161
) :
62-
this.props.intl.formatMessage({id:'ActionPanel.action.replace.noAction'}, { stepNumber, stepName });
62+
this.props.intl.formatMessage({id:'ActionPanel.action.replace.noSelectedAction'}, { stepNumber, stepActionName });
6363

6464
return {
6565
replaceStepAriaLabel,
66-
'deleteStepAriaLabel': this.props.intl.formatMessage({id:'ActionPanel.action.delete'}, { stepNumber, stepName }),
67-
'previousStepAriaLabel': this.makePreviousStepAriaLabel(stepNumber, stepName),
68-
'nextStepAriaLabel': this.makeNextStepAriaLabel(stepNumber, stepName)
66+
'deleteStepAriaLabel': this.props.intl.formatMessage({id:'ActionPanel.action.delete'}, { stepNumber, stepActionName }),
67+
'previousStepAriaLabel': this.makePreviousStepAriaLabel(stepNumber, stepActionName),
68+
'nextStepAriaLabel': this.makeNextStepAriaLabel(stepNumber, stepActionName)
6969
}
7070
}
7171

72-
makePreviousStepAriaLabel(stepNumber: ?number | string, stepName: string): string {
72+
makePreviousStepAriaLabel(stepNumber: ?number | string, stepActionName: string): string {
7373
const currentStep = this.props.programSequence.getProgramStepAt(this.props.pressedStepIndex);
7474
if (this.props.pressedStepIndex > 0) {
7575
const prevStep = this.props.programSequence.getProgramStepAt(this.props.pressedStepIndex - 1);
7676
const cachedPreviousStepLoopData = prevStep.cache;
7777
// When previous step is startLoop, aria-label communicates that movePrevious will move out of the current loop
7878
if (prevStep.block === 'startLoop' && currentStep.block !== 'endLoop') {
79-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.startLoop'},
79+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.outOfLoop'},
8080
{
8181
stepNumber,
82-
stepName,
82+
stepActionName,
8383
loopLabel: prevStep.label
8484
}
8585
);
8686
// When previous step is endLoop, aria-label communicates that movePrevious will move into a loop
8787
} else if (prevStep.block === 'endLoop') {
88-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.endLoop'},
88+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.intoLoop'},
8989
{
9090
stepNumber,
91-
stepName,
91+
stepActionName,
9292
loopLabel: prevStep.label
9393
}
9494
);
@@ -99,67 +99,67 @@ class ActionPanel extends React.Component<ActionPanelProps, {}> {
9999
const startLoopIndex = this.props.programSequence.getMatchingLoopBlockIndex(this.props.pressedStepIndex);
100100
const program = this.props.programSequence.getProgram();
101101
if (startLoopIndex != null && program[startLoopIndex - 1] != null) {
102-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.command'},
102+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep'},
103103
{
104104
stepNumber,
105-
stepName,
105+
stepActionName,
106106
previousStepNumber: startLoopIndex,
107-
command: this.props.intl.formatMessage({id: `Command.${program[startLoopIndex - 1].block}`}),
107+
previousStepActionName: this.props.intl.formatMessage({id: `Command.${program[startLoopIndex - 1].block}`}),
108108
}
109109
)
110110
}
111111
// When previous step is wrapped in a loop, aria-label communicates position within a loop
112112
} else if (cachedPreviousStepLoopData != null) {
113-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.inLoop'},
113+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.withInLoop'},
114114
{
115115
stepNumber,
116-
stepName,
116+
stepActionName,
117117
previousStepNumber: cachedPreviousStepLoopData.getContainingLoopPosition(),
118-
command: this.props.intl.formatMessage({id: `Command.${prevStep.block}`}),
118+
previousStepActionName: this.props.intl.formatMessage({id: `Command.${prevStep.block}`}),
119119
loopLabel: cachedPreviousStepLoopData.getContainingLoopLabel(),
120120
}
121121
)
122122
// When previous step is a movements step and not in a loop, aria-label communicates position within the program
123123
} else {
124-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.command'},
124+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep'},
125125
{
126126
stepNumber,
127-
stepName,
127+
stepActionName,
128128
previousStepNumber: this.props.pressedStepIndex,
129-
command: this.props.intl.formatMessage({id: `Command.${prevStep.block}`})
129+
previousStepActionName: this.props.intl.formatMessage({id: `Command.${prevStep.block}`})
130130
}
131131
);
132132
}
133133
}
134134
}
135-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep'},
135+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToPreviousStep.disabled'},
136136
{
137137
stepNumber,
138-
stepName
138+
stepActionName
139139
}
140140
);
141141
}
142142

143-
makeNextStepAriaLabel(stepNumber: ?number | string, stepName: string): string {
143+
makeNextStepAriaLabel(stepNumber: ?number | string, stepActionName: string): string {
144144
const currentStep = this.props.programSequence.getProgramStepAt(this.props.pressedStepIndex);
145145
if (this.props.pressedStepIndex < (this.props.programSequence.getProgramLength() - 1)) {
146146
const nextStep = this.props.programSequence.getProgramStepAt(this.props.pressedStepIndex + 1);
147147
const cachedNextStepLoopData = nextStep.cache;
148148
// When next step is startLoop, aria-label communicates that moveNext will move into a loop
149149
if (nextStep.block === 'startLoop') {
150-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.startLoop'},
150+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.intoLoop'},
151151
{
152152
stepNumber,
153-
stepName,
153+
stepActionName,
154154
loopLabel: nextStep.label
155155
}
156156
);
157157
// When next step is endLoop, aria-label communicates that moveNext will move out of the current loop
158158
} else if (nextStep.block === 'endLoop' && currentStep.block !== 'startLoop') {
159-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.endLoop'},
159+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.outOfLoop'},
160160
{
161161
stepNumber,
162-
stepName,
162+
stepActionName,
163163
loopLabel: nextStep.label
164164
}
165165
);
@@ -170,43 +170,43 @@ class ActionPanel extends React.Component<ActionPanelProps, {}> {
170170
const endLoopIndex = this.props.programSequence.getMatchingLoopBlockIndex(this.props.pressedStepIndex);
171171
const program = this.props.programSequence.getProgram();
172172
if (endLoopIndex != null && program[endLoopIndex + 1] != null) {
173-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.command'},
173+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep'},
174174
{
175175
stepNumber,
176-
stepName,
176+
stepActionName,
177177
nextStepNumber: endLoopIndex + 2,
178-
command: this.props.intl.formatMessage({id: `Command.${program[endLoopIndex + 1].block}`}),
178+
nextStepActionName: this.props.intl.formatMessage({id: `Command.${program[endLoopIndex + 1].block}`}),
179179
}
180180
);
181181
}
182182
// When next step is wrapped in a loop, aria-label communicates position within a loop
183183
} else if (cachedNextStepLoopData != null) {
184-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.inLoop'},
184+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.withInLoop'},
185185
{
186186
stepNumber,
187-
stepName,
187+
stepActionName,
188188
nextStepNumber: cachedNextStepLoopData.getContainingLoopPosition(),
189-
command: this.props.intl.formatMessage({id: `Command.${nextStep.block}`}),
189+
nextStepActionName: this.props.intl.formatMessage({id: `Command.${nextStep.block}`}),
190190
loopLabel: cachedNextStepLoopData.getContainingLoopLabel()
191191
}
192192
);
193193
// When next step is a movements step and not in a loop, aria-label communicates position within the program
194194
} else {
195-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.command'},
195+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep'},
196196
{
197197
stepNumber,
198-
stepName,
198+
stepActionName,
199199
nextStepNumber: this.props.pressedStepIndex + 2,
200-
command: this.props.intl.formatMessage({id: `Command.${nextStep.block}`})
200+
nextStepActionName: this.props.intl.formatMessage({id: `Command.${nextStep.block}`})
201201
}
202202
);
203203
}
204204
}
205205
}
206-
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep'},
206+
return this.props.intl.formatMessage({id: 'ActionPanel.action.moveToNextStep.disabled'},
207207
{
208208
stepNumber,
209-
stepName
209+
stepActionName
210210
}
211211
);
212212
}
@@ -238,7 +238,7 @@ class ActionPanel extends React.Component<ActionPanelProps, {}> {
238238
const moveToNextStepIsDisabled = this.props.programSequence.moveToNextStepDisabled(this.props.pressedStepIndex);
239239
const moveToPreviousStepIsDisabled = this.props.programSequence.moveToPreviousStepDisabled(this.props.pressedStepIndex);
240240
const replaceIsVisible = this.getReplaceIsVisible();
241-
const replaceIsDisabled = this.props.selectedCommandName == null;
241+
const replaceIsDisabled = this.props.selectedActionName == null;
242242

243243
return (
244244
<React.Fragment>

src/ActionPanel.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function createMountActionPanel(props) {
2424
{},
2525
{
2626
focusedOptionName: null,
27-
selectedCommandName: 'right45',
27+
selectedActionName: 'right45',
2828
programSequence: new ProgramSequence(
2929
[
3030
{block: 'forward1'},
@@ -101,7 +101,7 @@ describe('ActionPanel options', () => {
101101
test('Given that there is no selected action, then the Replace button should be disabled', () => {
102102
const { wrapper } = createMountActionPanel({
103103
pressedStepIndex: 1,
104-
selectedCommandName: null
104+
selectedActionName: null
105105
});
106106
const replaceButton = getActionPanelOptionButtons(wrapper, 'replaceCurrentStep');
107107
const expectedAriaLabel = 'Replace Step 2 turn left 45 degrees';

src/AnnouncementBuilder.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,43 @@ export default class AnnouncementBuilder {
1616
}
1717

1818
buildSelectActionAnnouncement(action: string): AnnouncementData {
19-
let commandType = null;
19+
let actionType = null;
2020
if (action === 'loop') {
21-
commandType = this.intl.formatMessage({
21+
actionType = this.intl.formatMessage({
2222
id: 'Announcement.control'
2323
});
2424
} else {
25-
commandType = this.intl.formatMessage({
25+
actionType = this.intl.formatMessage({
2626
id: 'Announcement.movement'
2727
});
2828
}
2929
return {
3030
messageIdSuffix: 'actionSelected',
3131
values: {
32-
commandType: commandType,
33-
command: this.intl.formatMessage({
32+
actionType,
33+
actionName: this.intl.formatMessage({
3434
id: `Announcement.${action}`
3535
}),
3636
}
3737
};
3838
}
3939

4040
buildAddStepAnnouncement(action: string): AnnouncementData {
41-
let commandType = null;
41+
let actionType = null;
4242
if (action === 'loop') {
43-
commandType = this.intl.formatMessage({
43+
actionType = this.intl.formatMessage({
4444
id: 'Announcement.control'
4545
});
4646
} else {
47-
commandType = this.intl.formatMessage({
47+
actionType = this.intl.formatMessage({
4848
id: 'Announcement.movement'
4949
});
5050
}
5151
return {
5252
messageIdSuffix: 'add',
5353
values: {
54-
commandType: commandType,
55-
command: this.intl.formatMessage({
54+
actionType,
55+
actionName: this.intl.formatMessage({
5656
id: `Announcement.${action}`
5757
}),
5858
}
@@ -64,10 +64,10 @@ export default class AnnouncementBuilder {
6464
return {
6565
messageIdSuffix: 'delete',
6666
values: {
67-
commandType: this.intl.formatMessage({
67+
actionType: this.intl.formatMessage({
6868
id: "Announcement.control"
6969
}),
70-
command: this.intl.formatMessage(
70+
actionName: this.intl.formatMessage(
7171
{
7272
id: `Announcement.${programBlock.block}`
7373
},
@@ -81,10 +81,10 @@ export default class AnnouncementBuilder {
8181
return {
8282
messageIdSuffix: 'delete',
8383
values: {
84-
commandType: this.intl.formatMessage({
84+
actionType: this.intl.formatMessage({
8585
id: "Announcement.movement"
8686
}),
87-
command: this.intl.formatMessage(
87+
actionName: this.intl.formatMessage(
8888
{
8989
id: `Announcement.${programBlock.block}`
9090
}
@@ -100,10 +100,10 @@ export default class AnnouncementBuilder {
100100
return {
101101
messageIdSuffix: 'replace',
102102
values: {
103-
oldCommand: this.intl.formatMessage({
103+
oldActionName: this.intl.formatMessage({
104104
id: `Announcement.${programBlock.block}`
105105
}),
106-
newCommand: this.intl.formatMessage({
106+
newActionName: this.intl.formatMessage({
107107
id: `Announcement.${selectedAction}`
108108
})
109109
}

0 commit comments

Comments
 (0)