Commit 982411c0 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch...

Merge branch '334569-docs-links-refactor-on-follow-up-pass-for-renaming-usage-ping-data-to-service-ping-data' into 'master'

Refactor documentation links source for Service Ping disabled component

See merge request gitlab-org/gitlab!67384
parents e5747a54 6ad576e9
<script> <script>
import { GlBadge, GlTable, GlLink, GlEmptyState } from '@gitlab/ui'; import { GlBadge, GlTable, GlLink, GlEmptyState } from '@gitlab/ui';
import { GlSingleStat } from '@gitlab/ui/dist/charts'; import { GlSingleStat } from '@gitlab/ui/dist/charts';
import { helpPagePath } from '~/helpers/help_page_helper';
import { sprintf, s__ } from '~/locale'; import { sprintf, s__ } from '~/locale';
import DevopsScoreCallout from './devops_score_callout.vue'; import DevopsScoreCallout from './devops_score_callout.vue';
...@@ -22,9 +23,6 @@ export default { ...@@ -22,9 +23,6 @@ export default {
devopsScoreMetrics: { devopsScoreMetrics: {
default: null, default: null,
}, },
devopsReportDocsPath: {
default: '',
},
noDataImagePath: { noDataImagePath: {
default: '', default: '',
}, },
...@@ -42,6 +40,7 @@ export default { ...@@ -42,6 +40,7 @@ export default {
return this.devopsScoreMetrics.averageScore === undefined; return this.devopsScoreMetrics.averageScore === undefined;
}, },
}, },
devopsReportDocsPath: helpPagePath('user/admin_area/analytics/dev_ops_report'),
tableHeaderFields: [ tableHeaderFields: [
{ {
key: 'title', key: 'title',
...@@ -76,7 +75,7 @@ export default { ...@@ -76,7 +75,7 @@ export default {
> >
<template #description> <template #description>
<p class="gl-mb-0">{{ __('It may be several days before you see feature usage data.') }}</p> <p class="gl-mb-0">{{ __('It may be several days before you see feature usage data.') }}</p>
<gl-link :href="devopsReportDocsPath">{{ <gl-link :href="$options.devopsReportDocsPath">{{
__('See example DevOps Score page in our documentation.') __('See example DevOps Score page in our documentation.')
}}</gl-link> }}</gl-link>
</template> </template>
......
<script> <script>
import { GlEmptyState, GlSprintf, GlLink, GlButton } from '@gitlab/ui'; import { GlEmptyState, GlSprintf, GlLink, GlButton } from '@gitlab/ui';
import { helpPagePath } from '~/helpers/help_page_helper';
export default { export default {
components: { components: {
...@@ -15,13 +16,11 @@ export default { ...@@ -15,13 +16,11 @@ export default {
svgPath: { svgPath: {
default: '', default: '',
}, },
docsLink: {
default: '',
},
primaryButtonPath: { primaryButtonPath: {
default: '', default: '',
}, },
}, },
docsLink: helpPagePath('development/service_ping/index.md'),
}; };
</script> </script>
<template> <template>
...@@ -36,7 +35,7 @@ export default { ...@@ -36,7 +35,7 @@ export default {
" "
> >
<template #docLink="{ content }"> <template #docLink="{ content }">
<gl-link :href="docsLink" target="_blank" data-testid="docs-link">{{ content }}</gl-link> <gl-link :href="$options.docsLink" target="_blank">{{ content }}</gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
<template v-else> <template v-else>
...@@ -44,12 +43,7 @@ export default { ...@@ -44,12 +43,7 @@ export default {
{{ s__('ServicePing|Turn on service ping to review instance-level analytics.') }} {{ s__('ServicePing|Turn on service ping to review instance-level analytics.') }}
</p> </p>
<gl-button <gl-button category="primary" variant="success" :href="primaryButtonPath">
category="primary"
variant="success"
:href="primaryButtonPath"
data-testid="power-on-button"
>
{{ s__('ServicePing|Turn on service ping') }} {{ s__('ServicePing|Turn on service ping') }}
</gl-button> </gl-button>
</template> </template>
......
...@@ -6,18 +6,12 @@ export default () => { ...@@ -6,18 +6,12 @@ export default () => {
if (!el) return false; if (!el) return false;
const { const { devopsScoreMetrics, noDataImagePath, devopsScoreIntroImagePath } = el.dataset;
devopsScoreMetrics,
devopsReportDocsPath,
noDataImagePath,
devopsScoreIntroImagePath,
} = el.dataset;
return new Vue({ return new Vue({
el, el,
provide: { provide: {
devopsScoreMetrics: JSON.parse(devopsScoreMetrics), devopsScoreMetrics: JSON.parse(devopsScoreMetrics),
devopsReportDocsPath,
noDataImagePath, noDataImagePath,
devopsScoreIntroImagePath, devopsScoreIntroImagePath,
}, },
......
...@@ -11,12 +11,7 @@ export default () => { ...@@ -11,12 +11,7 @@ export default () => {
if (!emptyStateContainer) return false; if (!emptyStateContainer) return false;
const { const { isAdmin, emptyStateSvgPath, enableServicePingPath } = emptyStateContainer.dataset;
isAdmin,
emptyStateSvgPath,
enableServicePingPath,
docsLink,
} = emptyStateContainer.dataset;
return new Vue({ return new Vue({
el: emptyStateContainer, el: emptyStateContainer,
...@@ -24,7 +19,6 @@ export default () => { ...@@ -24,7 +19,6 @@ export default () => {
isAdmin: parseBoolean(isAdmin), isAdmin: parseBoolean(isAdmin),
svgPath: emptyStateSvgPath, svgPath: emptyStateSvgPath,
primaryButtonPath: enableServicePingPath, primaryButtonPath: enableServicePingPath,
docsLink,
}, },
render(h) { render(h) {
return h(ServicePingDisabled); return h(ServicePingDisabled);
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
- if !service_ping_enabled - if !service_ping_enabled
#js-devops-service-ping-disabled{ data: { is_admin: current_user&.admin.to_s, empty_state_svg_path: image_path('illustrations/convdev/convdev_no_index.svg'), enable_service_ping_path: metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings'), docs_link: help_page_path('development/service_ping/index.md') } } #js-devops-service-ping-disabled{ data: { is_admin: current_user&.admin.to_s, empty_state_svg_path: image_path('illustrations/convdev/convdev_no_index.svg'), enable_service_ping_path: metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings'), docs_link: help_page_path('development/service_ping/index.md') } }
- else - else
#js-devops-score{ data: { devops_score_metrics: devops_score_metrics(@metric).to_json, devops_report_docs_path: help_page_path('user/admin_area/analytics/dev_ops_report'), no_data_image_path: image_path('dev_ops_report_no_data.svg'), devops_score_intro_image_path: image_path('dev_ops_report_overview.svg') } } #js-devops-score{ data: { devops_score_metrics: devops_score_metrics(@metric).to_json, no_data_image_path: image_path('dev_ops_report_no_data.svg'), devops_score_intro_image_path: image_path('dev_ops_report_overview.svg') } }
...@@ -13,7 +13,6 @@ export default () => { ...@@ -13,7 +13,6 @@ export default () => {
emptyStateSvgPath, emptyStateSvgPath,
groupId, groupId,
devopsScoreMetrics, devopsScoreMetrics,
devopsReportDocsPath,
devopsScoreIntroImagePath, devopsScoreIntroImagePath,
noDataImagePath, noDataImagePath,
} = el.dataset; } = el.dataset;
...@@ -28,7 +27,6 @@ export default () => { ...@@ -28,7 +27,6 @@ export default () => {
isGroup, isGroup,
groupGid: isGroup ? convertToGraphQLId(TYPE_GROUP, groupId) : null, groupGid: isGroup ? convertToGraphQLId(TYPE_GROUP, groupId) : null,
devopsScoreMetrics: isGroup ? null : JSON.parse(devopsScoreMetrics), devopsScoreMetrics: isGroup ? null : JSON.parse(devopsScoreMetrics),
devopsReportDocsPath,
noDataImagePath, noDataImagePath,
devopsScoreIntroImagePath, devopsScoreIntroImagePath,
}, },
......
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
= _('DevOps Report') = _('DevOps Report')
- if !service_ping_enabled - if !service_ping_enabled
#js-devops-service-ping-disabled{ data: { is_admin: current_user&.admin.to_s, empty_state_svg_path: image_path('illustrations/convdev/convdev_no_index.svg'), enable_service_ping_path: metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings'), docs_link: help_page_path('development/service_ping/index.md') } } #js-devops-service-ping-disabled{ data: { is_admin: current_user&.admin.to_s, empty_state_svg_path: image_path('illustrations/convdev/convdev_no_index.svg'), enable_service_ping_path: metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings') } }
- else - else
.js-devops-adoption{ data: { empty_state_svg_path: image_path('illustrations/monitoring/getting_started.svg'), devops_score_metrics: devops_score_metrics(@metric).to_json, devops_report_docs_path: help_page_path('user/admin_area/analytics/dev_ops_report'), no_data_image_path: image_path('dev_ops_report_no_data.svg'), devops_score_intro_image_path: image_path('dev_ops_report_overview.svg') } } .js-devops-adoption{ data: { empty_state_svg_path: image_path('illustrations/monitoring/getting_started.svg'), devops_score_metrics: devops_score_metrics(@metric).to_json, no_data_image_path: image_path('dev_ops_report_no_data.svg'), devops_score_intro_image_path: image_path('dev_ops_report_overview.svg') } }
import { GlTable, GlBadge, GlEmptyState, GlLink } from '@gitlab/ui'; import { GlTable, GlBadge, GlEmptyState } from '@gitlab/ui';
import { GlSingleStat } from '@gitlab/ui/dist/charts'; import { GlSingleStat } from '@gitlab/ui/dist/charts';
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import DevopsScore from '~/analytics/devops_report/components/devops_score.vue'; import DevopsScore from '~/analytics/devops_report/components/devops_score.vue';
import DevopsScoreCallout from '~/analytics/devops_report/components/devops_score_callout.vue'; import DevopsScoreCallout from '~/analytics/devops_report/components/devops_score_callout.vue';
import { import { devopsScoreMetricsData, noDataImagePath, devopsScoreTableHeaders } from '../mock_data';
devopsScoreMetricsData,
devopsReportDocsPath,
noDataImagePath,
devopsScoreTableHeaders,
} from '../mock_data';
describe('DevopsScore', () => { describe('DevopsScore', () => {
let wrapper; let wrapper;
...@@ -19,7 +14,6 @@ describe('DevopsScore', () => { ...@@ -19,7 +14,6 @@ describe('DevopsScore', () => {
mount(DevopsScore, { mount(DevopsScore, {
provide: { provide: {
devopsScoreMetrics, devopsScoreMetrics,
devopsReportDocsPath,
noDataImagePath, noDataImagePath,
}, },
}), }),
...@@ -32,6 +26,8 @@ describe('DevopsScore', () => { ...@@ -32,6 +26,8 @@ describe('DevopsScore', () => {
const findUsageCol = () => findCol('usageCol'); const findUsageCol = () => findCol('usageCol');
const findDevopsScoreApp = () => wrapper.findByTestId('devops-score-app'); const findDevopsScoreApp = () => wrapper.findByTestId('devops-score-app');
const bannerExists = () => wrapper.findComponent(DevopsScoreCallout).exists(); const bannerExists = () => wrapper.findComponent(DevopsScoreCallout).exists();
const findDocsLink = () =>
wrapper.findByRole('link', { name: 'See example DevOps Score page in our documentation.' });
describe('with no data', () => { describe('with no data', () => {
beforeEach(() => { beforeEach(() => {
...@@ -54,7 +50,10 @@ describe('DevopsScore', () => { ...@@ -54,7 +50,10 @@ describe('DevopsScore', () => {
}); });
it('contains a link to the feature documentation', () => { it('contains a link to the feature documentation', () => {
expect(wrapper.findComponent(GlLink).exists()).toBe(true); expect(findDocsLink().exists()).toBe(true);
expect(findDocsLink().attributes('href')).toBe(
'/help/user/admin_area/analytics/dev_ops_report',
);
}); });
}); });
......
import { GlEmptyState, GlSprintf } from '@gitlab/ui'; import { GlEmptyState, GlSprintf } from '@gitlab/ui';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper';
import ServicePingDisabled from '~/analytics/devops_report/components/service_ping_disabled.vue'; import ServicePingDisabled from '~/analytics/devops_report/components/service_ping_disabled.vue';
describe('~/analytics/devops_report/components/service_ping_disabled.vue', () => { describe('~/analytics/devops_report/components/service_ping_disabled.vue', () => {
...@@ -11,21 +11,19 @@ describe('~/analytics/devops_report/components/service_ping_disabled.vue', () => ...@@ -11,21 +11,19 @@ describe('~/analytics/devops_report/components/service_ping_disabled.vue', () =>
}); });
const createWrapper = ({ isAdmin = false } = {}) => { const createWrapper = ({ isAdmin = false } = {}) => {
wrapper = shallowMountExtended(ServicePingDisabled, { wrapper = mountExtended(ServicePingDisabled, {
provide: { provide: {
isAdmin, isAdmin,
svgPath: TEST_HOST, svgPath: TEST_HOST,
docsLink: TEST_HOST,
primaryButtonPath: TEST_HOST, primaryButtonPath: TEST_HOST,
}, },
stubs: { GlEmptyState, GlSprintf },
}); });
}; };
const findEmptyState = () => wrapper.findComponent(GlEmptyState); const findEmptyState = () => wrapper.findComponent(GlEmptyState);
const findMessageForRegularUsers = () => wrapper.findComponent(GlSprintf); const findMessageForRegularUsers = () => wrapper.findComponent(GlSprintf);
const findDocsLink = () => wrapper.findByTestId('docs-link'); const findDocsLink = () => wrapper.findByRole('link', { name: 'service ping' });
const findPowerOnButton = () => wrapper.findByTestId('power-on-button'); const findPowerOnButton = () => wrapper.findByRole('link', { name: 'Turn on service ping' });
it('renders empty state with provided SVG path', () => { it('renders empty state with provided SVG path', () => {
createWrapper(); createWrapper();
...@@ -45,7 +43,7 @@ describe('~/analytics/devops_report/components/service_ping_disabled.vue', () => ...@@ -45,7 +43,7 @@ describe('~/analytics/devops_report/components/service_ping_disabled.vue', () =>
it('renders docs link', () => { it('renders docs link', () => {
expect(findDocsLink().exists()).toBe(true); expect(findDocsLink().exists()).toBe(true);
expect(findDocsLink().attributes('href')).toBe(TEST_HOST); expect(findDocsLink().attributes('href')).toBe('/help/development/service_ping/index.md');
}); });
}); });
......
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