@brightspace-ui/return-points v1.1.0
return-points
Overview
A set of APIs to get/set a URL to "return to" after launching into a workflow that may have multiple entry points.
Installation
Install from NPM:
npm install @brightspace-ui/return-points
Choosing a Return Point Key
To prevent nested or circular workflows from stepping on each other, each return point must have a unique string-based key. This key must be known by both sides: the source page launching the workflow and the destination page which sends the user back to the source.
Try to make the key as unique as possible for the situation or object being viewed/operated on. Also try to avoid collisions with other applications.
Examples of good keys:
- "D2L.LE.Quizzing.Quiz.Edit.502" (editing quiz with ID=502)
- "D2L.LE.Content.CreateTopic.6609" (workflow to create a new topic in OU=6609)
- "D2L.LP.Profile.View.32346" (viewing profile for user=32346)
Setting the Return Point
Before navigating into the destination workflow, the source page should call
into the set
API using the predetermined key. By default, the current URL
will be used as the return point, but an optional URL can also be provided.
import { setReturnPoint } from '@brightspace-ui/return-points';
setReturnPoint( 'myKey', '/optional/url' );
Getting the Return Point
Once your workflow is complete, you need to return the user back to the source
page. This can be accomplished by navigating to the result of the get
API.
A default location must be provided in case the API can't determine the original source URL. This might occur if the user navigated to the destination directly somehow.
import { getReturnPoint } from '@brightspace-ui/return-points';
const url = getReturnPoint( 'myKey', '/default/url' );
document.location.href = url;
Developing
After cloning the repo, run npm install
to install dependencies.
Linting
npm run lint # lint all files
Testing
npm run test # run lint and unit tests
npm run test:unit # run unit tests
Versioning and Releasing
This repo is configured to use semantic-release
. Commits prefixed with fix:
and feat:
will trigger patch and minor releases when merged to main
.
To learn how to create major releases and release from maintenance branches, refer to the semantic-release GitHub Action documentation.