11.1.2 • Published 22 days ago

@talend/react-stepper v11.1.2

Weekly downloads
544
License
Apache-2.0
Repository
github
Last release
22 days ago

Stepper

What it does

This component provides a service to show progress when we have long loading steps.
The main purpose is to have this workflow ->

  • Init the steps with labels & set events to fail / success
  • When you have some progress in the app, you have dispatchers available

Here, it will not make the process work by itself, it's an api that provide tools to update the state

Bootstrap

First of all, you have to register the module in your application, it's the default export of the module :

// index.js file
import StepperModule from '@talend/react-stepper';

export default {
	id: 'MyModuleName',
	// ... Modules stuff
	modules: [StepperModule, ...myOtherModules],
};

Initialize

After bootstrapping the module, there is a reducer listening the events. StepperService provides some actionCreators to manage the loading state. For each of these action creators, some parameters are required: the resourceType & the resourceId. Theses parameters allow the Stepper service to identify each loading with uniqueness.

What is a step

A step is an object that matches this typescript interface :

interface Step {
	label: string; // displayed aside the icon
	message: string; // displayed as a description for what could go wrong
	status: LOADING_STEP_STATUSES; // match the icon to show
	loadingOn: string[] | string; // list of event for set to loading state
	failureOn: string[] | string; // list of event for set to failure state
	successOn: string[] | string; // list of event for set to success state
}

Action Creators

initStepper

This action is used to bootstrap a loading resourceType / resourceId. Steps are required to do so

import { StepperActions, StepperConstants } from '@talend/react-stepper';

const steps = [
	{
		label: 'Fetch Sample',
		status: StepperConstants.LOADING_STEP_STATUSES.LOADING,
		failureOn: ['FETCH_SAMPLE_ACCESS_FAILURE', 'SAMPLE_FETCHING_FAILURE'],
		successOn: 'SAMPLE_FETCHED',
	},
	{
		label: 'Update Sample',
		failureOn: ['SAMPLE_UPDATE_FAILURE', 'SAMPLE_REFRESH_FAILURE'],
		loadingOn: 'SAMPLE_FETCHED',
		successOn: 'SAMPLE_REFRESHED',
	},
	{
		label: 'Update Quality',
		failureOn: 'SAMPLE_QUALITY_FAILURE',
		loadingOn: 'SAMPLE_REFRESHED',
		successOn: 'SAMPLE_QUALITY_SUCCESS',
	},
];

StepperActions.initStepper('dataset', 'id12', steps);

removeStepper

This action is used when a loading is over and we want to remove it from the store it requires only the resourceType & the resourceId

StepperActions.removeStepper('dataset', 'id12');

proceedLoadingEvent

This action is used when an event has to be processed, the workflow for a dispatched event is :

  • If a step has a successOn as event, the current step status is set to success
  • If a step has a loadingOn as event, the current step status is set to loading
  • If a step has a failureOn as event, the current step status is set to failure & all the steps that are not in success status are set to aborted

A message can be also passed to the failure event to display a label below the current fail step

const failAction = StepperActions.proceedLoadingEvent(
	'dataset',
	'id12',
	'FETCH_SAMPLE_ACCESS_FAILURE',
	'This call has failed because the remote engine is not working',
);

Selectors

isResourceLoading

You may want to know for some use cases if a loading step is currently in loading state, it will return a boolean to say if it's finished. ⚠️ In the current API, if there is an error, the steps are considered finished even if the component is still rendered To have this information, you can use isResourceLoading selector :

import { StepperSelectors } from '@talend/react-stepper';

function mapStateToProps(store) {
	const isLoading = StepperSelectors.isResourceLoading(store, 'dataset', 'id12');
}

getStepsForResource

For some use cases, you may want to get the current state of the steps. It could be to know if the loading step has ended but with an error or to count how many steps are done... It will return the step with the same given model shape at init.

import { StepperSelectors } from '@talend/react-stepper';

function mapStateToProps(store) {
	const steps = StepperSelectors.getStepsForResource(store, 'dataset', 'id12');
}

Utils

isAllSuccessful

Take a list of steps in parameter and tell if all the steps are in a success state

import { StepperUtils } from '@talend/react-stepper';

// ... get the steps
const steps = StepperUtils.isAllSuccessful(steps);

isErrorInSteps

Take a list of steps in parameter and tell if there is an error in the steps

import { StepperUtils } from '@talend/react-stepper';

