-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Guided onboarding] Dynamic URLs for steps (#154572)
## Summary Fixes #143322 This PR adds an option to store dynamic parameters when a step is completed to be used later for dynamically built URLs. ### How to test 1. Add `xpack.cloud.id: 'testID'` to your `/config/kibana.dev.yml` file 2. Start ES with `yarn es snapshot` 3. Start Kibana with `yarn start --run-examples` 4. Navigate to the guided onboarding example plugin `http://localhost:5601/app/guidedOnboardingExample` 5. Start the test guide and when completing step 1 provide any value for the paramter `indexName` 6. Continue the guide until step 4 and check that the correct value is being used for the url of this step. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
89258d7
commit bc3471c
Showing
19 changed files
with
403 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
examples/guided_onboarding_example/public/components/step_four.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
|
||
import { EuiButton, EuiSpacer, EuiText, EuiTitle } from '@elastic/eui'; | ||
|
||
import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/public/types'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { | ||
EuiPageContentHeader_Deprecated as EuiPageContentHeader, | ||
EuiPageContentBody_Deprecated as EuiPageContentBody, | ||
EuiCode, | ||
} from '@elastic/eui'; | ||
import { RouteComponentProps } from 'react-router-dom'; | ||
|
||
interface StepFourProps { | ||
guidedOnboarding: GuidedOnboardingPluginStart; | ||
} | ||
|
||
export const StepFour = (props: StepFourProps & RouteComponentProps<{ indexName: string }>) => { | ||
const { | ||
guidedOnboarding: { guidedOnboardingApi }, | ||
match: { | ||
params: { indexName }, | ||
}, | ||
} = props; | ||
|
||
const [, setIsTourStepOpen] = useState<boolean>(false); | ||
|
||
useEffect(() => { | ||
const subscription = guidedOnboardingApi | ||
?.isGuideStepActive$('testGuide', 'step4') | ||
.subscribe((isStepActive) => { | ||
setIsTourStepOpen(isStepActive); | ||
}); | ||
return () => subscription?.unsubscribe(); | ||
}, [guidedOnboardingApi]); | ||
|
||
return ( | ||
<> | ||
<EuiPageContentHeader> | ||
<EuiTitle> | ||
<h2> | ||
<FormattedMessage | ||
id="guidedOnboardingExample.stepFour.title" | ||
defaultMessage="Example step 4" | ||
/> | ||
</h2> | ||
</EuiTitle> | ||
</EuiPageContentHeader> | ||
<EuiPageContentBody> | ||
<EuiText> | ||
<p> | ||
<FormattedMessage | ||
id="guidedOnboardingExample.guidesSelection.stepFour.explanation" | ||
defaultMessage="This step has a dynamic URL with a param {indexName} passed in step 1" | ||
values={{ | ||
indexName: ( | ||
<EuiCode language="javascript">{indexName: {indexName}}</EuiCode> | ||
), | ||
}} | ||
/> | ||
</p> | ||
</EuiText> | ||
<EuiSpacer /> | ||
|
||
<EuiButton | ||
onClick={async () => { | ||
await guidedOnboardingApi?.completeGuideStep('testGuide', 'step4'); | ||
}} | ||
> | ||
Complete step 4 | ||
</EuiButton> | ||
</EuiPageContentBody> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.