Skip to content

Commit 1d9aa54

Browse files
committed
feat: intégrer les options de Monaco Editor dans plusieurs composants pour une meilleure gestion de l'éditeur
1 parent 78c8b0b commit 1d9aa54

File tree

8 files changed

+40
-73
lines changed

8 files changed

+40
-73
lines changed

apps/web/nuxt.config.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { resolve } from 'path'
22
import { readFileSync, writeFileSync } from 'fs'
3-
import pugPlugin from 'vite-plugin-pug'
43
import openapiTS, { astToString, COMMENT_HEADER } from 'openapi-typescript'
54
import { defineNuxtConfig } from 'nuxt/config'
65
import { parse } from 'yaml'
@@ -216,13 +215,15 @@ export default defineNuxtConfig({
216215
define: {
217216
'process.env.DEBUG': process.env.NODE_ENV === 'development',
218217
},
219-
plugins: [
220-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
221-
pugPlugin(<any>{
222-
pretty: true,
223-
compilerOptions: {},
224-
}),
225-
],
218+
vue: {
219+
template: {
220+
preprocessOptions: {
221+
pug: {
222+
pretty: true,
223+
},
224+
},
225+
},
226+
},
226227
},
227228
alias: {
228229
cookie: resolve(__dirname, '../node_modules/cookie'),

apps/web/src/composables/useDebug.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import * as Monaco from 'monaco-editor'
2+
13
export function useDebug() {
4+
const $q = useQuasar()
25
const route = useRoute()
36
const cachedDebug = ref<boolean | null>(null)
47

@@ -47,5 +50,17 @@ export function useDebug() {
4750
}
4851
}
4952

50-
return { debug, initDebug }
53+
const monacoOptions = computed<Monaco.editor.IStandaloneEditorConstructionOptions>(() => {
54+
return {
55+
theme: $q.dark.isActive ? 'vs-dark' : 'vs-light',
56+
readOnly: true,
57+
minimap: {
58+
enabled: true,
59+
},
60+
scrollBeyondLastColumn: 0,
61+
scrollBeyondLastLine: false,
62+
}
63+
})
64+
65+
return { debug, initDebug, monacoOptions }
5166
}

apps/web/src/pages/identities/table/[_id]/debug.vue

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ export default defineNuxtComponent({
3030
},
3131
setup() {
3232
const { toPlainAndCrush } = useIdentityUtils()
33+
const { monacoOptions } = useDebug()
3334
34-
return { toPlainAndCrush }
35+
return { toPlainAndCrush, monacoOptions }
3536
},
3637
computed: {
3738
crushedIdentity(): Record<string, any> {
@@ -40,15 +41,6 @@ export default defineNuxtComponent({
4041
}
4142
return this.identity as Record<string, any>
4243
},
43-
monacoOptions() {
44-
return {
45-
theme: this.$q.dark.isActive ? 'vs-dark' : 'vs-light',
46-
readOnly: true,
47-
minimap: {
48-
enabled: true,
49-
},
50-
}
51-
},
5244
},
5345
})
5446
</script>

apps/web/src/pages/identities/table/[_id]/jobs.vue

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,15 @@ export default defineNuxtComponent({
8585
setup() {
8686
const empty = ref(false)
8787
const jobs = ref<any>([])
88+
const { monacoOptions } = useDebug()
8889
8990
return {
9091
empty,
9192
jobs,
93+
monacoOptions,
9294
}
9395
},
9496
computed: {
95-
monacoOptions() {
96-
return <Monaco.editor.IStandaloneEditorConstructionOptions>{
97-
theme: this.$q.dark.isActive ? 'vs-dark' : 'vs-light',
98-
readOnly: true,
99-
minimap: {
100-
enabled: true,
101-
},
102-
scrollBeyondLastColumn: 0,
103-
scrollBeyondLastLine: false,
104-
}
105-
},
10697
jobsBy: {
10798
get() {
10899
return this.$route.query.jobsBy ? `${this.$route.query.jobsBy}` : 'DD/MM/YYYY'

apps/web/src/pages/jobs/details.vue

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export default defineComponent({
8282
const empty = ref(false)
8383
const jobs = ref<any>([])
8484
const $route = useRoute()
85+
const { monacoOptions } = useDebug()
8586
8687
const load = async (index, done) => {
8788
const offset = (index - 1) * 10
@@ -100,23 +101,13 @@ export default defineComponent({
100101
}
101102
102103
return {
104+
monacoOptions,
103105
empty,
104106
jobs,
105107
load,
106108
}
107109
},
108110
computed: {
109-
monacoOptions() {
110-
return <Monaco.editor.IStandaloneEditorConstructionOptions>{
111-
theme: this.$q.dark.isActive ? 'vs-dark' : 'vs-light',
112-
readOnly: true,
113-
minimap: {
114-
enabled: true,
115-
},
116-
scrollBeyondLastColumn: 0,
117-
scrollBeyondLastLine: false,
118-
}
119-
},
120111
jobsBy: {
121112
get() {
122113
return this.$route.query.jobsBy ? `${this.$route.query.jobsBy}` : 'DD/MM/YYYY'

apps/web/src/pages/jobs/table.vue

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export default defineComponent({
112112
}
113113
},
114114
async setup() {
115+
const { monacoOptions } = useDebug()
115116
const $route = useRoute()
116117
const query = computed(() => {
117118
return {
@@ -140,6 +141,7 @@ export default defineComponent({
140141
})
141142
142143
return {
144+
monacoOptions,
143145
rows,
144146
pending,
145147
error,
@@ -177,17 +179,6 @@ export default defineComponent({
177179
stateFilter(): string {
178180
return (this.$route.query['filters[:state]'] as string) || '9'
179181
},
180-
monacoOptions(): Monaco.editor.IStandaloneEditorConstructionOptions {
181-
return <Monaco.editor.IStandaloneEditorConstructionOptions>{
182-
theme: this.$q.dark.isActive ? 'vs-dark' : 'vs-light',
183-
readOnly: true,
184-
minimap: {
185-
enabled: true,
186-
},
187-
scrollBeyondLastColumn: 0,
188-
scrollBeyondLastLine: false,
189-
}
190-
},
191182
},
192183
methods: {
193184
updateStateFilter(selection: { value: string | null }): void {

apps/web/src/pages/lifecycles/table.vue

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export default defineComponent({
7272
}
7373
},
7474
async setup() {
75+
const { monacoOptions } = useDebug()
7576
const route = useRoute()
7677
const router = useRouter()
7778
@@ -108,6 +109,7 @@ export default defineComponent({
108109
})
109110
110111
return {
112+
monacoOptions,
111113
pagination,
112114
113115
getLifecycleName,
@@ -151,17 +153,6 @@ export default defineComponent({
151153
},
152154
]
153155
},
154-
monacoOptions(): Monaco.editor.IStandaloneEditorConstructionOptions {
155-
return <Monaco.editor.IStandaloneEditorConstructionOptions>{
156-
theme: this.$q.dark.isActive ? 'vs-dark' : 'vs-light',
157-
readOnly: true,
158-
minimap: {
159-
enabled: true,
160-
},
161-
scrollBeyondLastColumn: 0,
162-
scrollBeyondLastLine: false,
163-
}
164-
},
165156
},
166157
methods: {
167158
async onRequest(props) {

apps/web/src/pages/settings/agents/[_id]/debug.vue

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,11 @@ export default defineNuxtComponent({
2424
required: true,
2525
},
2626
},
27-
computed: {
28-
monacoOptions() {
29-
return {
30-
theme: this.$q.dark.isActive ? 'vs-dark' : 'vs-light',
31-
readOnly: true,
32-
minimap: {
33-
enabled: true,
34-
},
35-
}
36-
},
27+
setup() {
28+
const { monacoOptions } = useDebug()
29+
return {
30+
monacoOptions,
31+
}
3732
},
3833
})
3934
</script>

0 commit comments

Comments
 (0)