text-transform: capitalize !important;
}
+.cursor-pointer {
+ cursor: pointer;
+}
+
.cursor-not-allowed {
cursor: not-allowed !important;
}
exports[`should render correctly: jenkins tutorial 1`] = `
<Fragment>
- <JenkinsTutorial
+ <Connect(JenkinsTutorial)
almBinding={
Object {
"key": "key",
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
+import { connect } from 'react-redux';
import { Alert } from 'sonar-ui-common/components/ui/Alert';
import { translate } from 'sonar-ui-common/helpers/l10n';
import {
isBitbucketBindingDefinition,
isProjectBitbucketBindingResponse
} from '../../../helpers/alm-settings';
+import { getCurrentUserSetting, Store } from '../../../store/rootReducer';
+import { setCurrentUserSetting } from '../../../store/users';
import { AlmBindingDefinition, ProjectAlmBindingResponse } from '../../../types/alm-settings';
import BitbucketWebhookStep from './BitbucketWebhookStep';
import JenkinsfileStep from './JenkinsfileStep';
almBinding?: AlmBindingDefinition;
component: T.Component;
projectBinding: ProjectAlmBindingResponse;
+ setCurrentUserSetting: (setting: T.CurrentUserSetting) => void;
+ skipPreReqs: boolean;
}
enum Steps {
Jenkinsfile = 3
}
-export default function JenkinsTutorial(props: JenkinsTutorialProps) {
- const { almBinding, component, projectBinding } = props;
- const [step, setStep] = React.useState(Steps.PreRequisites);
+const USER_SETTING_SKIP_BITBUCKET_PREREQS = 'tutorials.jenkins.skipBitbucketPreReqs';
+
+export function JenkinsTutorial(props: JenkinsTutorialProps) {
+ const { almBinding, component, projectBinding, skipPreReqs } = props;
+ const [step, setStep] = React.useState(
+ skipPreReqs ? Steps.MultiBranchPipeline : Steps.PreRequisites
+ );
// Failsafe; should never happen.
if (!isProjectBitbucketBindingResponse(projectBinding)) {
<PreRequisitesStep
onDone={() => setStep(Steps.MultiBranchPipeline)}
onOpen={() => setStep(Steps.PreRequisites)}
+ onChangeSkipNextTime={skip => {
+ props.setCurrentUserSetting({
+ key: USER_SETTING_SKIP_BITBUCKET_PREREQS,
+ value: skip.toString()
+ });
+ }}
open={step === Steps.PreRequisites}
+ skipNextTime={skipPreReqs}
/>
<MultiBranchPipelineStep
</>
);
}
+
+const mapStateToProps = (state: Store): Pick<JenkinsTutorialProps, 'skipPreReqs'> => {
+ return {
+ skipPreReqs: getCurrentUserSetting(state, USER_SETTING_SKIP_BITBUCKET_PREREQS) === 'true'
+ };
+};
+
+const mapDispatchToProps = { setCurrentUserSetting };
+
+export default connect(mapStateToProps, mapDispatchToProps)(JenkinsTutorial);
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router';
import { Button } from 'sonar-ui-common/components/controls/buttons';
+import Checkbox from 'sonar-ui-common/components/controls/Checkbox';
import { translate } from 'sonar-ui-common/helpers/l10n';
import SentenceWithHighlights from '../components/SentenceWithHighlights';
import Step from '../components/Step';
export interface PreRequisitesStepProps {
+ onChangeSkipNextTime: (skip: boolean) => void;
onDone: () => void;
onOpen: () => void;
open: boolean;
+ skipNextTime: boolean;
}
export default function PreRequisitesStep(props: PreRequisitesStepProps) {
- const { open } = props;
+ const { open, skipNextTime } = props;
return (
<Step
finished={!open}
<p className="big-spacer-bottom">
{translate('onboarding.tutorial.with.jenkins.prereqs.following_are_recommendations')}
</p>
+ <p className="big-spacer-bottom display-flex-center">
+ <label
+ className="cursor-pointer"
+ htmlFor="skip-prereqs"
+ onClick={() => {
+ props.onChangeSkipNextTime(!skipNextTime);
+ }}>
+ {translate('onboarding.tutorial.with.jenkins.prereqs.skip_next_time')}
+ </label>
+ <Checkbox
+ checked={skipNextTime}
+ className="little-spacer-left"
+ id="skip-prereqs"
+ onCheck={props.onChangeSkipNextTime}
+ />
+ </p>
<Button onClick={props.onDone}>
{translate('onboarding.tutorial.with.jenkins.prereqs.done')}
</Button>
import { mockComponent } from '../../../../helpers/testMocks';
import BitbucketWebhookStep from '../BitbucketWebhookStep';
import JenkinsfileStep from '../JenkinsfileStep';
-import JenkinsTutorial, { JenkinsTutorialProps } from '../JenkinsTutorial';
+import { JenkinsTutorial, JenkinsTutorialProps } from '../JenkinsTutorial';
import MultiBranchPipelineStep from '../MultiBranchPipelineStep';
import PreRequisitesStep from '../PreRequisitesStep';
expect(wrapper.find(BitbucketWebhookStep).prop('open')).toBe(true);
});
+it('should correctly store the user setting', () => {
+ const setCurrentUserSetting = jest.fn();
+ const wrapper = shallowRender({ setCurrentUserSetting });
+
+ wrapper.find(PreRequisitesStep).prop('onChangeSkipNextTime')(true);
+ expect(setCurrentUserSetting).toBeCalledWith({
+ key: 'tutorials.jenkins.skipBitbucketPreReqs',
+ value: 'true'
+ });
+
+ wrapper.find(PreRequisitesStep).prop('onChangeSkipNextTime')(false);
+ expect(setCurrentUserSetting).toBeCalledWith({
+ key: 'tutorials.jenkins.skipBitbucketPreReqs',
+ value: 'false'
+ });
+});
+
+it('should correctly skip the pre-reqs step if the user requested it', () => {
+ const wrapper = shallowRender({ skipPreReqs: true });
+ expect(wrapper.find(PreRequisitesStep).prop('open')).toBe(false);
+ expect(wrapper.find(MultiBranchPipelineStep).prop('open')).toBe(true);
+});
+
function shallowRender(props: Partial<JenkinsTutorialProps> = {}) {
return shallow<JenkinsTutorialProps>(
<JenkinsTutorial
component={mockComponent()}
projectBinding={mockProjectBitbucketBindingGet()}
+ setCurrentUserSetting={jest.fn()}
+ skipPreReqs={false}
{...props}
/>
);
function shallowRender(props: Partial<PreRequisitesStepProps> = {}) {
return shallow<PreRequisitesStepProps>(
- <PreRequisitesStep onDone={jest.fn()} onOpen={jest.fn()} open={false} {...props} />
+ <PreRequisitesStep
+ onChangeSkipNextTime={jest.fn()}
+ onDone={jest.fn()}
+ onOpen={jest.fn()}
+ open={false}
+ skipNextTime={true}
+ {...props}
+ />
);
}
</h1>
</div>
<PreRequisitesStep
+ onChangeSkipNextTime={[Function]}
onDone={[Function]}
onOpen={[Function]}
open={true}
+ skipNextTime={false}
/>
<MultiBranchPipelineStep
finished={false}
>
onboarding.tutorial.with.jenkins.prereqs.following_are_recommendations
</p>
+ <p
+ className="big-spacer-bottom display-flex-center"
+ >
+ <label
+ className="cursor-pointer"
+ htmlFor="skip-prereqs"
+ onClick={[Function]}
+ >
+ onboarding.tutorial.with.jenkins.prereqs.skip_next_time
+ </label>
+ <Checkbox
+ checked={true}
+ className="little-spacer-left"
+ id="skip-prereqs"
+ onCheck={[MockFunction]}
+ thirdState={false}
+ />
+ </p>
<Button
onClick={[MockFunction]}
>
value: string;
}
- type CurrentUserSettingNames = 'notifications.optOut' | 'notifications.readDate';
+ type CurrentUserSettingNames =
+ | 'notifications.optOut'
+ | 'notifications.readDate'
+ | 'tutorials.jenkins.skipBitbucketPreReqs';
export interface CustomMeasure {
createdAt?: string;
onboarding.tutorial.with.jenkins.prereqs.step_by_step_guide=For a step by step guide on installing and configuring those plugins in Jenkins, visit the {link} documentation page.
onboarding.tutorial.with.jenkins.prereqs.step_by_step_guide.link=Analysis Prerequisites
onboarding.tutorial.with.jenkins.prereqs.following_are_recommendations=We recommend using the configuration in the following steps for the best results, but you can customize it as needed.
+onboarding.tutorial.with.jenkins.prereqs.skip_next_time=Don't show me the prerequisites next time
onboarding.tutorial.with.jenkins.prereqs.done=Configure Analysis
onboarding.tutorial.with.jenkins.multi_branch_pipeline.title=Create a Multibranch Pipeline Job
onboarding.tutorial.with.jenkins.multi_branch_pipeline.intro=Create a Multibranch Pipeline in order to automatically analyze all your branches and pull requests.