POC: Global Search - Create Vue App
Size Concerns
I plan to split the code here into 2 MRs:
- Create the initial bootstrap Vue app and Store
- 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?
- We create a top level Vue instance with a
<section>
tag and pass all the nested HAML into av-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 - Inside the
$mounted
lifecycle we then replace our targeted ID inside of thev-html
with the Vue Component - To do step 2, we simply can use a helper method
mountComponent(vueInstance, component, id)
Screenshots
before | after | |
---|---|---|
Search UI |
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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