Remove SVG imports from `?raw` and remove usage of v-safe-html to render images

Description

Our webpack configuration supports importing SVGs in two ways, by using <img> or v-safe-html. Having an <img> is more semantic and requires fewer imports.

Use should migrate occurrences to use <img> instead.

From

<script>
import GITLAB_LOGO_RAW from '@gitlab/svgs/dist/illustrations/gitlab_logo.svg?raw';
import SafeHtml from '~/vue_shared/directives/safe_html';

export default {
  directives: {
    SafeHtml
  },
  GITLAB_LOGO_RAW,
};
</script>
<template>
  <div>
    <div v-safe-html="$options.GITLAB_LOGO_RAW"/>
  </div>
</template>

To

<script>
import GITLAB_LOGO_URL from '@gitlab/svgs/dist/illustrations/gitlab_logo.svg?url';

export default {
  GITLAB_LOGO_URL,
};
</script>
<template>
  <div>
    <img :src="$options.GITLAB_LOGO_URL" alt="GitLab Logo"/>
  </div>
</template>

Files that import svgs using ?raw

  • ee/spec/frontend/external_issues_list/mock_data.js
  • ee/app/assets/javascripts/analytics/repository_analytics/components/test_coverage_summary.vue
  • ee/app/assets/javascripts/vulnerabilities/components/issue_link.vue
  • ee/app/assets/javascripts/vulnerabilities/components/related_jira_issues.vue
  • ee/app/assets/javascripts/security_orchestration/components/policy_editor/policy_selection.vue !125894 (merged)
  • ee/app/assets/javascripts/integrations/jira/issues_list/jira_issues_list_bundle.js
  • ee/app/assets/javascripts/subscriptions/buy_addons_shared/components/app.vue
  • ee/app/assets/javascripts/integrations/zentao/issues_list/zentao_issues_list_bundle.js
  • app/assets/javascripts/feature_highlight/feature_highlight_popover.vue
  • app/assets/javascripts/ensure_data.js
  • app/assets/javascripts/monitoring/components/charts/empty_chart.vue
  • app/assets/javascripts/surveys/merge_request_experience/app.vue
  • app/assets/javascripts/work_items/components/work_item_detail.vue
  • app/assets/javascripts/security_configuration/components/constants.js
  • app/assets/javascripts/environments/components/deploy_board.vue
  • app/assets/javascripts/projects/new/components/app.vue !124180 (merged)
  • app/assets/javascripts/pages/groups/new/components/app.vue !124180 (merged)
  • app/assets/javascripts/ci/pipeline_schedules/components/pipeline_schedules_empty_state.vue !124175 (merged)

Exceptions:

  • [-] app/assets/javascripts/super_sidebar/components/brand_logo.vue !125892 (closed)
    • This logo is styled and animated by CSS app/assets/stylesheets/framework/logo.scss, so we should keep this import with ?raw
regex used
$ rg --multiline -l "import.+(.+\.svg\?raw)"

Why not update this in mass?

There could be some legitimate reasons to import SVGs a HTML, such as using JS to alter its contents to animate, etc. I haven't seen this at use in GitLab.

Edited by Miguel Rincon