From 935f48195e80db893220d81cda8e547c13a2a143 Mon Sep 17 00:00:00 2001
From: Philippe Perrin
Date: Wed, 18 Aug 2021 11:41:00 +0200
Subject: [PATCH] SONAR-15119 Tutorials shouldn't always mention that the page
will automatically reload
---
.../overview/components/EmptyOverview.tsx | 1 +
.../__snapshots__/EmptyOverview-test.tsx.snap | 2 +
.../tutorials/TutorialSelection.tsx | 10 ++-
.../tutorials/TutorialSelectionRenderer.tsx | 7 +-
.../BitbucketPipelinesTutorial.tsx | 11 ++-
.../BitbucketPipelinesTutorial-test.tsx | 1 +
.../BitbucketPipelinesTutorial-test.tsx.snap | 2 +
.../tutorials/components/AllSet.tsx | 46 ++++++-----
.../tutorials/components/AllSetStep.tsx | 5 +-
.../components/__tests__/AllSet-test.tsx | 1 +
.../components/__tests__/AllSetStep-test.tsx | 8 +-
.../__snapshots__/AllSet-test.tsx.snap | 77 +++++++++++--------
.../__snapshots__/AllSetStep-test.tsx.snap | 1 +
.../github-action/GitHubActionTutorial.tsx | 11 ++-
.../__tests__/GitHubActionTutorial-test.tsx | 1 +
.../GitHubActionTutorial-test.tsx.snap | 2 +
.../tutorials/jenkins/JenkinsTutorial.tsx | 18 ++++-
.../__tests__/JenkinsTutorial-test.tsx | 1 +
.../JenkinsTutorial-test.tsx.snap | 2 +
19 files changed, 146 insertions(+), 61 deletions(-)
diff --git a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx
index 60514ea6101..a17ec366fa0 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx
+++ b/server/sonar-web/src/main/js/apps/overview/components/EmptyOverview.tsx
@@ -94,6 +94,7 @@ export function EmptyOverview(props: EmptyOverviewProps) {
component={component}
currentUser={currentUser}
projectBinding={projectBinding}
+ willRefreshAutomatically={true}
/>
)}
>
diff --git a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap
index 9e3e14188d3..0feced6e7c7 100644
--- a/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap
+++ b/server/sonar-web/src/main/js/apps/overview/components/__tests__/__snapshots__/EmptyOverview-test.tsx.snap
@@ -37,6 +37,7 @@ exports[`renders correctly 1`] = `
"scmAccounts": Array [],
}
}
+ willRefreshAutomatically={true}
/>
`;
@@ -112,6 +113,7 @@ exports[`renders correctly 4`] = `
"repository": "PROJECT_KEY",
}
}
+ willRefreshAutomatically={true}
/>
`;
diff --git a/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx b/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx
index 903fdd3c242..2dd1d3851c9 100644
--- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelection.tsx
@@ -32,6 +32,7 @@ interface Props extends Pick {
component: T.Component;
currentUser: T.LoggedInUser;
projectBinding?: ProjectAlmBindingResponse;
+ willRefreshAutomatically?: boolean;
}
interface State {
@@ -97,7 +98,13 @@ export class TutorialSelection extends React.PureComponent {
};
render() {
- const { component, currentUser, location, projectBinding } = this.props;
+ const {
+ component,
+ currentUser,
+ location,
+ projectBinding,
+ willRefreshAutomatically
+ } = this.props;
const { almBinding, baseUrl, loading } = this.state;
const selectedTutorial: TutorialModes | undefined = location.query?.selectedTutorial;
@@ -112,6 +119,7 @@ export class TutorialSelection extends React.PureComponent {
onSelectTutorial={this.handleSelectTutorial}
projectBinding={projectBinding}
selectedTutorial={selectedTutorial}
+ willRefreshAutomatically={willRefreshAutomatically}
/>
);
}
diff --git a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx
index 28b272f0452..08445cc67fb 100644
--- a/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/TutorialSelectionRenderer.tsx
@@ -39,6 +39,7 @@ export interface TutorialSelectionRendererProps {
onSelectTutorial: (mode: TutorialModes) => void;
projectBinding?: ProjectAlmBindingResponse;
selectedTutorial?: TutorialModes;
+ willRefreshAutomatically?: boolean;
}
const DEFAULT_ICON_SIZE = 80;
@@ -72,7 +73,8 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender
currentUser,
loading,
projectBinding,
- selectedTutorial
+ selectedTutorial,
+ willRefreshAutomatically
} = props;
if (loading) {
@@ -195,6 +197,7 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender
component={component}
currentUser={currentUser}
projectBinding={projectBinding}
+ willRefreshAutomatically={willRefreshAutomatically}
/>
)}
@@ -205,6 +208,7 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender
component={component}
currentUser={currentUser}
projectBinding={projectBinding}
+ willRefreshAutomatically={willRefreshAutomatically}
/>
)}
@@ -214,6 +218,7 @@ export default function TutorialSelectionRenderer(props: TutorialSelectionRender
baseUrl={baseUrl}
component={component}
projectBinding={projectBinding}
+ willRefreshAutomatically={willRefreshAutomatically}
/>
)}
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx
index b41b7749e41..76f314de563 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/BitbucketPipelinesTutorial.tsx
@@ -43,10 +43,18 @@ export interface BitbucketPipelinesTutorialProps {
component: T.Component;
currentUser: T.LoggedInUser;
projectBinding?: ProjectAlmBindingResponse;
+ willRefreshAutomatically?: boolean;
}
export default function BitbucketPipelinesTutorial(props: BitbucketPipelinesTutorialProps) {
- const { almBinding, baseUrl, currentUser, component, projectBinding } = props;
+ const {
+ almBinding,
+ baseUrl,
+ currentUser,
+ component,
+ projectBinding,
+ willRefreshAutomatically
+ } = props;
const [step, setStep] = React.useState(Steps.REPOSITORY_VARIABLES);
return (
@@ -89,6 +97,7 @@ export default function BitbucketPipelinesTutorial(props: BitbucketPipelinesTuto
alm={almBinding?.alm || AlmKeys.BitbucketCloud}
open={step === Steps.ALL_SET}
stepNumber={Steps.ALL_SET}
+ willRefreshAutomatically={willRefreshAutomatically}
/>
>
);
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx
index 8200ad27904..8d070b65f31 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/BitbucketPipelinesTutorial-test.tsx
@@ -79,6 +79,7 @@ function shallowRender(props: Partial = {}) {
currentUser={mockLoggedInUser()}
component={mockComponent()}
projectBinding={mockProjectBitbucketCloudBindingResponse()}
+ willRefreshAutomatically={true}
{...props}
/>
);
diff --git a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-test.tsx.snap
index 819ee58c015..d4841cd4a6c 100644
--- a/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/tutorials/bitbucket-pipelines/__tests__/__snapshots__/BitbucketPipelinesTutorial-test.tsx.snap
@@ -22,6 +22,7 @@ exports[`should render correctly: default 1`] = `
alm="github"
open={false}
stepNumber={3}
+ willRefreshAutomatically={true}
/>
`;
@@ -48,6 +49,7 @@ exports[`should render correctly: no binding 1`] = `
alm="bitbucketcloud"
open={false}
stepNumber={3}
+ willRefreshAutomatically={true}
/>
`;
diff --git a/server/sonar-web/src/main/js/components/tutorials/components/AllSet.tsx b/server/sonar-web/src/main/js/components/tutorials/components/AllSet.tsx
index ad3e794c589..1721c3d3f84 100644
--- a/server/sonar-web/src/main/js/components/tutorials/components/AllSet.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/components/AllSet.tsx
@@ -27,12 +27,14 @@ import SentenceWithHighlights from './SentenceWithHighlights';
export interface AllSetProps {
alm: AlmKeys;
appState: T.AppState;
+ willRefreshAutomatically?: boolean;
}
export function AllSet(props: AllSetProps) {
const {
alm,
- appState: { branchesEnabled }
+ appState: { branchesEnabled },
+ willRefreshAutomatically
} = props;
return (
@@ -64,27 +66,31 @@ export function AllSet(props: AllSetProps) {
-
-
-
+ {willRefreshAutomatically && (
+
+
+
+
+
+
+ {translate('onboarding.tutorial.ci_outro.refresh')}
+
+
{translate('onboarding.tutorial.ci_outro.refresh.why')}
+
-
-
- {translate('onboarding.tutorial.ci_outro.refresh')}
-
-
{translate('onboarding.tutorial.ci_outro.refresh.why')}
-
-
-
-
-
- {translate('onboarding.tutorial.ci_outro.waiting_for_fist_analysis')}
+ )}
+ {willRefreshAutomatically && (
+
+
+ {translate('onboarding.tutorial.ci_outro.waiting_for_fist_analysis')}
+
+ )}
>
);
}
diff --git a/server/sonar-web/src/main/js/components/tutorials/components/AllSetStep.tsx b/server/sonar-web/src/main/js/components/tutorials/components/AllSetStep.tsx
index b18fcbf767f..0146f4968b3 100644
--- a/server/sonar-web/src/main/js/components/tutorials/components/AllSetStep.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/components/AllSetStep.tsx
@@ -27,17 +27,18 @@ export interface AllSetStepProps {
alm: AlmKeys;
open: boolean;
stepNumber: number;
+ willRefreshAutomatically?: boolean;
}
export default function AllSetStep(props: AllSetStepProps) {
- const { alm, open, stepNumber } = props;
+ const { alm, open, stepNumber, willRefreshAutomatically } = props;
return (
(
)}
stepNumber={stepNumber}
diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSet-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSet-test.tsx
index ad59543f79b..6d1d2ac58c0 100644
--- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSet-test.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSet-test.tsx
@@ -28,6 +28,7 @@ it('should render correctly', () => {
expect(shallowRender({ appState: mockAppState({ branchesEnabled: false }) })).toMatchSnapshot(
'without branch'
);
+ expect(shallowRender({ willRefreshAutomatically: true })).toMatchSnapshot('with auto refresh');
});
function shallowRender(props: Partial = {}) {
diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSetStep-test.tsx b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSetStep-test.tsx
index 99823160b42..388812ec825 100644
--- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSetStep-test.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/AllSetStep-test.tsx
@@ -31,6 +31,12 @@ it('should render correctly', () => {
function shallowRender(props: Partial = {}) {
return shallow(
-
+
);
}
diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSet-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSet-test.tsx.snap
index 5b3d13d45d1..b34ae3f4df4 100644
--- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSet-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSet-test.tsx.snap
@@ -1,6 +1,51 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`should render correctly 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+ onboarding.tutorial.ci_outro.commit
+
+
+
+ onboarding.tutorial.ci_outro.commit.why.github
+
+
+
+
+
+`;
+
+exports[`should render correctly: with auto refresh 1`] = `
-
-
-
-
-
-
-
- onboarding.tutorial.ci_outro.refresh
-
-
-
- onboarding.tutorial.ci_outro.refresh.why
-
-
-
-
-
-
- onboarding.tutorial.ci_outro.waiting_for_fist_analysis
`;
diff --git a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSetStep-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSetStep-test.tsx.snap
index 12deb834a0e..81965c60b99 100644
--- a/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSetStep-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/tutorials/components/__tests__/__snapshots__/AllSetStep-test.tsx.snap
@@ -16,6 +16,7 @@ exports[`should render correctly: step content 1`] = `
>
`;
diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx
index 03647bf12c0..7be0f3252a0 100644
--- a/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/github-action/GitHubActionTutorial.tsx
@@ -42,10 +42,18 @@ export interface GitHubActionTutorialProps {
component: T.Component;
currentUser: T.LoggedInUser;
projectBinding?: ProjectAlmBindingResponse;
+ willRefreshAutomatically?: boolean;
}
export default function GitHubActionTutorial(props: GitHubActionTutorialProps) {
- const { almBinding, baseUrl, currentUser, component, projectBinding } = props;
+ const {
+ almBinding,
+ baseUrl,
+ currentUser,
+ component,
+ projectBinding,
+ willRefreshAutomatically
+ } = props;
const [step, setStep] = React.useState(Steps.CREATE_SECRET);
return (
@@ -89,6 +97,7 @@ export default function GitHubActionTutorial(props: GitHubActionTutorialProps) {
alm={almBinding?.alm || AlmKeys.GitHub}
open={step === Steps.ALL_SET}
stepNumber={Steps.ALL_SET}
+ willRefreshAutomatically={willRefreshAutomatically}
/>
>
);
diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx
index 891c84a1e1d..e656347bebc 100644
--- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/GitHubActionTutorial-test.tsx
@@ -77,6 +77,7 @@ function shallowRender(props: Partial = {}) {
currentUser={mockLoggedInUser()}
component={mockComponent()}
projectBinding={mockProjectGithubBindingResponse()}
+ willRefreshAutomatically={true}
{...props}
/>
);
diff --git a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GitHubActionTutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GitHubActionTutorial-test.tsx.snap
index bea7818d24e..1294b757150 100644
--- a/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GitHubActionTutorial-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/tutorials/github-action/__tests__/__snapshots__/GitHubActionTutorial-test.tsx.snap
@@ -22,6 +22,7 @@ exports[`should render correctly: default 1`] = `
alm="github"
open={false}
stepNumber={3}
+ willRefreshAutomatically={true}
/>
`;
@@ -48,6 +49,7 @@ exports[`should render correctly: no binding 1`] = `
alm="github"
open={false}
stepNumber={3}
+ willRefreshAutomatically={true}
/>
`;
diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsTutorial.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsTutorial.tsx
index 443bc98e516..0af21063e28 100644
--- a/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsTutorial.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsTutorial.tsx
@@ -43,6 +43,7 @@ export interface JenkinsTutorialProps {
projectBinding?: ProjectAlmBindingResponse;
setCurrentUserSetting: (setting: T.CurrentUserSetting) => void;
skipPreReqs: boolean;
+ willRefreshAutomatically?: boolean;
}
enum Steps {
@@ -57,7 +58,15 @@ enum Steps {
const USER_SETTING_SKIP_BITBUCKET_PREREQS = 'tutorials.jenkins.skipBitbucketPreReqs';
export function JenkinsTutorial(props: JenkinsTutorialProps) {
- const { almBinding, baseUrl, branchesEnabled, component, projectBinding, skipPreReqs } = props;
+ const {
+ almBinding,
+ baseUrl,
+ branchesEnabled,
+ component,
+ projectBinding,
+ skipPreReqs,
+ willRefreshAutomatically
+ } = props;
const hasSelectAlmStep = projectBinding?.alm === undefined;
const [alm, setAlm] = React.useState(projectBinding?.alm);
@@ -145,7 +154,12 @@ export function JenkinsTutorial(props: JenkinsTutorialProps) {
open={step === Steps.Jenkinsfile}
/>
-
+
>
)}
>
diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-test.tsx b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-test.tsx
index b01c8d7e8d4..9e48708164f 100644
--- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-test.tsx
+++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/JenkinsTutorial-test.tsx
@@ -138,6 +138,7 @@ function shallowRender(props: Partial = {}) {
projectBinding={mockProjectBitbucketBindingResponse()}
setCurrentUserSetting={jest.fn()}
skipPreReqs={false}
+ willRefreshAutomatically={true}
{...props}
/>
);
diff --git a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-test.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-test.tsx.snap
index e8c3dfb49ce..7858029d190 100644
--- a/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-test.tsx.snap
+++ b/server/sonar-web/src/main/js/components/tutorials/jenkins/__tests__/__snapshots__/JenkinsTutorial-test.tsx.snap
@@ -78,6 +78,7 @@ exports[`should render correctly: branches not enabled 1`] = `
alm="bitbucket"
open={false}
stepNumber={4}
+ willRefreshAutomatically={true}
/>
`;
@@ -169,6 +170,7 @@ exports[`should render correctly: default 1`] = `
alm="bitbucket"
open={false}
stepNumber={4}
+ willRefreshAutomatically={true}
/>
`;
--
2.39.5