Commit c35d807b authored by Dave Pisek's avatar Dave Pisek

Add info tooltip to sec primary config

This commit adds an info icon with a tooltip to the configuration
to set a primary security training provider.
parent 7d3cae74
<script> <script>
import { GlAlert, GlCard, GlToggle, GlLink, GlSkeletonLoader } from '@gitlab/ui'; import {
GlAlert,
GlTooltipDirective,
GlCard,
GlToggle,
GlLink,
GlSkeletonLoader,
GlIcon,
} from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
...@@ -25,6 +33,9 @@ const i18n = { ...@@ -25,6 +33,9 @@ const i18n = {
'Could not save configuration. Please refresh the page, or try again later.', 'Could not save configuration. Please refresh the page, or try again later.',
), ),
primaryTraining: s__('SecurityTraining|Primary Training'), primaryTraining: s__('SecurityTraining|Primary Training'),
primaryTrainingDescription: s__(
'SecurityTraining|Training from this partner takes precedence when more than one training partner is enabled.',
),
}; };
export default { export default {
...@@ -34,6 +45,10 @@ export default { ...@@ -34,6 +45,10 @@ export default {
GlToggle, GlToggle,
GlLink, GlLink,
GlSkeletonLoader, GlSkeletonLoader,
GlIcon,
},
directives: {
GlTooltip: GlTooltipDirective,
}, },
mixins: [Tracking.mixin()], mixins: [Tracking.mixin()],
inject: ['projectFullPath'], inject: ['projectFullPath'],
...@@ -236,7 +251,6 @@ export default { ...@@ -236,7 +251,6 @@ export default {
:id="`security-training-provider-${provider.id}`" :id="`security-training-provider-${provider.id}`"
type="radio" type="radio"
:checked="provider.isPrimary" :checked="provider.isPrimary"
name="radio-group-name"
class="custom-control-input" class="custom-control-input"
:disabled="!provider.isEnabled" :disabled="!provider.isEnabled"
@change="setPrimaryProvider(provider)" @change="setPrimaryProvider(provider)"
...@@ -247,6 +261,11 @@ export default { ...@@ -247,6 +261,11 @@ export default {
> >
{{ $options.i18n.primaryTraining }} {{ $options.i18n.primaryTraining }}
</label> </label>
<gl-icon
v-gl-tooltip="$options.i18n.primaryTrainingDescription"
name="information-o"
class="gl-ml-2 gl-cursor-help"
/>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -33115,6 +33115,9 @@ msgstr "" ...@@ -33115,6 +33115,9 @@ msgstr ""
msgid "SecurityTraining|Primary Training" msgid "SecurityTraining|Primary Training"
msgstr "" msgstr ""
msgid "SecurityTraining|Training from this partner takes precedence when more than one training partner is enabled."
msgstr ""
msgid "See example DevOps Score page in our documentation." msgid "See example DevOps Score page in our documentation."
msgstr "" msgstr ""
......
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { GlAlert, GlLink, GlToggle, GlCard, GlSkeletonLoader } from '@gitlab/ui'; import { GlAlert, GlLink, GlToggle, GlCard, GlSkeletonLoader, GlIcon } from '@gitlab/ui';
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { import {
TRACK_TOGGLE_TRAINING_PROVIDER_ACTION, TRACK_TOGGLE_TRAINING_PROVIDER_ACTION,
TRACK_TOGGLE_TRAINING_PROVIDER_LABEL, TRACK_TOGGLE_TRAINING_PROVIDER_LABEL,
...@@ -69,6 +70,9 @@ describe('TrainingProviderList component', () => { ...@@ -69,6 +70,9 @@ describe('TrainingProviderList component', () => {
provide: { provide: {
projectFullPath: testProjectPath, projectFullPath: testProjectPath,
}, },
directives: {
GlTooltip: createMockDirective(),
},
apolloProvider, apolloProvider,
}); });
}; };
...@@ -172,6 +176,16 @@ describe('TrainingProviderList component', () => { ...@@ -172,6 +176,16 @@ describe('TrainingProviderList component', () => {
); );
}); });
it('shows a info-tooltip that describes the purpose of a primary provider', () => {
const infoIcon = findPrimaryProviderRadios().at(index).find(GlIcon);
const tooltip = getBinding(infoIcon.element, 'gl-tooltip');
expect(infoIcon.props()).toMatchObject({
name: 'information-o',
});
expect(tooltip.value).toBe(TrainingProviderList.i18n.primaryTrainingDescription);
});
it('does not show loader when query is populated', () => { it('does not show loader when query is populated', () => {
expect(findLoader().exists()).toBe(false); expect(findLoader().exists()).toBe(false);
}); });
......
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