@appscode/design-system 1.0.43-alpha.99 → 1.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/utilities/_all.scss +7 -0
- package/base/utilities/_customize-bulma.scss +191 -0
- package/base/utilities/_default.scss +58 -124
- package/base/utilities/_derived-variables.scss +6 -0
- package/base/utilities/_grid.scss +29 -0
- package/base/utilities/_initial-variables.scss +13 -9
- package/base/utilities/_typography.scss +6 -12
- package/base/utilities/dark-theme.scss +1 -0
- package/components/_ac-accordion.scss +14 -5
- package/components/_ac-alert-box.scss +32 -6
- package/components/_ac-card.scss +17 -5
- package/components/_ac-drag.scss +2 -0
- package/components/_ac-input.scss +19 -11
- package/components/_ac-modal.scss +1 -1
- package/components/_ac-multi-select.scss +60 -4
- package/components/_ac-report.scss +53 -0
- package/components/_ac-table.scss +60 -2
- package/components/_ac-tabs.scss +16 -2
- package/components/_ac-tags.scss +85 -0
- package/components/_ac-terminal.scss +1 -3
- package/components/_all.scss +28 -0
- package/components/_buttons.scss +14 -33
- package/components/_dashboard-header.scss +32 -0
- package/components/_left-sidebar-menu.scss +9 -9
- package/components/_navbar.scss +89 -4
- package/components/_preview-modal.scss +14 -1
- package/components/_transitions.scss +296 -0
- package/components/_wizard.scss +1 -0
- package/components/bbum/_all.scss +9 -0
- package/components/bbum/_single-post-preview.scss +1 -1
- package/components/ui-builder/_ui-builder.scss +58 -0
- package/components/ui-builder/_vue-open-api.scss +6 -0
- package/layouts/_all.scss +2 -0
- package/layouts/_code-preview.scss +5 -2
- package/main.scss +5 -56
- package/package.json +4 -2
- package/plugins/caching.ts +243 -0
- package/plugins/time-convert.js +49 -0
- package/plugins/vue-toaster.js +3 -0
- package/vue-components/v2/banner/Banner.vue +2 -2
- package/vue-components/v2/breadcrumbs/Breadcrumb.vue +97 -0
- package/vue-components/v2/button/Button.vue +5 -0
- package/vue-components/v2/button/DownloadBtn.vue +45 -0
- package/vue-components/v2/card/Card.vue +1 -0
- package/vue-components/v2/content/ContentTable.vue +12 -7
- package/vue-components/v2/editor/Editor.vue +37 -24
- package/vue-components/v2/editor/FilteredFileEditor.vue +189 -0
- package/vue-components/v2/editor/MonacoEditor.vue +125 -0
- package/vue-components/v2/editor/ResourceKeyValueEditor.vue +209 -0
- package/vue-components/v2/form-fields/Input.vue +1 -1
- package/vue-components/v2/loaders/ResourceLoader.vue +101 -0
- package/vue-components/v2/loaders/SidebarLoader.vue +43 -0
- package/vue-components/v2/modal/Modal.vue +30 -5
- package/vue-components/v2/modals/DeleteConfirmationModal.vue +79 -0
- package/vue-components/v2/modals/JsonShowModal.vue +12 -2
- package/vue-components/v2/navbar/User.vue +229 -17
- package/vue-components/v2/notification/Notification.vue +101 -0
- package/vue-components/v2/notification/NotificationItem.vue +44 -0
- package/vue-components/v2/pagination/Pagination.vue +16 -3
- package/vue-components/v2/preloader/Preloader.vue +1 -1
- package/vue-components/v2/sidebar/SidebarItemWithDropDown.vue +19 -20
- package/vue-components/v2/tab/TabItem.vue +1 -1
- package/vue-components/v2/table/Table.vue +44 -8
- package/vue-components/v2/table/TableRow.vue +12 -2
- package/vue-components/v2/table/table-cell/CellValue.vue +29 -9
- package/vue-components/v2/table/table-cell/GenericCell.vue +56 -0
- package/vue-components/v2/table/table-cell/ObjectCell.vue +4 -1
- package/vue-components/v3/button/Button.vue +6 -1
- package/vue-components/v3/content/ContentHeader.vue +2 -1
- package/vue-components/v3/content/ContentTable.vue +20 -2
- package/vue-components/v3/editor/Editor.vue +36 -33
- package/vue-components/v3/editor/FilteredFileEditor.vue +186 -0
- package/vue-components/v3/editor/MonacoEditor.vue +131 -0
- package/vue-components/v3/editor/ResourceKeyValueEditor.vue +125 -0
- package/vue-components/v3/form/Form.vue +63 -0
- package/vue-components/v3/form-fields/Input.vue +11 -10
- package/vue-components/v3/header/HeaderItem.vue +5 -0
- package/vue-components/v3/header/HeaderItems.vue +5 -0
- package/vue-components/v3/loaders/ResourceLoader.vue +83 -0
- package/vue-components/v3/loaders/SidebarLoader.vue +34 -0
- package/vue-components/v3/long-running-tasks/LongRunningTaskItem.vue +92 -0
- package/vue-components/v3/modal/Modal.vue +30 -7
- package/vue-components/v3/modals/DeleteConfirmationModal.vue +85 -0
- package/vue-components/v3/modals/JsonShowModal.vue +25 -16
- package/vue-components/v3/modals/LongRunningTasksModal.vue +373 -0
- package/vue-components/v3/navbar/ThemeMode.vue +41 -49
- package/vue-components/v3/navbar/User.vue +242 -18
- package/vue-components/v3/notification/Notification.vue +98 -0
- package/vue-components/v3/notification/NotificationItem.vue +52 -0
- package/vue-components/v3/pagination/Pagination.vue +16 -3
- package/vue-components/v3/sidebar/SidebarItemWithDropDown.vue +120 -0
- package/vue-components/v3/tab/TabItem.vue +1 -1
- package/vue-components/v3/table/MultiInfoTable.vue +143 -0
- package/vue-components/v3/table/Table.vue +50 -14
- package/vue-components/v3/table/TableContainer.vue +34 -0
- package/vue-components/v3/table/TableRow.vue +93 -6
- package/vue-components/v3/table/table-cell/CellValue.vue +23 -7
- package/vue-components/v3/table/table-cell/GenericCell.vue +75 -0
- package/vue-components/v3/table/table-cell/ObjectCell.vue +7 -2
- package/vue-components/v3/terminal/LongRunningTaskTerminal.vue +148 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ac-breadcrumb">
|
|
3
|
+
<nav aria-label="breadcrumbs" class="breadcrumb">
|
|
4
|
+
<ul>
|
|
5
|
+
<li
|
|
6
|
+
v-for="(item, idx) in list"
|
|
7
|
+
:key="idx"
|
|
8
|
+
:class="{ 'is-active': idx === list.length - 1 }"
|
|
9
|
+
>
|
|
10
|
+
<router-link
|
|
11
|
+
class="router-link-active"
|
|
12
|
+
:class="{ 'is-active': idx === list.length - 1 }"
|
|
13
|
+
:to="item.path"
|
|
14
|
+
>{{ item.name }}
|
|
15
|
+
</router-link>
|
|
16
|
+
</li>
|
|
17
|
+
</ul>
|
|
18
|
+
</nav>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
<script>
|
|
22
|
+
export default {
|
|
23
|
+
data() {
|
|
24
|
+
return {
|
|
25
|
+
list: []
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
createBreadcrumbs(n) {
|
|
30
|
+
//Adding dynamic path to the route
|
|
31
|
+
const listPaths = this.$route.matched.map(element =>
|
|
32
|
+
this.pathReplaceWithParam(element.path)
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
//Removing the last duplicate value from the listpaths array
|
|
36
|
+
listPaths.pop();
|
|
37
|
+
|
|
38
|
+
//Createing the breadcrumb name
|
|
39
|
+
const listName = this.createList(listPaths);
|
|
40
|
+
|
|
41
|
+
//Set the new breadcrumb name and path value to list
|
|
42
|
+
this.list = listName.map((element, index) => {
|
|
43
|
+
return {
|
|
44
|
+
name: element,
|
|
45
|
+
path: listPaths[index]
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
pathReplaceWithParam(path) {
|
|
50
|
+
//Split the path and remove the first and last empty block
|
|
51
|
+
let splitPath = path.split("/").filter(element => element !== "");
|
|
52
|
+
|
|
53
|
+
//Replace all element with query params where the element start with ":"
|
|
54
|
+
// Then again add them wthi "/" and return the path value
|
|
55
|
+
return splitPath.reduce((pval, cval) => {
|
|
56
|
+
if (cval[0] === ":") {
|
|
57
|
+
const cutIndex =
|
|
58
|
+
cval.indexOf("?") !== -1 ? cval.indexOf("?") : cval.length;
|
|
59
|
+
return (pval += this.$route.params[cval.slice(1, cutIndex)] + "/");
|
|
60
|
+
} else return (pval += cval + "/");
|
|
61
|
+
}, "/");
|
|
62
|
+
},
|
|
63
|
+
createList(paths) {
|
|
64
|
+
//Split all the path and remove all empty block
|
|
65
|
+
let spath = paths.map(element => {
|
|
66
|
+
return element.split("/").filter(word => word !== "");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Convert all the path arry in one arry where each element is the different fo previous element
|
|
70
|
+
return spath.reduce((prev, curr, currentIdx) => {
|
|
71
|
+
if (currentIdx === 0) return prev.concat([this.createVal(0, curr)]);
|
|
72
|
+
else
|
|
73
|
+
return prev.concat([
|
|
74
|
+
this.createVal(spath[currentIdx - 1].length, curr)
|
|
75
|
+
]);
|
|
76
|
+
}, []);
|
|
77
|
+
},
|
|
78
|
+
createVal(startIdx, paths) {
|
|
79
|
+
return paths.reduce((prev, curr, idx) => {
|
|
80
|
+
if (idx >= startIdx) {
|
|
81
|
+
if (idx + 1 === paths.length) return (prev += curr);
|
|
82
|
+
else return (prev += curr + " / ");
|
|
83
|
+
} else return prev + "";
|
|
84
|
+
}, "");
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
watch: {
|
|
88
|
+
"$route.path": {
|
|
89
|
+
deep: true,
|
|
90
|
+
immediate: true,
|
|
91
|
+
handler(n) {
|
|
92
|
+
this.createBreadcrumbs(n);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
</script>
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
:class="`${modifierClasses}${isLoaderActive ? ' is-loading' : ''}`"
|
|
5
5
|
:disabled="disabled"
|
|
6
6
|
@click="handleClick"
|
|
7
|
+
:title="tooltip"
|
|
7
8
|
>
|
|
8
9
|
<span v-if="iconClass || iconImage" class="icon is-small">
|
|
9
10
|
<img
|
|
@@ -27,6 +28,10 @@ export default {
|
|
|
27
28
|
type: String,
|
|
28
29
|
default: "",
|
|
29
30
|
},
|
|
31
|
+
tooltip: {
|
|
32
|
+
type: String,
|
|
33
|
+
defualt: undefined
|
|
34
|
+
},
|
|
30
35
|
// for loader
|
|
31
36
|
isLoaderActive: {
|
|
32
37
|
type: Boolean,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ac-button
|
|
3
|
+
modifier-classes="is-primary is-square"
|
|
4
|
+
icon-class="download"
|
|
5
|
+
:is-loader-active="isFetching"
|
|
6
|
+
@click="download()"
|
|
7
|
+
/>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import downloadFunc from "downloadjs";
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
components: {
|
|
15
|
+
AcButton: () => import("./../button/Button.vue")
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
fileData: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: ""
|
|
21
|
+
},
|
|
22
|
+
fileName: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: ""
|
|
25
|
+
},
|
|
26
|
+
isFetching: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
data() {
|
|
32
|
+
return {
|
|
33
|
+
downloadIcon: "fa fa-cloud-download"
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
component: {
|
|
37
|
+
downloadFunc
|
|
38
|
+
},
|
|
39
|
+
methods: {
|
|
40
|
+
download() {
|
|
41
|
+
downloadFunc(this.fileData, this.fileName);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
</script>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<content-layout>
|
|
3
3
|
<template #content-header>
|
|
4
4
|
<content-header
|
|
5
|
+
v-if="!hideHeader"
|
|
5
6
|
:header-title="tableTitle"
|
|
6
7
|
:header-sub-title="tableSubTitle"
|
|
7
8
|
:class="{ 'pl-0 pr-0': removeTableHeaderPadding }"
|
|
@@ -21,32 +22,36 @@ export default {
|
|
|
21
22
|
props: {
|
|
22
23
|
removeTableHeaderPadding: {
|
|
23
24
|
type: Boolean,
|
|
24
|
-
default: false
|
|
25
|
+
default: false
|
|
25
26
|
},
|
|
26
27
|
tableTitle: {
|
|
27
28
|
type: String,
|
|
28
|
-
default: "Table"
|
|
29
|
+
default: "Table"
|
|
29
30
|
},
|
|
30
31
|
tableSubTitle: {
|
|
31
32
|
type: String,
|
|
32
|
-
default: ""
|
|
33
|
+
default: ""
|
|
33
34
|
},
|
|
34
35
|
searchable: {
|
|
35
36
|
type: Boolean,
|
|
36
|
-
default: true
|
|
37
|
+
default: true
|
|
37
38
|
},
|
|
39
|
+
hideHeader: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false
|
|
42
|
+
}
|
|
38
43
|
},
|
|
39
44
|
components: {
|
|
40
45
|
ContentLayout: () => import("./ContentLayout.vue"),
|
|
41
46
|
ContentHeader: () => import("./ContentHeader.vue"),
|
|
42
47
|
HeaderItem: () => import("../header/HeaderItem.vue"),
|
|
43
|
-
SearchBar: () => import("../searchbars/SearchBar.vue")
|
|
48
|
+
SearchBar: () => import("../searchbars/SearchBar.vue")
|
|
44
49
|
},
|
|
45
50
|
|
|
46
51
|
data() {
|
|
47
52
|
return {
|
|
48
|
-
searchText: ""
|
|
53
|
+
searchText: ""
|
|
49
54
|
};
|
|
50
|
-
}
|
|
55
|
+
}
|
|
51
56
|
};
|
|
52
57
|
</script>
|
|
@@ -7,21 +7,22 @@
|
|
|
7
7
|
/>
|
|
8
8
|
<monaco-editor
|
|
9
9
|
v-if="activeTab === 'edit'"
|
|
10
|
-
ref="monacoEditor"
|
|
11
10
|
@editorDidMount="onEditorMount"
|
|
12
11
|
key="edit"
|
|
13
12
|
:class="`vh-${editorHeight} is-clipped`"
|
|
14
|
-
|
|
13
|
+
:value="editorContent"
|
|
14
|
+
@change="onChange"
|
|
15
15
|
:language="language"
|
|
16
16
|
:options="{
|
|
17
17
|
minimap: {
|
|
18
|
-
enabled: calcShowMinimap
|
|
18
|
+
enabled: calcShowMinimap,
|
|
19
19
|
},
|
|
20
20
|
theme: theme,
|
|
21
21
|
readOnly: readOnly,
|
|
22
22
|
wordWrap: wordWrap,
|
|
23
|
-
scrollBeyondLastLine: false
|
|
23
|
+
scrollBeyondLastLine: false,
|
|
24
24
|
}"
|
|
25
|
+
data-testid="monaco-editor-edit-section"
|
|
25
26
|
/>
|
|
26
27
|
<monaco-editor
|
|
27
28
|
v-if="activeTab === 'preview'"
|
|
@@ -31,65 +32,75 @@
|
|
|
31
32
|
:language="language"
|
|
32
33
|
:options="{
|
|
33
34
|
minimap: {
|
|
34
|
-
enabled: calcShowMinimap
|
|
35
|
+
enabled: calcShowMinimap,
|
|
35
36
|
},
|
|
36
37
|
theme: theme,
|
|
37
38
|
readOnly: true,
|
|
38
39
|
wordWrap: wordWrap,
|
|
39
|
-
scrollBeyondLastLine: false
|
|
40
|
+
scrollBeyondLastLine: false,
|
|
40
41
|
}"
|
|
41
42
|
:original="originalEditorContent"
|
|
42
43
|
:diff-editor="true"
|
|
44
|
+
data-testid="monaco-editor-preview-section"
|
|
43
45
|
/>
|
|
44
46
|
</div>
|
|
45
47
|
</template>
|
|
46
48
|
|
|
47
49
|
<script>
|
|
50
|
+
import Preloader from "../preloader/Preloader.vue";
|
|
51
|
+
import Banner from "../banner/Banner.vue";
|
|
48
52
|
export default {
|
|
49
53
|
props: {
|
|
50
54
|
value: {
|
|
51
55
|
type: String,
|
|
52
|
-
default: ""
|
|
56
|
+
default: "",
|
|
53
57
|
},
|
|
54
58
|
originalValue: {
|
|
55
59
|
type: String,
|
|
56
|
-
default: ""
|
|
60
|
+
default: "",
|
|
57
61
|
},
|
|
58
62
|
readOnly: {
|
|
59
63
|
type: Boolean,
|
|
60
|
-
default: false
|
|
64
|
+
default: false,
|
|
61
65
|
},
|
|
62
66
|
language: {
|
|
63
67
|
type: String,
|
|
64
|
-
default: "yaml"
|
|
68
|
+
default: "yaml",
|
|
65
69
|
},
|
|
66
70
|
showMinimap: {
|
|
67
71
|
type: Boolean,
|
|
68
|
-
default: true
|
|
72
|
+
default: true,
|
|
69
73
|
},
|
|
70
74
|
editorHeight: {
|
|
71
75
|
type: Number,
|
|
72
|
-
default: 40
|
|
76
|
+
default: 40,
|
|
73
77
|
},
|
|
74
78
|
editorTheme: {
|
|
75
79
|
type: String,
|
|
76
|
-
default: ""
|
|
80
|
+
default: "",
|
|
77
81
|
},
|
|
78
82
|
wordWrap: {
|
|
79
83
|
type: String,
|
|
80
|
-
default: "off"
|
|
84
|
+
default: "off",
|
|
81
85
|
},
|
|
82
86
|
},
|
|
87
|
+
|
|
83
88
|
components: {
|
|
84
89
|
EditorTabs: () => import("../tabs/EditorTabs.vue"),
|
|
85
|
-
MonacoEditor: () =>
|
|
90
|
+
MonacoEditor: () => ({
|
|
91
|
+
component: import("./MonacoEditor.vue"),
|
|
92
|
+
loading: Preloader,
|
|
93
|
+
delay: 200,
|
|
94
|
+
error: Banner,
|
|
95
|
+
timeout: 100000,
|
|
96
|
+
}),
|
|
86
97
|
},
|
|
87
98
|
|
|
88
99
|
data() {
|
|
89
100
|
return {
|
|
90
101
|
activeTab: "edit",
|
|
91
102
|
editorContent: "",
|
|
92
|
-
originalEditorContent: ""
|
|
103
|
+
originalEditorContent: "",
|
|
93
104
|
};
|
|
94
105
|
},
|
|
95
106
|
|
|
@@ -105,7 +116,7 @@ export default {
|
|
|
105
116
|
? "vs-dark"
|
|
106
117
|
: "vs")
|
|
107
118
|
);
|
|
108
|
-
}
|
|
119
|
+
},
|
|
109
120
|
},
|
|
110
121
|
|
|
111
122
|
watch: {
|
|
@@ -115,7 +126,7 @@ export default {
|
|
|
115
126
|
if (this.editorContent !== n) {
|
|
116
127
|
this.editorContent = n;
|
|
117
128
|
}
|
|
118
|
-
}
|
|
129
|
+
},
|
|
119
130
|
},
|
|
120
131
|
originalValue: {
|
|
121
132
|
immediate: true,
|
|
@@ -123,18 +134,20 @@ export default {
|
|
|
123
134
|
if (this.originalEditorContent !== n) {
|
|
124
135
|
this.originalEditorContent = n;
|
|
125
136
|
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
137
|
+
},
|
|
138
|
+
},
|
|
128
139
|
},
|
|
129
140
|
|
|
130
141
|
methods: {
|
|
131
|
-
|
|
132
|
-
|
|
142
|
+
onChange(e) {
|
|
143
|
+
if (typeof e === "string") this.editorContent = e;
|
|
144
|
+
},
|
|
145
|
+
onEditorMount(editor) {
|
|
133
146
|
// add event listeners
|
|
134
147
|
editor.onDidBlurEditorText(() => {
|
|
135
148
|
this.$emit("input", this.editorContent);
|
|
136
149
|
});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
150
|
+
},
|
|
151
|
+
},
|
|
139
152
|
};
|
|
140
153
|
</script>
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ac-preview is-active is-not-fixed">
|
|
3
|
+
<div class="ac-preview-inner">
|
|
4
|
+
<!-- preview body start -->
|
|
5
|
+
<div class="ac-preview-body mt-0 pt-15 pl-20">
|
|
6
|
+
<div
|
|
7
|
+
v-if="isPreviewLoading || (!isPreviewLoading && previewYamls)"
|
|
8
|
+
class="left-content"
|
|
9
|
+
>
|
|
10
|
+
<div class="ac-files ac-hscrollbar pt-0">
|
|
11
|
+
<ul v-if="!isPreviewLoading">
|
|
12
|
+
<li
|
|
13
|
+
v-for="(previewYaml, idx) in filteredYamls"
|
|
14
|
+
:key="previewYaml.name + idx"
|
|
15
|
+
:class="{ 'is-active': activeKey === previewYaml.uid }"
|
|
16
|
+
data-testid="filtered-file-editor-file-name"
|
|
17
|
+
>
|
|
18
|
+
<a @click.prevent="setActivePreview(previewYaml.uid)">
|
|
19
|
+
<span>
|
|
20
|
+
<img
|
|
21
|
+
src="~@appscode/design-system-images/icons/file-icon.svg"
|
|
22
|
+
alt=""
|
|
23
|
+
/>
|
|
24
|
+
</span>
|
|
25
|
+
<span>{{ previewYaml.name }}</span>
|
|
26
|
+
</a>
|
|
27
|
+
</li>
|
|
28
|
+
</ul>
|
|
29
|
+
<sidebar-loader
|
|
30
|
+
v-else
|
|
31
|
+
:primaryLoaderColor="primaryLoaderColor"
|
|
32
|
+
:secondaryLoaderColor="secondaryLoaderColor"
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="right-content" data-testid="filtered-file-editor-content">
|
|
37
|
+
<div class="right-content">
|
|
38
|
+
<resource-loader
|
|
39
|
+
v-if="isPreviewLoading"
|
|
40
|
+
:primaryLoaderColor="primaryLoaderColor"
|
|
41
|
+
:secondaryLoaderColor="secondaryLoaderColor"
|
|
42
|
+
/>
|
|
43
|
+
<editor
|
|
44
|
+
v-else-if="!isPreviewLoading && !hideValue"
|
|
45
|
+
v-model="activeFile.content"
|
|
46
|
+
:original-value="originalValue"
|
|
47
|
+
:language="activeFile.format"
|
|
48
|
+
:read-only="isEditorReadOnly"
|
|
49
|
+
:editor-height="editorHeight"
|
|
50
|
+
:show-minimap="showMinimap"
|
|
51
|
+
:editor-theme="editorTheme"
|
|
52
|
+
:key="editorTheme"
|
|
53
|
+
/>
|
|
54
|
+
<span v-else> *************** </span>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
<script>
|
|
62
|
+
import Preloader from "../preloader/Preloader.vue";
|
|
63
|
+
import Banner from "../banner/Banner.vue";
|
|
64
|
+
export default {
|
|
65
|
+
components: {
|
|
66
|
+
Editor: () => ({
|
|
67
|
+
component: import("./Editor.vue"),
|
|
68
|
+
loading: Preloader,
|
|
69
|
+
delay: 200,
|
|
70
|
+
error: Banner,
|
|
71
|
+
timeout: 100000,
|
|
72
|
+
}),
|
|
73
|
+
ResourceLoader: () => import("./../loaders/ResourceLoader.vue"),
|
|
74
|
+
SidebarLoader: () => import("./../loaders/SidebarLoader.vue"),
|
|
75
|
+
},
|
|
76
|
+
props: {
|
|
77
|
+
searchText: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: "",
|
|
80
|
+
},
|
|
81
|
+
toggleHideValue: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: true,
|
|
84
|
+
},
|
|
85
|
+
isPreviewLoading: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: false,
|
|
88
|
+
},
|
|
89
|
+
isEditorReadOnly: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: false,
|
|
92
|
+
},
|
|
93
|
+
previewYamls: {
|
|
94
|
+
type: Array,
|
|
95
|
+
default: () => {
|
|
96
|
+
[];
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
showMinimap: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: false,
|
|
102
|
+
},
|
|
103
|
+
editorHeight: {
|
|
104
|
+
type: Number,
|
|
105
|
+
default: 60,
|
|
106
|
+
},
|
|
107
|
+
loaderColor: {
|
|
108
|
+
type: Object,
|
|
109
|
+
default: () => {
|
|
110
|
+
return {};
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
theme: {
|
|
114
|
+
type: String,
|
|
115
|
+
default: "light",
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
data() {
|
|
119
|
+
return {
|
|
120
|
+
activeKey: "",
|
|
121
|
+
hideValue: "",
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
computed: {
|
|
125
|
+
activeFile() {
|
|
126
|
+
const activeFile = this.filteredYamls.find(
|
|
127
|
+
(element) => element.uid === this.activeKey
|
|
128
|
+
);
|
|
129
|
+
return activeFile || { content: "", format: "yaml" };
|
|
130
|
+
},
|
|
131
|
+
originalValue() {
|
|
132
|
+
const activeFile = this.filteredYamls.find(
|
|
133
|
+
(element) => element.uid === this.activeKey
|
|
134
|
+
);
|
|
135
|
+
return (activeFile && activeFile.initContent) || "";
|
|
136
|
+
},
|
|
137
|
+
editorTheme() {
|
|
138
|
+
return this.theme === "dark" ? "vs-dark" : "vs";
|
|
139
|
+
},
|
|
140
|
+
primaryLoaderColor() {
|
|
141
|
+
return this.loaderColor.primaryLoaderColor;
|
|
142
|
+
},
|
|
143
|
+
secondaryLoaderColor() {
|
|
144
|
+
return this.loaderColor.secondaryLoaderColor;
|
|
145
|
+
},
|
|
146
|
+
filteredYamls() {
|
|
147
|
+
if (this.searchText) {
|
|
148
|
+
return this.previewYamls.filter(
|
|
149
|
+
(element) => JSON.stringify(element).search(this.searchText) > -1
|
|
150
|
+
);
|
|
151
|
+
} else return this.previewYamls;
|
|
152
|
+
},
|
|
153
|
+
isKeyAvailable() {
|
|
154
|
+
const val = this.previewYamls.find((element) => {
|
|
155
|
+
return element.uid === this.activeKey;
|
|
156
|
+
});
|
|
157
|
+
return val === undefined ? false : true;
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
methods: {
|
|
161
|
+
initActivePreview() {
|
|
162
|
+
if (!this.isKeyAvailable) {
|
|
163
|
+
this.activeKey = this.previewYamls[0].uid;
|
|
164
|
+
this.hideValue = this.activeFile.isSecret;
|
|
165
|
+
this.$emit("setActiveKey", this.activeKey);
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
setActivePreview(uid) {
|
|
169
|
+
this.activeKey = uid;
|
|
170
|
+
this.hideValue = this.activeFile.isSecret;
|
|
171
|
+
this.$emit("setActiveKey", this.activeKey);
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
watch: {
|
|
175
|
+
previewYamls: {
|
|
176
|
+
deep: true,
|
|
177
|
+
immediate: true,
|
|
178
|
+
handler(n) {
|
|
179
|
+
if (n.length) {
|
|
180
|
+
this.initActivePreview();
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
toggleHideValue(n) {
|
|
185
|
+
this.hideValue = n;
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
</script>
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="monaco-editor-vue2" :style="style"></div>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import * as monaco from "monaco-editor";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
name: "MonacoEditor",
|
|
10
|
+
props: {
|
|
11
|
+
diffEditor: { type: Boolean, default: false },
|
|
12
|
+
width: { type: [String, Number], default: "100%" },
|
|
13
|
+
height: { type: [String, Number], default: "100%" },
|
|
14
|
+
original: String,
|
|
15
|
+
value: String,
|
|
16
|
+
language: { type: String, default: "javascript" },
|
|
17
|
+
theme: { type: String, default: "vs" },
|
|
18
|
+
options: {
|
|
19
|
+
type: Object,
|
|
20
|
+
default() {
|
|
21
|
+
return {};
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
computed: {
|
|
26
|
+
style() {
|
|
27
|
+
const fixedWidth = this.width.toString().includes("%")
|
|
28
|
+
? this.width
|
|
29
|
+
: `${this.width}px`;
|
|
30
|
+
const fixedHeight = this.height.toString().includes("%")
|
|
31
|
+
? this.height
|
|
32
|
+
: `${this.height}px`;
|
|
33
|
+
return {
|
|
34
|
+
width: fixedWidth,
|
|
35
|
+
height: fixedHeight,
|
|
36
|
+
"text-align": "left",
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
mounted() {
|
|
41
|
+
this.initMonaco();
|
|
42
|
+
},
|
|
43
|
+
beforeDestroy() {
|
|
44
|
+
this.editor && this.editor.dispose();
|
|
45
|
+
},
|
|
46
|
+
methods: {
|
|
47
|
+
initMonaco() {
|
|
48
|
+
this.$emit("editorWillMount", this.monaco);
|
|
49
|
+
const { value, language, theme, options } = this;
|
|
50
|
+
this.editor = monaco.editor[
|
|
51
|
+
this.diffEditor ? "createDiffEditor" : "create"
|
|
52
|
+
](this.$el, {
|
|
53
|
+
value: value,
|
|
54
|
+
language: language,
|
|
55
|
+
theme: theme,
|
|
56
|
+
...options,
|
|
57
|
+
});
|
|
58
|
+
this.diffEditor && this._setModel(this.value, this.original);
|
|
59
|
+
|
|
60
|
+
// @event `change`
|
|
61
|
+
const editor = this._getEditor();
|
|
62
|
+
editor.onDidChangeModelContent((event) => {
|
|
63
|
+
const value = editor.getValue();
|
|
64
|
+
if (this.value !== value) {
|
|
65
|
+
this.$emit("change", value, event);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
this.$emit("editorDidMount", this.editor);
|
|
70
|
+
},
|
|
71
|
+
_setModel(value, original) {
|
|
72
|
+
const { language } = this;
|
|
73
|
+
const originalModel = monaco.editor.createModel(original, language);
|
|
74
|
+
const modifiedModel = monaco.editor.createModel(value, language);
|
|
75
|
+
this.editor.setModel({
|
|
76
|
+
original: originalModel,
|
|
77
|
+
modified: modifiedModel,
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
_setValue(value) {
|
|
81
|
+
let editor = this._getEditor();
|
|
82
|
+
if (editor) return editor.setValue(value);
|
|
83
|
+
},
|
|
84
|
+
_getValue() {
|
|
85
|
+
let editor = this._getEditor();
|
|
86
|
+
if (!editor) return "";
|
|
87
|
+
return editor.getValue();
|
|
88
|
+
},
|
|
89
|
+
_getEditor() {
|
|
90
|
+
if (!this.editor) return null;
|
|
91
|
+
return this.diffEditor ? this.editor.getModifiedEditor() : this.editor;
|
|
92
|
+
},
|
|
93
|
+
_setOriginal() {
|
|
94
|
+
const { original } = this.editor.getModel();
|
|
95
|
+
original.setValue(this.original);
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
watch: {
|
|
99
|
+
options: {
|
|
100
|
+
deep: true,
|
|
101
|
+
handler(options) {
|
|
102
|
+
this.editor.updateOptions(options);
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
value() {
|
|
106
|
+
this.value !== this._getValue() && this._setValue(this.value);
|
|
107
|
+
},
|
|
108
|
+
original() {
|
|
109
|
+
this._setOriginal();
|
|
110
|
+
},
|
|
111
|
+
language() {
|
|
112
|
+
if (!this.editor) return;
|
|
113
|
+
if (this.diffEditor) {
|
|
114
|
+
const { original, modified } = this.editor.getModel();
|
|
115
|
+
monaco.editor.setModelLanguage(original, this.language);
|
|
116
|
+
monaco.editor.setModelLanguage(modified, this.language);
|
|
117
|
+
} else
|
|
118
|
+
monaco.editor.setModelLanguage(this.editor.getModel(), this.language);
|
|
119
|
+
},
|
|
120
|
+
theme() {
|
|
121
|
+
monaco.editor.setTheme(this.theme);
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
</script>
|