Commit cf0c00c4 authored by Fatih Acet's avatar Fatih Acet

Merge branch...

Merge branch '12245-user-onboarding-calculate-percentagecomplated-instead-of-using-a-hardcoded-value' into 'master'

Resolve "User Onboarding: Calculate `percentageComplated` instead of using a hardcoded value"

Closes #12245

See merge request gitlab-org/gitlab-ee!14260
parents 23fb1a19 3b3340fc
...@@ -48,9 +48,7 @@ export const percentageCompleted = state => { ...@@ -48,9 +48,7 @@ export const percentageCompleted = state => {
return 0; return 0;
} }
return tourData[tourKey][lastStepIndex] return Math.floor((100 * lastStepIndex) / tourData[tourKey].length);
? tourData[tourKey][lastStepIndex].percentageCompleted
: 0;
}; };
export const actionPopover = (state, getters) => export const actionPopover = (state, getters) =>
......
...@@ -34,7 +34,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -34,7 +34,6 @@ const GUIDED_GITLAB_TOUR = [
false, false,
), ),
}, },
percentageCompleted: 0,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/tree/master$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/tree/master$`, ''),
...@@ -68,7 +67,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -68,7 +67,6 @@ const GUIDED_GITLAB_TOUR = [
false, false,
), ),
}, },
percentageCompleted: 8,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/commits/master$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/commits/master$`, ''),
...@@ -84,7 +82,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -84,7 +82,6 @@ const GUIDED_GITLAB_TOUR = [
selector: '.js-onboarding-commit-item', selector: '.js-onboarding-commit-item',
text: s__('UserOnboardingTour|Click to open the latest commit to see its details.'), text: s__('UserOnboardingTour|Click to open the latest commit to see its details.'),
}, },
percentageCompleted: 16,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/commit/[a-z0-9]+$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/commit/[a-z0-9]+$`, ''),
...@@ -115,7 +112,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -115,7 +112,6 @@ const GUIDED_GITLAB_TOUR = [
false, false,
), ),
}, },
percentageCompleted: 24,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/-/branches$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/-/branches$`, ''),
...@@ -149,7 +145,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -149,7 +145,6 @@ const GUIDED_GITLAB_TOUR = [
false, false,
), ),
}, },
percentageCompleted: 32,
}, },
{ {
forUrl: ({ projectFullPath }) => forUrl: ({ projectFullPath }) =>
...@@ -175,7 +170,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -175,7 +170,6 @@ const GUIDED_GITLAB_TOUR = [
false, false,
), ),
}, },
percentageCompleted: 40,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/issues$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/issues$`, ''),
...@@ -204,7 +198,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -204,7 +198,6 @@ const GUIDED_GITLAB_TOUR = [
}, },
], ],
actionPopover: null, actionPopover: null,
percentageCompleted: 48,
}, },
{ {
forUrl: ({ projectFullPath }) => forUrl: ({ projectFullPath }) =>
...@@ -226,7 +219,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -226,7 +219,6 @@ const GUIDED_GITLAB_TOUR = [
selector: '.js-onboarding-issue-item', selector: '.js-onboarding-issue-item',
text: s__('UserOnboardingTour|Open one of the issues by clicking on its title.'), text: s__('UserOnboardingTour|Open one of the issues by clicking on its title.'),
}, },
percentageCompleted: 56,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/issues/[0-9]+$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/issues/[0-9]+$`, ''),
...@@ -259,7 +251,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -259,7 +251,6 @@ const GUIDED_GITLAB_TOUR = [
false, false,
), ),
}, },
percentageCompleted: 64,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/merge_requests$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/merge_requests$`, ''),
...@@ -277,7 +268,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -277,7 +268,6 @@ const GUIDED_GITLAB_TOUR = [
"UserOnboardingTour|Let's take a closer look at a merge request. Click on the title of one.", "UserOnboardingTour|Let's take a closer look at a merge request. Click on the title of one.",
), ),
}, },
percentageCompleted: 72,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/merge_requests/[0-9]+$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/merge_requests/[0-9]+$`, ''),
...@@ -308,7 +298,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -308,7 +298,6 @@ const GUIDED_GITLAB_TOUR = [
false, false,
), ),
}, },
percentageCompleted: 80,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/pipelines$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/pipelines$`, ''),
...@@ -342,7 +331,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -342,7 +331,6 @@ const GUIDED_GITLAB_TOUR = [
false, false,
), ),
}, },
percentageCompleted: 88,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/pipelines/[0-9]+$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/pipelines/[0-9]+$`, ''),
...@@ -392,7 +380,6 @@ const GUIDED_GITLAB_TOUR = [ ...@@ -392,7 +380,6 @@ const GUIDED_GITLAB_TOUR = [
}, },
], ],
actionPopover: null, actionPopover: null,
percentageCompleted: 96,
}, },
]; ];
...@@ -407,7 +394,6 @@ const CREATE_PROJECT_TOUR = [ ...@@ -407,7 +394,6 @@ const CREATE_PROJECT_TOUR = [
), ),
placement: 'bottom', placement: 'bottom',
}, },
percentageCompleted: 0,
}, },
{ {
forUrl: () => new RegExp(`/projects/new\\?*.*$`, ''), forUrl: () => new RegExp(`/projects/new\\?*.*$`, ''),
...@@ -428,7 +414,6 @@ const CREATE_PROJECT_TOUR = [ ...@@ -428,7 +414,6 @@ const CREATE_PROJECT_TOUR = [
}, },
], ],
actionPopover: null, actionPopover: null,
percentageCompleted: 33,
}, },
{ {
forUrl: ({ createdProjectPath }) => new RegExp(`${createdProjectPath}$`, ''), forUrl: ({ createdProjectPath }) => new RegExp(`${createdProjectPath}$`, ''),
...@@ -458,7 +443,6 @@ const CREATE_PROJECT_TOUR = [ ...@@ -458,7 +443,6 @@ const CREATE_PROJECT_TOUR = [
}, },
], ],
actionPopover: null, actionPopover: null,
percentageCompleted: 66,
}, },
]; ];
...@@ -479,7 +463,6 @@ const INVITE_COLLEAGUES_TOUR = [ ...@@ -479,7 +463,6 @@ const INVITE_COLLEAGUES_TOUR = [
false, false,
), ),
}, },
percentageCompleted: 0,
}, },
{ {
forUrl: ({ createdProjectPath }) => new RegExp(`${createdProjectPath}/edit$`, ''), forUrl: ({ createdProjectPath }) => new RegExp(`${createdProjectPath}/edit$`, ''),
...@@ -495,7 +478,6 @@ const INVITE_COLLEAGUES_TOUR = [ ...@@ -495,7 +478,6 @@ const INVITE_COLLEAGUES_TOUR = [
false, false,
), ),
}, },
percentageCompleted: 33,
}, },
{ {
forUrl: ({ createdProjectPath }) => new RegExp(`${createdProjectPath}/-/project_members$`, ''), forUrl: ({ createdProjectPath }) => new RegExp(`${createdProjectPath}/-/project_members$`, ''),
...@@ -522,7 +504,6 @@ const INVITE_COLLEAGUES_TOUR = [ ...@@ -522,7 +504,6 @@ const INVITE_COLLEAGUES_TOUR = [
}, },
], ],
actionPopover: null, actionPopover: null,
percentageCompleted: 66,
}, },
]; ];
......
...@@ -17,7 +17,6 @@ export const mockTourData = { ...@@ -17,7 +17,6 @@ export const mockTourData = {
text: 'foo', text: 'foo',
placement: 'top', placement: 'top',
}, },
percentageCompleted: 10,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/foo/bar$`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/foo/bar$`, ''),
...@@ -31,7 +30,6 @@ export const mockTourData = { ...@@ -31,7 +30,6 @@ export const mockTourData = {
selector: '', selector: '',
text: 'bar', text: 'bar',
}, },
percentageCompleted: 20,
}, },
{ {
forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/xyz`, ''), forUrl: ({ projectFullPath }) => new RegExp(`${projectFullPath}/xyz`, ''),
...@@ -41,7 +39,6 @@ export const mockTourData = { ...@@ -41,7 +39,6 @@ export const mockTourData = {
text: 'foo', text: 'foo',
placement: 'top', placement: 'top',
}, },
percentageCompleted: 30,
}, },
], ],
}; };
......
...@@ -163,7 +163,7 @@ describe('User onboarding store getters', () => { ...@@ -163,7 +163,7 @@ describe('User onboarding store getters', () => {
it('returns the percentage completed for the current step', () => { it('returns the percentage completed for the current step', () => {
localState.lastStepIndex = 1; localState.lastStepIndex = 1;
expect(getters.percentageCompleted(localState)).toBe(20); expect(getters.percentageCompleted(localState)).toBe(33);
}); });
it('returns the 0 if there is no step index', () => { it('returns the 0 if there is no step index', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment