Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Plugins and Directives to Provide a Path for Vue3 #10774

Open
1 task done
rak-phillip opened this issue Apr 8, 2024 · 2 comments · Fixed by #10943, #10944, #10946 or #10981 · May be fixed by #10790
Open
1 task done

Refactor Plugins and Directives to Provide a Path for Vue3 #10774

rak-phillip opened this issue Apr 8, 2024 · 2 comments · Fixed by #10943, #10944, #10946 or #10981 · May be fixed by #10790
Assignees
Labels
QA/dev-automation Issues that engineers have written automation around so QA doesn't have look at this
Milestone

Comments

@rak-phillip
Copy link
Member

rak-phillip commented Apr 8, 2024

Vue 2.x has a number of global APIs and configurations that globally mutate Vue’s behavior. This is no longer an option in Vue 3. Any APIs that globally mutate Vue's behavior in Vue 2 are now moved to the app instance, exposed via createApp.

This means that patterns currently used to register plugins

// Vue 2 - Current plugin registration
import Vue from 'vue';

...
Vue.prototype.t = function(key, args, raw) {
  return stringFor(this.$store, key, args, raw);
};

Will need to include a install function in Vue 3

// Vue 3
install(app) {
    app.config.globalProperties.t = function(key, args, raw) {
      return stringFor(this.$store, key, args, raw);
    };
   ...
}

We can utilize a similar pattern in our code today to make the migration more straightforward

// Vue 2
install(Vue) {
    Vue.prototype.t = function(key, args, raw) {
      return stringFor(this.$store, key, args, raw);
    };
    ...
}

Refactor Plugins

Plugins Globally Mutating Vue in multiple ways

Candidates for writing an install function

Plugins Globally Mutating Vue via Vue.component

Candidates for accepting a vue instance before modifying

  • shell/plugins/global-formatters.js
  • shell/plugins/v-select.js

Plugins Globally Mutating Vue via Vue.use

Candidates for accepting a vue instance before modifying

  • shell/plugins/codemirror.js
  • shell/plugins/portal-vue.js
  • shell/plugins/portal.js
  • shell/plugins/resize.js
  • shell/plugins/shortkey.js
  • shell/plugins/tooltip.js
  • shell/plugins/vue-js-modal.js (No Vue 3 implementation. Should be removed)

Refactor Directives

Candidates for accepting a vue instance before modifying

  • shell/plugins/clean-html-directive.js
  • shell/plugins/clean-tooltip-directive.js
  • shell/plugins/directives.js
  • shell/plugins/int-number.js
  • shell/plugins/positive-int-number.js
  • shell/plugins/trim-whitespace.js
@rak-phillip
Copy link
Member Author

Reopening issue, there are still 2 more PRs to address this.

@gaktive
Copy link
Member

gaktive commented May 14, 2024

@nwmac we may need to check our actions since this ticket didn't move to QA. Maybe multiple PRs tied to this ticket?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment