Skip to content

[5.x] Upgrade from Vue 2 to Vue 3 #1496

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

Merged
merged 10 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
330 changes: 261 additions & 69 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"watch": "vite build --watch"
},
"devDependencies": {
"@vitejs/plugin-vue2": "^2.3.1",
"@vitejs/plugin-vue": "^5.1.3",
"axios": "^1.7.4",
"bootstrap": "~5.1.3",
"chart.js": "^2.9.4",
Expand All @@ -19,8 +19,8 @@
"sass": "^1.74.1",
"sql-formatter": "^4.0.2",
"vite": "^5.2.8",
"vue": "^2.7.16",
"vue-json-pretty": "^1.9.5",
"vue-router": "^3.6.5"
"vue": "^3.5.4",
"vue-json-pretty": "^2.4.0",
"vue-router": "^4.4.4"
}
}
51 changes: 25 additions & 26 deletions resources/js/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';
import Vue from 'vue/dist/vue.esm.js';
import VueRouter from 'vue-router';
import { createApp } from 'vue/dist/vue.esm-bundler.js';
import { createRouter, createWebHistory } from 'vue-router';
import VueJsonPretty from 'vue-json-pretty';
import 'vue-json-pretty/lib/styles.css';
import Base from './base';
Expand All @@ -16,9 +16,22 @@ if (token) {
axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
}

Vue.use(VueRouter);
const app = createApp({
data() {
return {
alert: {
type: null,
autoClose: 0,
message: '',
confirmationProceed: null,
confirmationCancel: null,
},
autoLoadsNewEntries: localStorage.autoLoadsNewEntries === '1',
};
},
});

Vue.prototype.$http = axios.create();
app.config.globalProperties.$http = axios.create();

window.Horizon.basePath = '/' + window.Horizon.path;

Expand All @@ -29,31 +42,17 @@ if (window.Horizon.path === '' || window.Horizon.path === '/') {
window.Horizon.basePath = '';
}