// ... get the steps
const steps = StepperUtils.isErrorInSteps(steps);

isStepsLoading

Take a list of steps in parameter and tell if the loading steps is still loading

import { StepperUtils } from '@talend/react-stepper';

// ... get the steps
const steps = StepperUtils.isStepsLoading(steps);
11.1.2

22 days ago

11.1.1

29 days ago

11.1.0

2 months ago

11.0.0

2 months ago

11.0.1

2 months ago

10.2.1

3 months ago

10.2.0

3 months ago

10.1.2

4 months ago

10.1.1

4 months ago

10.0.0

5 months ago

8.1.0

7 months ago

9.0.0

5 months ago

9.1.0

5 months ago

10.1.0

5 months ago

8.0.0

8 months ago

7.2.0

11 months ago

7.1.5

1 year ago

7.1.4

1 year ago

7.1.3

1 year ago

7.1.2

2 years ago

7.1.1

2 years ago

7.1.0

2 years ago

6.36.6

2 years ago

7.0.0

2 years ago

7.0.2

2 years ago

7.0.1

2 years ago

6.36.5

2 years ago

6.36.4

2 years ago

6.36.3

3 years ago

6.36.2

3 years ago

6.36.1

3 years ago

6.36.0

3 years ago

6.35.0

3 years ago

6.34.0

3 years ago

6.33.0

3 years ago

6.32.0

3 years ago

6.31.0

3 years ago

6.30.0

3 years ago

6.29.0

3 years ago

6.28.0

3 years ago

6.27.0

3 years ago

6.26.0

3 years ago

6.25.0

3 years ago

6.24.0

3 years ago

6.24.1

3 years ago

6.23.0

3 years ago

6.22.0

3 years ago

6.21.0

3 years ago

6.20.0

3 years ago

6.19.0

3 years ago

6.18.0

3 years ago

6.17.0

3 years ago

6.16.0

3 years ago

6.15.1

3 years ago

6.15.0

3 years ago

6.14.2

3 years ago

6.14.1

3 years ago

6.14.0

3 years ago

7.0.0-alpha.1

3 years ago

6.13.0

3 years ago

6.12.0

3 years ago

6.11.1

3 years ago

6.12.0-alpha.0

3 years ago

6.11.0

3 years ago

6.10.1

3 years ago

6.10.0

3 years ago

6.9.1

3 years ago

6.9.0

3 years ago

6.8.0

3 years ago

6.7.0

3 years ago

6.6.0

3 years ago

6.5.1

3 years ago

6.5.0

3 years ago

6.4.0

3 years ago

6.3.1

3 years ago

6.3.0

3 years ago

6.2.4

3 years ago

6.2.3

3 years ago

6.2.1

3 years ago

6.2.0

3 years ago

6.2.2

3 years ago

5.31.0

3 years ago

6.1.8

3 years ago

5.30.3

3 years ago

6.1.7

3 years ago

5.30.2

3 years ago

6.1.6

3 years ago

6.1.4

3 years ago

6.1.5

3 years ago

6.1.2

3 years ago

6.1.3

3 years ago

5.30.1

3 years ago

6.1.1

3 years ago

6.1.0

3 years ago

5.30.0

3 years ago

6.0.1

3 years ago

5.29.4

3 years ago

6.0.0

3 years ago

5.29.3

3 years ago

5.29.2

3 years ago

5.29.1

3 years ago

5.29.0

3 years ago

5.28.1-alpha.0

3 years ago

6.0.0-ds.0

3 years ago

5.29.0-alpha.0

3 years ago

5.28.0

3 years ago

5.27.1

3 years ago

5.27.0

3 years ago

6.0.0-alpha.43

3 years ago

6.0.0-alpha.41

3 years ago

6.0.0-alpha.42

3 years ago

6.0.0-alpha.40

3 years ago

6.0.0-ds-alpha.3

3 years ago

6.0.0-alpha.39

3 years ago

5.26.0

3 years ago

6.0.0-ds-alpha.2

3 years ago

6.0.0-alpha.38

3 years ago

6.0.0-ds-alpha.0

3 years ago

6.0.0-alpha.37

3 years ago

6.0.0-alpha.36

3 years ago

6.0.0-alpha.35

3 years ago

6.0.0-alpha.34

3 years ago

6.0.0-alpha.29

3 years ago

6.0.0-alpha.30

3 years ago

6.0.0-alpha.31

3 years ago

6.0.0-alpha.32

3 years ago

