orc-shared 5.10.2-dev.0 → 5.10.2-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -111,7 +111,7 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
111
111
  };
112
112
  });
113
113
  var StepperModal = function StepperModal(_ref) {
114
- var _steps$currentStep, _steps$currentStep$fu, _steps$currentStep2, _steps$currentStep3, _steps$currentStep4;
114
+ var _steps$currentStep, _steps$currentStep$fu, _steps$currentStep2, _steps$currentStep3, _steps$currentStep4, _steps$currentStep5, _steps$currentStep6;
115
115
  var _ref$steps = _ref.steps,
116
116
  steps = _ref$steps === void 0 ? [] : _ref$steps,
117
117
  _ref$title = _ref.title,
@@ -180,7 +180,7 @@ var StepperModal = function StepperModal(_ref) {
180
180
  }, /*#__PURE__*/_react.default.createElement(_Button.default, {
181
181
  variant: "outlined",
182
182
  onClick: closeCallback
183
- }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.cancel)), currentStep < steps.length - 1 && (((_steps$currentStep4 = steps[currentStep]) == null || (_steps$currentStep4 = _steps$currentStep4.actions) == null ? void 0 : _steps$currentStep4.length) > 0 ? steps[currentStep].actions.map(function (action) {
183
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.cancel)), (currentStep < steps.length - 1 || ((_steps$currentStep4 = steps[currentStep]) == null ? void 0 : _steps$currentStep4.isIntermediate)) && (((_steps$currentStep5 = steps[currentStep]) == null || (_steps$currentStep5 = _steps$currentStep5.actions) == null ? void 0 : _steps$currentStep5.length) > 0 ? steps[currentStep].actions.map(function (action) {
184
184
  return /*#__PURE__*/_react.default.createElement(_Button.default, {
185
185
  key: action.value,
186
186
  variant: "contained",
@@ -199,7 +199,7 @@ var StepperModal = function StepperModal(_ref) {
199
199
  return nextClick();
200
200
  },
201
201
  disableElevation: true
202
- }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.next))), currentStep === steps.length - 1 && /*#__PURE__*/_react.default.createElement(_Button.default, {
202
+ }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.next))), currentStep === steps.length - 1 && !((_steps$currentStep6 = steps[currentStep]) != null && _steps$currentStep6.isIntermediate) && /*#__PURE__*/_react.default.createElement(_Button.default, {
203
203
  variant: "contained",
204
204
  color: "primary",
205
205
  disabled: nextDisabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "5.10.2-dev.0",
3
+ "version": "5.10.2-dev.1",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -165,7 +165,7 @@ const StepperModal = ({
165
165
  <FormattedMessage {...sharedMessages.cancel} />
166
166
  </Button>
167
167
 
168
- {currentStep < steps.length - 1 &&
168
+ {(currentStep < steps.length - 1 || steps[currentStep]?.isIntermediate) &&
169
169
  (steps[currentStep]?.actions?.length > 0 ? (
170
170
  steps[currentStep].actions.map(action => (
171
171
  <Button
@@ -191,7 +191,7 @@ const StepperModal = ({
191
191
  </Button>
192
192
  ))}
193
193
 
194
- {currentStep === steps.length - 1 && (
194
+ {currentStep === steps.length - 1 && !steps[currentStep]?.isIntermediate && (
195
195
  <Button
196
196
  variant="contained"
197
197
  color="primary"
@@ -335,6 +335,80 @@ describe("StepperModal", () => {
335
335
  expect(okCallback, "was called");
336
336
  });
337
337
 
338
+ it("Renders StepperModal correctly without confirm button for an intermediate step", () => {
339
+ const open = true;
340
+ const title = "title";
341
+ const backdropClickCallback = jest.fn();
342
+ const okCallback = jest.fn();
343
+ const cancelCallback = jest.fn();
344
+ const modalProps = new ModalProps();
345
+ const actions = [
346
+ {
347
+ value: "first value",
348
+ label: "first action",
349
+ Handler: () => {},
350
+ },
351
+ {
352
+ value: "second value",
353
+ label: "second action",
354
+ Handler: () => {},
355
+ },
356
+ ];
357
+ const steps = [{ title: "step1", content: <div>content</div>, actions, isIntermediate: true }];
358
+
359
+ const titleComponent = (
360
+ <div>
361
+ <div>{title}</div>
362
+ <div>step1</div>
363
+ </div>
364
+ );
365
+ const messageComponent = <div>{steps[0].content}</div>;
366
+
367
+ modalProps.set(ModalProps.propNames.title, titleComponent);
368
+ modalProps.set(ModalProps.propNames.open, open);
369
+ modalProps.set(ModalProps.propNames.backdropClickCallback, backdropClickCallback);
370
+ modalProps.set(ModalProps.propNames.type, "wide");
371
+
372
+ const actionPanel = (
373
+ <div>
374
+ <div></div>
375
+ <div>
376
+ <Button variant="outlined" disabled={false} onClick={() => cancelCallback()}>
377
+ {sharedMessages.cancel.defaultMessage}
378
+ </Button>
379
+ <Button variant="contained" color="primary" disabled={false} onClick={() => {}} disableElevation>
380
+ first action
381
+ </Button>
382
+ <Button variant="contained" color="primary" disabled={false} onClick={() => {}} disableElevation>
383
+ second action
384
+ </Button>
385
+ </div>
386
+ </div>
387
+ );
388
+
389
+ modalProps.set(ModalProps.propNames.actionPanel, actionPanel);
390
+
391
+ const component = (
392
+ <IntlProvider locale="en-US" messages={messages}>
393
+ <StepperModal
394
+ steps={steps}
395
+ title={title}
396
+ open={open}
397
+ confirmCallback={okCallback}
398
+ closeCallback={cancelCallback}
399
+ />
400
+ </IntlProvider>
401
+ );
402
+
403
+ const expected = (
404
+ <IntlProvider locale="en-US" messages={messages}>
405
+ <Modal message={messageComponent} modalProps={modalProps} />
406
+ </IntlProvider>
407
+ );
408
+
409
+ expect(component, "when mounted", "to satisfy", expected);
410
+ });
411
+
338
412
  it("Render closed modal", () => {
339
413
  const open = false;
340
414