const router = new VueRouter({
const router = createRouter({
history: createWebHistory(routerBasePath),
routes: Routes,
mode: 'history',
base: routerBasePath,
});

Vue.component('vue-json-pretty', VueJsonPretty);
Vue.component('alert', Alert);
Vue.component('scheme-toggler', SchemeToggler);
app.use(router);

Vue.mixin(Base);
app.component('vue-json-pretty', VueJsonPretty);
app.component('alert', Alert);
app.component('scheme-toggler', SchemeToggler);

new Vue({
router,
data() {
return {
alert: {
type: null,
autoClose: 0,
message: '',
confirmationProceed: null,
confirmationCancel: null,
},
app.mixin(Base);

autoLoadsNewEntries: localStorage.autoLoadsNewEntries === '1',
};
},
}).$mount('#horizon');
app.mount('#horizon');
131 changes: 66 additions & 65 deletions resources/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,99 +24,100 @@ export default [

{
path: '/monitoring',
name: 'monitoring',
component: monitoring,
},

{
path: '/monitoring/:tag',
component: monitoringTag,
children: [
{
path: 'jobs',
name: 'monitoring-jobs',
component: monitoringTagJobs,
props: { type: 'jobs' },
path: '',
name: 'monitoring',
component: monitoring,
},
{
path: 'failed',
name: 'monitoring-failed',
component: monitoringTagJobs,
props: { type: 'failed' },
path: ':tag',
component: monitoringTag,
children: [
{
path: 'jobs',
name: 'monitoring-jobs',
component: monitoringTagJobs,
props: { type: 'jobs' },
},
{
path: 'failed',
name: 'monitoring-failed',
component: monitoringTagJobs,
props: { type: 'failed' },
},
],
},
],
},

{ path: '/metrics', redirect: '/metrics/jobs' },

{
path: '/metrics/',
component: metrics,
path: '/metrics',
redirect: '/metrics/jobs',
children: [
{
path: 'jobs',
name: 'metrics-jobs',
component: metricsJobs,
component: metrics,
children: [{ path: '', name: 'metrics-jobs', component: metricsJobs }],
},
{
path: 'queues',
name: 'metrics-queues',
component: metricsQueues,
component: metrics,
children: [{ path: '', name: 'metrics-queues', component: metricsQueues }],
},
{
path: ':type/:slug',
name: 'metrics-preview',
component: metricsPreview,
},
],
},

{
path: '/metrics/:type/:slug',
name: 'metrics-preview',
component: metricsPreview,
},

{
path: '/jobs/:type',
name: 'jobs',
component: recentJobs,
},

{
path: '/jobs/pending/:jobId',
name: 'pending-jobs-preview',
component: recentJobsJob,
},

{
path: '/jobs/completed/:jobId',
name: 'completed-jobs-preview',
component: recentJobsJob,
},

{
path: '/jobs/silenced/:jobId',
name: 'silenced-jobs-preview',
component: recentJobsJob,
children: [
{
path: '',
name: 'jobs',
component: recentJobs,
},
{
path: ':jobId',
name: 'job-preview',
component: recentJobsJob,
},
],
},

{
path: '/failed',
name: 'failed-jobs',
component: failedJobs,
},

{
path: '/failed/:jobId',
name: 'failed-jobs-preview',
component: failedJobsJob,
children: [
{
path: '',
name: 'failed-jobs',
component: failedJobs,
},
{
path: ':jobId',
name: 'failed-jobs-preview',
component: failedJobsJob,
},
],
},

{
path: '/batches',
name: 'batches',
component: batches,
},

{
path: '/batches/:batchId',
name: 'batches-preview',
component: batchesPreview,
children: [
{
path: '',
name: 'batches',
component: batches,
},
{
path: ':batchId',
name: 'batches-preview',
component: batchesPreview,
},
],
},
];
4 changes: 2 additions & 2 deletions resources/js/screens/batches/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
},

/**
* Clean after the component is destroyed.
* Clean after the component is unmounted.
*/
destroyed() {
unmounted() {
clearInterval(this.interval);
},

Expand Down
4 changes: 2 additions & 2 deletions resources/js/screens/batches/preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@


/**
* Clean after the component is destroyed.
* Clean after the component is unmounted.
*/
destroyed() {
unmounted() {
clearInterval(this.interval);
},

Expand Down
4 changes: 2 additions & 2 deletions resources/js/screens/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@


/**
* Clean after the component is destroyed.
* Clean after the component is unmounted.
*/
destroyed() {
unmounted() {
clearTimeout(this.timeout);
},

Expand Down
4 changes: 2 additions & 2 deletions resources/js/screens/failedJobs/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
},

/**
* Clean after the component is destroyed.
* Clean after the component is unmounted.
*/
destroyed() {
unmounted() {
clearInterval(this.interval);
},

Expand Down
4 changes: 2 additions & 2 deletions resources/js/screens/failedJobs/job.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
/**
* Clean after the component is destroyed.
* Clean after the component is unmounted.
*/
destroyed() {
unmounted() {
clearInterval(this.interval);
},
Expand Down
8 changes: 2 additions & 6 deletions resources/js/screens/monitoring/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@
this.loadTags();

this.refreshTagsPeriodically();

this.$on('addTagModalClosed', data => {
this.addTagModalOpened = false;
});
},

/**
* Clean up after the component is destroyed.
* Clean up after the component is unmounted.
*/
destroyed() {
unmounted() {
clearInterval(this.interval);
},

Expand Down
2 changes: 1 addition & 1 deletion resources/js/screens/monitoring/job-row.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<tr>
<td>
<router-link :title="job.name" :to="{ name: $parent.type != 'failed' ? 'completed-jobs-preview' : 'failed-jobs-preview', params: { jobId: job.id }}">
<router-link :title="job.name" :to="{ name: 'job-preview', params: { jobId: job.id, type: $parent.type }}">
{{ jobBaseName(job.name) }}
</router-link>

Expand Down
8 changes: 4 additions & 4 deletions resources/js/screens/monitoring/tag-jobs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@


/**
* Clean after the component is destroyed.
* Clean after the component is unmounted.
*/
destroyed() {
unmounted() {
clearInterval(this.interval);
},

Expand Down Expand Up @@ -176,8 +176,8 @@
</td>
</tr>

<tr v-for="job in jobs" :key="job.id" :job="job" is="job-row">
</tr>
<component v-for="job in jobs" :key="job.id" :job="job" is="job-row">
</component>
</tbody>
</table>

Expand Down
8 changes: 4 additions & 4 deletions resources/js/screens/recentJobs/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
},

/**
* Clean after the component is destroyed.
* Clean after the component is unmounted.
*/
destroyed() {
unmounted() {
clearInterval(this.interval);
},

Expand Down Expand Up @@ -191,8 +191,8 @@
</td>
</tr>

<tr v-for="job in jobs" :key="job.id" :job="job" is="job-row">
</tr>
<component v-for="job in jobs" :key="job.id" :job="job" is="job-row">
</component>
</tbody>
</table>

Expand Down
Loading