6.0.0-alpha.33

3 years ago

5.25.0

3 years ago

6.0.0-alpha.28

3 years ago

6.0.0-alpha.27

3 years ago

6.0.0-alpha.25

3 years ago

6.0.0-alpha.26

3 years ago

6.0.0-alpha.22

3 years ago

6.0.0-alpha.23

3 years ago

6.0.0-alpha.24

3 years ago

6.0.0-alpha.21

3 years ago

6.0.0-y.0

3 years ago

6.0.0-alpha.20

3 years ago

6.0.0-alpha.19

3 years ago

5.24.0

3 years ago

6.0.0-alpha.18

3 years ago

6.0.0-alpha.17

3 years ago

5.23.0

3 years ago

6.0.0-alpha.16

3 years ago

6.0.0-alpha.15

3 years ago

6.0.0-alpha.14

3 years ago

6.0.0-alpha.13

3 years ago

5.22.1

3 years ago

5.22.0

4 years ago

6.0.0-alpha.12

4 years ago

5.21.0

4 years ago

6.0.0-alpha.11

4 years ago

5.20.0

4 years ago

5.20.0-alpha.0

4 years ago

5.19.0

4 years ago

5.18.0

4 years ago

5.17.0

4 years ago

5.16.0

4 years ago

5.15.0

4 years ago

5.14.0

4 years ago

5.14.0-alpha.0

4 years ago

5.13.0

4 years ago

5.12.0

4 years ago

5.11.0

4 years ago

6.0.0-alpha.9

4 years ago

6.0.0-alpha.10

4 years ago

5.10.3

4 years ago

5.9.2

4 years ago

5.7.2

4 years ago

6.0.0-alpha.8

4 years ago

5.10.2

4 years ago

5.9.1

4 years ago

6.0.0-alpha.7

4 years ago

5.10.1

4 years ago

5.10.0

4 years ago

5.7.1

4 years ago

6.0.0-alpha.6

4 years ago

6.0.0-alpha.3

4 years ago

6.0.0-alpha.4

4 years ago

6.0.0-alpha.5

4 years ago

6.0.0-alpha.2

4 years ago

6.0.0-alpha.1

4 years ago

6.0.0-alpha.0

4 years ago

5.9.0

4 years ago

5.8.0

4 years ago

5.7.0

4 years ago

5.6.0

4 years ago

5.1.3

4 years ago

5.5.0

4 years ago

5.5.0-alpha.0

4 years ago

5.4.0

4 years ago

5.3.0

4 years ago

4.38.2

4 years ago

4.38.1

4 years ago

4.38.0

4 years ago

5.2.0

4 years ago

5.2.0-y.4

4 years ago

5.1.2

4 years ago

5.2.0-y.1

4 years ago

5.2.0-y.0

4 years ago

4.37.1

4 years ago

5.1.2-alpha.2

4 years ago

5.1.1

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

4.37.0

4 years ago

4.36.3

4 years ago

4.36.2

4 years ago

4.36.1

4 years ago

4.36.0

4 years ago

4.35.0

4 years ago

4.34.1

4 years ago

4.34.0

4 years ago

4.32.2

4 years ago

4.33.0

4 years ago

4.32.1

4 years ago

4.32.0

4 years ago

4.32.0-0

4 years ago

4.31.0

4 years ago

4.30.0

4 years ago

4.29.0

4 years ago

4.28.1

4 years ago

4.28.0

4 years ago

4.27.0

4 years ago

4.26.0

4 years ago

4.26.1

4 years ago

4.26.2

4 years ago

4.25.0

4 years ago

4.25.0-0

4 years ago

4.24.0

4 years ago

4.23.0

4 years ago

4.23.0-0

4 years ago

4.21.1

4 years ago

4.22.0

4 years ago

4.21.0

4 years ago

4.19.1

4 years ago

4.20.0

4 years ago

4.19.0

4 years ago

4.19.0-1

4 years ago

4.19.0-0

4 years ago

4.18.0

4 years ago

4.17.0

4 years ago

4.16.0

4 years ago

4.15.0

4 years ago

4.14.0

4 years ago

4.14.0-1

4 years ago

4.14.0-0

4 years ago

4.13.0

4 years ago

4.13.0-1

4 years ago

4.10.3

4 years ago

4.13.0-0

4 years ago

4.12.0

4 years ago

4.11.0

4 years ago

4.10.2

5 years ago

4.10.1

5 years ago

4.10.0

5 years ago