Commit 58849b24 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'fix-provider-logo-not-working-prod' into 'master'

Fix security provider logo

See merge request gitlab-org/gitlab!82929
parents d79cdb40 cf535999
...@@ -16,6 +16,8 @@ import { ...@@ -16,6 +16,8 @@ import {
REPORT_TYPE_LICENSE_COMPLIANCE, REPORT_TYPE_LICENSE_COMPLIANCE,
} from '~/vue_shared/security_reports/constants'; } from '~/vue_shared/security_reports/constants';
import kontraLogo from 'images/vulnerability/kontra-logo.svg';
import scwLogo from 'images/vulnerability/scw-logo.svg';
import configureSastMutation from '../graphql/configure_sast.mutation.graphql'; import configureSastMutation from '../graphql/configure_sast.mutation.graphql';
import configureSastIacMutation from '../graphql/configure_iac.mutation.graphql'; import configureSastIacMutation from '../graphql/configure_iac.mutation.graphql';
import configureSecretDetectionMutation from '../graphql/configure_secret_detection.mutation.graphql'; import configureSecretDetectionMutation from '../graphql/configure_secret_detection.mutation.graphql';
...@@ -284,9 +286,9 @@ export const AUTO_DEVOPS_ENABLED_ALERT_DISMISSED_STORAGE_KEY = ...@@ -284,9 +286,9 @@ export const AUTO_DEVOPS_ENABLED_ALERT_DISMISSED_STORAGE_KEY =
// https://gitlab.com/gitlab-org/gitlab/-/issues/346899 // https://gitlab.com/gitlab-org/gitlab/-/issues/346899
export const TEMP_PROVIDER_LOGOS = { export const TEMP_PROVIDER_LOGOS = {
Kontra: { Kontra: {
svg: '/assets/vulnerability/kontra-logo.svg', svg: kontraLogo,
}, },
[__('Secure Code Warrior')]: { [__('Secure Code Warrior')]: {
svg: '/assets/vulnerability/scw-logo.svg', svg: scwLogo,
}, },
}; };
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
GlLink, GlLink,
GlSkeletonLoader, GlSkeletonLoader,
GlIcon, GlIcon,
GlSafeHtmlDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
...@@ -50,6 +51,7 @@ export default { ...@@ -50,6 +51,7 @@ export default {
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
SafeHtml: GlSafeHtmlDirective,
}, },
mixins: [Tracking.mixin()], mixins: [Tracking.mixin()],
inject: ['projectFullPath'], inject: ['projectFullPath'],
...@@ -233,11 +235,12 @@ export default { ...@@ -233,11 +235,12 @@ export default {
@change="toggleProvider(provider)" @change="toggleProvider(provider)"
/> />
<div v-if="$options.TEMP_PROVIDER_LOGOS[provider.name]" class="gl-ml-4"> <div v-if="$options.TEMP_PROVIDER_LOGOS[provider.name]" class="gl-ml-4">
<img <div
:src="$options.TEMP_PROVIDER_LOGOS[provider.name].svg" v-safe-html="$options.TEMP_PROVIDER_LOGOS[provider.name].svg"
width="18" data-testid="provider-logo"
style="width: 18px"
role="presentation" role="presentation"
/> ></div>
</div> </div>
<div class="gl-ml-3"> <div class="gl-ml-3">
<h3 class="gl-font-lg gl-m-0 gl-mb-2">{{ provider.name }}</h3> <h3 class="gl-font-lg gl-m-0 gl-mb-2">{{ provider.name }}</h3>
......
<script> <script>
import { GlLink, GlIcon, GlSkeletonLoader } from '@gitlab/ui'; import { GlLink, GlIcon, GlSkeletonLoader, GlSafeHtmlDirective } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
import securityTrainingProvidersQuery from '~/security_configuration/graphql/security_training_providers.query.graphql'; import securityTrainingProvidersQuery from '~/security_configuration/graphql/security_training_providers.query.graphql';
...@@ -30,6 +30,9 @@ export default { ...@@ -30,6 +30,9 @@ export default {
GlIcon, GlIcon,
GlSkeletonLoader, GlSkeletonLoader,
}, },
directives: {
SafeHtml: GlSafeHtmlDirective,
},
mixins: [glFeatureFlagsMixin(), Tracking.mixin()], mixins: [glFeatureFlagsMixin(), Tracking.mixin()],
props: { props: {
projectFullPath: { projectFullPath: {
...@@ -162,7 +165,12 @@ export default { ...@@ -162,7 +165,12 @@ export default {
<div v-for="({ name, url }, index) in securityTrainingUrls" :key="index" class="gl-mt-6"> <div v-for="({ name, url }, index) in securityTrainingUrls" :key="index" class="gl-mt-6">
<div> <div>
<span v-if="$options.TEMP_PROVIDER_LOGOS[name]" class="gl-mr-1 gl-display-inline-flex"> <span v-if="$options.TEMP_PROVIDER_LOGOS[name]" class="gl-mr-1 gl-display-inline-flex">
<img :src="$options.TEMP_PROVIDER_LOGOS[name].svg" width="12" role="presentation" /> <div
v-safe-html="$options.TEMP_PROVIDER_LOGOS[name].svg"
data-testid="provider-logo"
style="width: 12px"
role="presentation"
></div>
</span> </span>
<span class="gl-font-weight-bold gl-font-base">{{ name }}</span> <span class="gl-font-weight-bold gl-font-base">{{ name }}</span>
</div> </div>
......
...@@ -99,7 +99,7 @@ describe('VulnerabilityTraining component', () => { ...@@ -99,7 +99,7 @@ describe('VulnerabilityTraining component', () => {
const findTrainingItemName = (name) => wrapper.findByText(name); const findTrainingItemName = (name) => wrapper.findByText(name);
const findTrainingItemLinks = () => wrapper.findAllComponents(GlLink); const findTrainingItemLinks = () => wrapper.findAllComponents(GlLink);
const findTrainingItemLinkIcons = () => wrapper.findAllComponents(GlIcon); const findTrainingItemLinkIcons = () => wrapper.findAllComponents(GlIcon);
const findTrainingLogos = () => wrapper.findAll('img'); const findTrainingLogos = () => wrapper.findAllByTestId('provider-logo');
describe('with the query being successful', () => { describe('with the query being successful', () => {
describe('basic structure', () => { describe('basic structure', () => {
...@@ -225,15 +225,15 @@ describe('VulnerabilityTraining component', () => { ...@@ -225,15 +225,15 @@ describe('VulnerabilityTraining component', () => {
const providerIndexArray = [0, 1]; const providerIndexArray = [0, 1];
it.each(providerIndexArray)('displays the correct width for training item %s', (index) => { it.each(providerIndexArray)('displays the correct width for training item %s', (index) => {
expect(findTrainingLogos().at(index).attributes('width')).toBe('12'); expect(findTrainingLogos().at(index).attributes('style')).toBe('width: 12px;');
}); });
it.each(providerIndexArray)('has a11y decorative attribute for provider %s', (index) => { it.each(providerIndexArray)('has a11y decorative attribute for provider %s', (index) => {
expect(findTrainingLogos().at(index).attributes('role')).toBe('presentation'); expect(findTrainingLogos().at(index).attributes('role')).toBe('presentation');
}); });
it.each(providerIndexArray)('displays the correct svg path for training item %s', (index) => { it.each(providerIndexArray)('renders the svg content for training item %s', (index) => {
expect(findTrainingLogos().at(index).attributes('src')).toBe( expect(findTrainingLogos().at(index).html()).toContain(
tempProviderLogos[testProviderName[index]].svg, tempProviderLogos[testProviderName[index]].svg,
); );
}); });
......
...@@ -89,7 +89,7 @@ describe('TrainingProviderList component', () => { ...@@ -89,7 +89,7 @@ describe('TrainingProviderList component', () => {
const findPrimaryProviderRadios = () => wrapper.findAllByTestId('primary-provider-radio'); const findPrimaryProviderRadios = () => wrapper.findAllByTestId('primary-provider-radio');
const findLoader = () => wrapper.findComponent(GlSkeletonLoader); const findLoader = () => wrapper.findComponent(GlSkeletonLoader);
const findErrorAlert = () => wrapper.findComponent(GlAlert); const findErrorAlert = () => wrapper.findComponent(GlAlert);
const findLogos = () => wrapper.findAll('img'); const findLogos = () => wrapper.findAllByTestId('provider-logo');
const toggleFirstProvider = () => findFirstToggle().vm.$emit('change', testProviderIds[0]); const toggleFirstProvider = () => findFirstToggle().vm.$emit('change', testProviderIds[0]);
...@@ -205,15 +205,15 @@ describe('TrainingProviderList component', () => { ...@@ -205,15 +205,15 @@ describe('TrainingProviderList component', () => {
const providerIndexArray = [0, 1]; const providerIndexArray = [0, 1];
it.each(providerIndexArray)('displays the correct width for provider %s', (provider) => { it.each(providerIndexArray)('displays the correct width for provider %s', (provider) => {
expect(findLogos().at(provider).attributes('width')).toBe('18'); expect(findLogos().at(provider).attributes('style')).toBe('width: 18px;');
}); });
it.each(providerIndexArray)('has a11y decorative attribute for provider %s', (provider) => { it.each(providerIndexArray)('has a11y decorative attribute for provider %s', (provider) => {
expect(findLogos().at(provider).attributes('role')).toBe('presentation'); expect(findLogos().at(provider).attributes('role')).toBe('presentation');
}); });
it.each(providerIndexArray)('displays the correct svg path for provider %s', (provider) => { it.each(providerIndexArray)('renders the svg content for provider %s', (provider) => {
expect(findLogos().at(provider).attributes('src')).toBe( expect(findLogos().at(provider).html()).toContain(
tempProviderLogos[testProviderName[provider]].svg, tempProviderLogos[testProviderName[provider]].svg,
); );
}); });
......
...@@ -105,9 +105,9 @@ export const updateSecurityTrainingProvidersErrorResponse = { ...@@ -105,9 +105,9 @@ export const updateSecurityTrainingProvidersErrorResponse = {
// https://gitlab.com/gitlab-org/gitlab/-/issues/346899 // https://gitlab.com/gitlab-org/gitlab/-/issues/346899
export const tempProviderLogos = { export const tempProviderLogos = {
[testProviderName[0]]: { [testProviderName[0]]: {
svg: '/assets/illustrations/vulnerability/vendor-1.svg', svg: `<svg>${[testProviderName[0]]}</svg>`,
}, },
[testProviderName[1]]: { [testProviderName[1]]: {
svg: '/assets/illustrations/vulnerability/vendor-2.svg', svg: `<svg>${[testProviderName[1]]}</svg>`,
}, },
}; };
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