Skip to content

POC: Global Search - Create Vue App

Zack Cuddy requested to merge search-v2-bootstrap into master

Size Concerns

I plan to split the code here into 2 MRs:

  1. Create the initial bootstrap Vue app and Store
  2. Port over State and Confidential Features

What does this MR do?

This is the entry point for the efforts of #249709 (closed)

This change consists of the Vue Instance we will be using for the updates to the Global Search tool.

Using a singular instance will allow us to have a shared Vuex Store between the components while still leveraging existing Rails and HAML.

The tricky part of this change is we are still having HAML nested throughout. So instead of a full Vue rewrite we are injecting Vue components to different places in the HAML programatically.

This change is inspired by a blog post on CSS-Tricks: https://css-tricks.com/creating-vue-js-component-instances-programmatically/

How it works?

  1. We create a top level Vue instance with a <section> tag and pass all the nested HAML into a v-html (need to check with security about if there is a possible XSS injection here) - This approach is similar to https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/vue_shared/components/dismissible_alert.vue#L31
  2. Inside the $mounted lifecycle we then replace our targeted ID inside of the v-html with the Vue Component
  3. To do step 2, we simply can use a helper method mountComponent(vueInstance, component, id)

Screenshots

before after
Search UI Before Screen_Shot_2020-10-01_at_10.56.25_AM

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Zack Cuddy

Merge request reports

Loading