@appscode/design-system 1.0.43-alpha.20 → 1.0.43-alpha.201

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.
Files changed (127) hide show
  1. package/base/utilities/_all.scss +6 -0
  2. package/base/utilities/_default.scss +298 -57
  3. package/base/utilities/_derived-variables.scss +0 -1
  4. package/base/utilities/_initial-variables.scss +16 -10
  5. package/base/utilities/_mixin.scss +1 -17
  6. package/base/utilities/_typography.scss +12 -2
  7. package/base/utilities/dark-theme.scss +9 -147
  8. package/components/_ac-accordion.scss +8 -4
  9. package/components/_ac-alert-box.scss +13 -5
  10. package/components/_ac-card.scss +33 -6
  11. package/components/_ac-code-highlight.scss +5 -1
  12. package/components/_ac-content-layout.scss +2 -2
  13. package/components/_ac-input.scss +63 -23
  14. package/components/_ac-modal.scss +1 -1
  15. package/components/_ac-multi-select.scss +187 -5
  16. package/components/_ac-options.scss +24 -9
  17. package/components/_ac-select-box.scss +13 -3
  18. package/components/_ac-table.scss +7 -5
  19. package/components/_ac-tabs.scss +33 -5
  20. package/components/_ac-terminal.scss +270 -0
  21. package/components/_all.scss +35 -0
  22. package/components/_app-drawer.scss +2 -2
  23. package/components/_breadcumb.scss +2 -0
  24. package/components/_buttons.scss +46 -37
  25. package/components/_card-body-wrapper.scss +2 -2
  26. package/components/_dashboard-header.scss +32 -0
  27. package/components/_direct-deploy.scss +69 -0
  28. package/components/_go-to-top.scss +1 -1
  29. package/components/_graph.scss +45 -0
  30. package/components/_image-upload.scss +5 -3
  31. package/components/_left-sidebar-menu.scss +115 -64
  32. package/components/_monaco-editor.scss +1 -1
  33. package/components/_navbar.scss +125 -7
  34. package/components/_overview-info.scss +3 -3
  35. package/components/_pagination.scss +8 -0
  36. package/components/_payment-card.scss +10 -1
  37. package/components/_preview-modal.scss +18 -5
  38. package/components/_pricing-table.scss +1 -1
  39. package/components/_progress-bar.scss +4 -4
  40. package/components/_subscription-card.scss +11 -4
  41. package/components/_table-of-content.scss +1 -1
  42. package/components/_tfa.scss +69 -0
  43. package/components/_transitions.scss +261 -0
  44. package/components/_wizard.scss +16 -3
  45. package/components/bbum/_card-team.scss +1 -1
  46. package/components/bbum/_information-center.scss +15 -1
  47. package/components/bbum/_sign-up-notification.scss +1 -1
  48. package/components/bbum/_single-post-preview.scss +1 -1
  49. package/components/bbum/_user-profile.scss +2 -3
  50. package/components/ui-builder/_ui-builder.scss +43 -3
  51. package/components/ui-builder/_vue-open-api.scss +104 -0
  52. package/layouts/_all.scss +2 -0
  53. package/layouts/_code-preview.scss +5 -2
  54. package/main.scss +4 -54
  55. package/package.json +2 -7
  56. package/plugins/theme.js +4 -0
  57. package/plugins/time-convert.js +49 -0
  58. package/plugins/vue-toaster.js +3 -0
  59. package/vue-components/v2/banner/Banner.vue +2 -2
  60. package/vue-components/v2/breadcrumbs/Breadcrumb.vue +97 -0
  61. package/vue-components/v2/button/Button.vue +5 -0
  62. package/vue-components/v2/button/DownloadBtn.vue +45 -0
  63. package/vue-components/v2/card/Card.vue +1 -0
  64. package/vue-components/v2/card/PaymentCards.vue +11 -2
  65. package/vue-components/v2/content/ContentTable.vue +12 -7
  66. package/vue-components/v2/editor/Editor.vue +38 -5
  67. package/vue-components/v2/editor/FilteredFileEditor.vue +189 -0
  68. package/vue-components/v2/editor/MonacoEditor.vue +125 -0
  69. package/vue-components/v2/editor/ResourceKeyValueEditor.vue +209 -0
  70. package/vue-components/v2/form-fields/Input.vue +1 -1
  71. package/vue-components/v2/loaders/ResourceLoader.vue +101 -0
  72. package/vue-components/v2/loaders/SidebarLoader.vue +43 -0
  73. package/vue-components/v2/modal/Modal.vue +38 -4
  74. package/vue-components/v2/modals/DeleteConfirmationModal.vue +79 -0
  75. package/vue-components/v2/modals/JsonShowModal.vue +12 -2
  76. package/vue-components/v2/navbar/Appdrawer.vue +10 -9
  77. package/vue-components/v2/navbar/ThemeMode.vue +50 -44
  78. package/vue-components/v2/navbar/User.vue +229 -17
  79. package/vue-components/v2/notification/Notification.vue +101 -0
  80. package/vue-components/v2/notification/NotificationItem.vue +44 -0
  81. package/vue-components/v2/pagination/Pagination.vue +16 -3
  82. package/vue-components/v2/preloader/Preloader.vue +5 -5
  83. package/vue-components/v2/sidebar/ClusterSwitcher.vue +126 -0
  84. package/vue-components/v2/sidebar/SidebarItem.vue +23 -1
  85. package/vue-components/v2/sidebar/SidebarItemWithDropDown.vue +19 -20
  86. package/vue-components/v2/tab/TabItem.vue +1 -1
  87. package/vue-components/v2/table/Table.vue +44 -8
  88. package/vue-components/v2/table/TableRow.vue +12 -2
  89. package/vue-components/v2/table/table-cell/CellValue.vue +33 -4
  90. package/vue-components/v2/table/table-cell/GenericCell.vue +56 -0
  91. package/vue-components/v2/table/table-cell/ObjectCell.vue +4 -1
  92. package/vue-components/v2/tabs/EditorTabs.vue +1 -1
  93. package/vue-components/v3/button/Button.vue +5 -0
  94. package/vue-components/v3/content/ContentTable.vue +5 -0
  95. package/vue-components/v3/editor/Editor.vue +36 -13
  96. package/vue-components/v3/editor/FilteredFileEditor.vue +186 -0
  97. package/vue-components/v3/editor/MonacoEditor.vue +131 -0
  98. package/vue-components/v3/editor/ResourceKeyValueEditor.vue +125 -0
  99. package/vue-components/v3/form/Form.vue +63 -0
  100. package/vue-components/v3/form-fields/Input.vue +11 -10
  101. package/vue-components/v3/header/HeaderItem.vue +5 -0
  102. package/vue-components/v3/header/HeaderItems.vue +5 -0
  103. package/vue-components/v3/loaders/ResourceLoader.vue +83 -0
  104. package/vue-components/v3/loaders/SidebarLoader.vue +34 -0
  105. package/vue-components/v3/long-running-tasks/LongRunningTaskItem.vue +92 -0
  106. package/vue-components/v3/modal/Modal.vue +35 -3
  107. package/vue-components/v3/modals/DeleteConfirmationModal.vue +85 -0
  108. package/vue-components/v3/modals/JsonShowModal.vue +25 -16
  109. package/vue-components/v3/modals/LongRunningTasksModal.vue +337 -0
  110. package/vue-components/v3/navbar/Appdrawer.vue +12 -7
  111. package/vue-components/v3/navbar/ThemeMode.vue +49 -47
  112. package/vue-components/v3/navbar/User.vue +242 -18
  113. package/vue-components/v3/notification/Notification.vue +98 -0
  114. package/vue-components/v3/notification/NotificationItem.vue +52 -0
  115. package/vue-components/v3/pagination/Pagination.vue +16 -3
  116. package/vue-components/v3/sidebar/ClusterSwitcher.vue +133 -0
  117. package/vue-components/v3/sidebar/SidebarItemWithDropDown.vue +120 -0
  118. package/vue-components/v3/tab/TabItem.vue +1 -1
  119. package/vue-components/v3/table/MultiInfoTable.vue +143 -0
  120. package/vue-components/v3/table/Table.vue +35 -12
  121. package/vue-components/v3/table/TableContainer.vue +34 -0
  122. package/vue-components/v3/table/TableRow.vue +16 -2
  123. package/vue-components/v3/table/table-cell/CellValue.vue +28 -3
  124. package/vue-components/v3/table/table-cell/GenericCell.vue +62 -0
  125. package/vue-components/v3/table/table-cell/ObjectCell.vue +5 -1
  126. package/vue-components/v3/tabs/EditorTabs.vue +1 -1
  127. package/vue-components/v3/terminal/LongRunningTaskTerminal.vue +148 -0
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <span
3
+ :class="{
4
+ 'is-flex': cellDescriptor.type !== 'object',
5
+ 'is-align-items-center': cellValue.icon,
6
+ 'is-justify-content-center': cellDescriptor.textAlign === 'center',
7
+ 'is-justify-content-left': cellDescriptor.textAlign === 'left',
8
+ 'is-justify-content-right': cellDescriptor.textAlign === 'right'
9
+ }"
10
+ >
11
+ <span v-if="cellValue.icon" class="icon p-0 mr-10">
12
+ <img width="15" :src="cellValue.icon" />
13
+ </span>
14
+ <router-link v-if="cellValue.link" :to="getCellLink(cellValue)">
15
+ {{ cellValue.data }}
16
+ </router-link>
17
+ <tag v-else-if="cellValue.color" :class="`is-${cellValue.color}`">
18
+ {{ cellValue.data }}
19
+ </tag>
20
+ <cell-value
21
+ v-else
22
+ :cell-title="cellDescriptor.name"
23
+ :value="cellValue.data || '-'"
24
+ :tooltip="cellValue.tooltip || JSON.stringify(cellValue.data)"
25
+ />
26
+ </span>
27
+ </template>
28
+ <script>
29
+ export default {
30
+ components: {
31
+ Tag: () => import("../../tag/Tag.vue"),
32
+ CellValue: () => import("../table-cell/CellValue.vue")
33
+ },
34
+ props: {
35
+ cellDescriptor: {
36
+ type: Object,
37
+ default: () => ({})
38
+ },
39
+ cellValue: {
40
+ type: Object,
41
+ default: () => ({})
42
+ }
43
+ },
44
+ methods: {
45
+ getCellLink(cell) {
46
+ const inject = (str, obj) => str.replace(/\${(.*?)}/g, (x, g) => obj[g]);
47
+ const { user, cluster } = this.$route.params;
48
+ const link = inject(cell.link || "", {
49
+ username: user,
50
+ clustername: cluster
51
+ });
52
+ return link;
53
+ }
54
+ }
55
+ };
56
+ </script>
@@ -68,7 +68,10 @@ export default {
68
68
  },
69
69
  printableStringObjs() {
70
70
  return this.objKeys.map((key) => {
71
- const value = this.obj[key];
71
+ let value = this.obj[key];
72
+ if (typeof value === "object" && value !== null) {
73
+ value = JSON.stringify(value);
74
+ }
72
75
  const keyValue = `${key}: ${value}`;
73
76
  const exceededLength = keyValue.length > 30;
74
77
  const print = exceededLength ? key : keyValue;
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <tabs-body class="mt-20">
2
+ <tabs-body>
3
3
  <tabs class="is-line">
4
4
  <tab-item :is-active="activeTab === 'edit'">
5
5
  <a @click.prevent="$emit('tabchange', 'edit')">Edit</a>
@@ -4,6 +4,7 @@
4
4
  :class="`${modifierClasses}${isLoaderActive ? ' is-loading' : ''}`"
5
5
  :disabled="disabled ? true : null"
6
6
  @click="handleClick"
7
+ :title="tooltip"
7
8
  >
8
9
  <span v-if="iconClass || iconImage" class="icon is-small">
9
10
  <img
@@ -28,6 +29,10 @@ export default defineComponent({
28
29
  type: String,
29
30
  default: "",
30
31
  },
32
+ tooltip: {
33
+ type: String,
34
+ defualt: undefined
35
+ },
31
36
  // for loader
32
37
  isLoaderActive: {
33
38
  type: Boolean,
@@ -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 }"
@@ -38,6 +39,10 @@ export default defineComponent({
38
39
  type: Boolean,
39
40
  default: true,
40
41
  },
42
+ hideHeader: {
43
+ type: Boolean,
44
+ default: false
45
+ }
41
46
  },
42
47
  components: {
43
48
  ContentLayout: defineAsyncComponent(() =>
@@ -7,7 +7,6 @@
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`"
@@ -18,9 +17,12 @@
18
17
  minimap: {
19
18
  enabled: calcShowMinimap,
20
19
  },
20
+ theme: theme,
21
21
  readOnly: readOnly,
22
+ wordWrap: wordWrap,
22
23
  scrollBeyondLastLine: false,
23
24
  }"
25
+ data-testid="monaco-editor-edit-section"
24
26
  />
25
27
  <monaco-editor
26
28
  v-if="activeTab === 'preview'"
@@ -32,20 +34,25 @@
32
34
  minimap: {
33
35
  enabled: calcShowMinimap,
34
36
  },
37
+ theme: theme,
35
38
  readOnly: true,
39
+ wordWrap: wordWrap,
36
40
  scrollBeyondLastLine: false,
37
41
  }"
38
42
  :original="originalEditorContent"
39
43
  :diff-editor="true"
44
+ data-testid="monaco-editor-preview-section"
40
45
  />
41
46
  </div>
42
47
  </template>
43
48
 
44
49
  <script>
45
50
  import { defineComponent, defineAsyncComponent, h } from "vue";
51
+ import Preloader from "../../v2/preloader/Preloader.vue";
52
+ import Banner from "../../v2/banner/Banner.vue";
46
53
  export default defineComponent({
47
54
  props: {
48
- value: {
55
+ modelValue: {
49
56
  type: String,
50
57
  default: "",
51
58
  },
@@ -69,6 +76,14 @@ export default defineComponent({
69
76
  type: Number,
70
77
  default: 40,
71
78
  },
79
+ editorTheme: {
80
+ type: String,
81
+ default: "",
82
+ },
83
+ wordWrap: {
84
+ type: String,
85
+ default: "off",
86
+ },
72
87
  },
73
88
 
74
89
  emits: ["update:modelValue"],
@@ -77,14 +92,15 @@ export default defineComponent({
77
92
  EditorTabs: defineAsyncComponent(() =>
78
93
  import("../tabs/EditorTabs.vue").then((module) => module.default)
79
94
  ),
80
- MonacoEditor: defineAsyncComponent(() =>
81
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
82
- // @ts-ignore
83
- import("vue-monaco").then((module) => {
84
- module.default.render = () => h("div");
85
- return module.default;
86
- })
87
- ),
95
+ MonacoEditor: defineAsyncComponent({
96
+ loader: () =>
97
+ import("./MonacoEditor.vue").then((module) => module.default),
98
+
99
+ loadingComponent: Preloader,
100
+ delay: 200,
101
+ errorComponent: Banner,
102
+ timeout: 100000,
103
+ }),
88
104
  },
89
105
 
90
106
  data() {
@@ -100,10 +116,18 @@ export default defineComponent({
100
116
  const noOfLines = this.editorContent.split("\n").length;
101
117
  return this.showMinimap && noOfLines * 2 > this.editorHeight;
102
118
  },
119
+ theme() {
120
+ return (
121
+ this.editorTheme ||
122
+ (document.documentElement.classList.contains("is-dark-theme")
123
+ ? "vs-dark"
124
+ : "vs")
125
+ );
126
+ },
103
127
  },
104
128
 
105
129
  watch: {
106
- value: {
130
+ modelValue: {
107
131
  immediate: true,
108
132
  handler(n) {
109
133
  if (this.editorContent !== n) {
@@ -125,8 +149,7 @@ export default defineComponent({
125
149
  onChange(e) {
126
150
  if (typeof e === "string") this.editorContent = e;
127
151
  },
128
- onEditorMount() {
129
- const editor = this.$refs.monacoEditor.getEditor();
152
+ onEditorMount(editor) {
130
153
  // add event listeners
131
154
  editor.onDidBlurEditorText(() => {
132
155
  this.$emit("update:modelValue", this.editorContent);
@@ -0,0 +1,186 @@
1
+ <template>
2
+ <div class="ac-preview is-active is-not-fixed">
3
+ <div class="ac-preview-inner">
4
+ <!-- preview body start -->
5
+ <div
6
+ class="ac-preview-body mt-0 pt-20"
7
+ :class="{
8
+ 'is-justify-content-center': isYamlsEmpty && !isPreviewLoading,
9
+ }"
10
+ >
11
+ <strong v-if="isYamlsEmpty && !isPreviewLoading">
12
+ No Data Available
13
+ <i class="pl-5 fa fa-exclamation-circle" aria-hidden="true"></i>
14
+ </strong>
15
+ <template v-else>
16
+ <div v-if="!isPreviewLoading && previewYamls" class="left-content">
17
+ <div class="ac-files ac-hscrollbar pt-0">
18
+ <ul v-if="!isPreviewLoading">
19
+ <li
20
+ v-for="(previewYaml, idx) in filteredYamls"
21
+ :key="previewYaml.name + idx"
22
+ :class="{ 'is-active': activeKey === previewYaml.uid }"
23
+ :title="previewYaml.name"
24
+ data-testid="filtered-file-editor-file-name"
25
+ >
26
+ <a @click.prevent="setActivePreview(previewYaml.uid)">
27
+ <span>
28
+ <img
29
+ src="~@appscode/design-system-images/icons/file-icon.svg"
30
+ alt=""
31
+ />
32
+ </span>
33
+ <span>{{ previewYaml.name }}</span>
34
+ </a>
35
+ </li>
36
+ </ul>
37
+ <sidebar-loader v-else />
38
+ </div>
39
+ </div>
40
+ <div class="right-content" data-testid="filtered-file-editor-content">
41
+ <resource-loader v-if="isPreviewLoading" />
42
+ <strong v-else-if="isYamlsNotSelected"
43
+ >Selecet a data from sidebar</strong
44
+ >
45
+ <strong v-else-if="hideValue"> *************** </strong>
46
+ <editor
47
+ v-else
48
+ v-model="activeFile.content"
49
+ :original-value="originalValue"
50
+ :language="activeFile.format"
51
+ :read-only="isEditorReadOnly"
52
+ :editor-height="editorHeight"
53
+ :show-minimap="showMinimap"
54
+ />
55
+ </div>
56
+ </template>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </template>
61
+ <script>
62
+ import { defineComponent, defineAsyncComponent } from "vue";
63
+ import Preloader from "../../v2/preloader/Preloader.vue";
64
+ import Banner from "../../v2/banner/Banner.vue";
65
+ export default defineComponent({
66
+ components: {
67
+ Editor: defineAsyncComponent({
68
+ loader: () =>
69
+ import("../editor/Editor.vue").then((module) => module.default),
70
+ loadingComponent: Preloader,
71
+ delay: 200,
72
+ errorComponent: Banner,
73
+ timeout: 100000,
74
+ }),
75
+ ResourceLoader: defineAsyncComponent(() =>
76
+ import("../loaders/ResourceLoader.vue")
77
+ ),
78
+ SidebarLoader: defineAsyncComponent(() =>
79
+ import("../loaders/SidebarLoader.vue")
80
+ ),
81
+ },
82
+ props: {
83
+ searchText: {
84
+ type: String,
85
+ default: "",
86
+ },
87
+ toggleHideValue: {
88
+ type: Boolean,
89
+ default: true,
90
+ },
91
+ isPreviewLoading: {
92
+ type: Boolean,
93
+ default: false,
94
+ },
95
+ isEditorReadOnly: {
96
+ type: Boolean,
97
+ default: false,
98
+ },
99
+ previewYamls: {
100
+ type: Array,
101
+ default: () => {
102
+ [];
103
+ },
104
+ },
105
+ showMinimap: {
106
+ type: Boolean,
107
+ default: false,
108
+ },
109
+ editorHeight: {
110
+ type: Number,
111
+ default: 60,
112
+ },
113
+ },
114
+ emits: ["setActiveKey"],
115
+ data() {
116
+ return {
117
+ activeKey: "",
118
+ hideValue: "",
119
+ };
120
+ },
121
+ computed: {
122
+ activeFile() {
123
+ const activeFile = this.filteredYamls.find(
124
+ (element) => element.uid === this.activeKey
125
+ );
126
+ return activeFile || { content: "", format: "yaml" };
127
+ },
128
+ originalValue() {
129
+ const activeFile = this.filteredYamls.find(
130
+ (element) => element.uid === this.activeKey
131
+ );
132
+ return (activeFile && activeFile.initContent) || "";
133
+ },
134
+ filteredYamls() {
135
+ if (this.searchText) {
136
+ return this.previewYamls.filter(
137
+ (element) => JSON.stringify(element).search(this.searchText) > -1
138
+ );
139
+ } else return this.previewYamls;
140
+ },
141
+ isKeyAvailable() {
142
+ const val = this.previewYamls.find((element) => {
143
+ return element.uid === this.activeKey;
144
+ });
145
+ return val === undefined ? false : true;
146
+ },
147
+ isYamlsEmpty() {
148
+ return this.filteredYamls.length === 0;
149
+ },
150
+ isYamlsNotSelected() {
151
+ const val = this.filteredYamls.find((element) => {
152
+ return element.uid === this.activeKey;
153
+ });
154
+ return val === undefined;
155
+ },
156
+ },
157
+ methods: {
158
+ initActivePreview() {
159
+ if (!this.isKeyAvailable) {
160
+ this.activeKey = this.previewYamls[0].uid;
161
+ this.hideValue = this.activeFile.isSecret;
162
+ this.$emit("setActiveKey", this.activeKey);
163
+ }
164
+ },
165
+ setActivePreview(uid) {
166
+ this.activeKey = uid;
167
+ this.hideValue = this.activeFile.isSecret;
168
+ this.$emit("setActiveKey", this.activeKey);
169
+ },
170
+ },
171
+ watch: {
172
+ previewYamls: {
173
+ deep: true,
174
+ immediate: true,
175
+ handler(n) {
176
+ if (n.length) {
177
+ this.initActivePreview();
178
+ }
179
+ },
180
+ },
181
+ toggleHideValue(n) {
182
+ this.hideValue = n;
183
+ },
184
+ },
185
+ });
186
+ </script>
@@ -0,0 +1,131 @@
1
+ <template>
2
+ <div class="monaco-editor-vue3" :style="style"></div>
3
+ </template>
4
+
5
+ <script>
6
+ import { defineComponent, computed, toRefs } from "vue";
7
+ import * as monaco from "monaco-editor";
8
+
9
+ export default defineComponent({
10
+ name: "MonacoEditor",
11
+ props: {
12
+ diffEditor: { type: Boolean, default: false },
13
+ width: { type: [String, Number], default: "100%" },
14
+ height: { type: [String, Number], default: "100%" },
15
+ original: String,
16
+ value: String,
17
+ language: { type: String, default: "javascript" },
18
+ theme: { type: String, default: "vs" },
19
+ options: {
20
+ type: Object,
21
+ default() {
22
+ return {};
23
+ },
24
+ },
25
+ },
26
+ emits: ["editorWillMount", "editorDidMount", "change"],
27
+ setup(props) {
28
+ const { width, height } = toRefs(props);
29
+ const style = computed(() => {
30
+ const fixedWidth = width.value.toString().includes("%")
31
+ ? width.value
32
+ : `${width.value}px`;
33
+ const fixedHeight = height.value.toString().includes("%")
34
+ ? height.value
35
+ : `${height.value}px`;
36
+ return {
37
+ width: fixedWidth,
38
+ height: fixedHeight,
39
+ "text-align": "left",
40
+ };
41
+ });
42
+ return {
43
+ style,
44
+ };
45
+ },
46
+ mounted() {
47
+ this.initMonaco();
48
+ },
49
+ beforeUnmount() {
50
+ this.editor && this.editor.dispose();
51
+ },
52
+ methods: {
53
+ initMonaco() {
54
+ this.$emit("editorWillMount", this.monaco);
55
+ const { value, language, theme, options } = this;
56
+ this.editor = monaco.editor[
57
+ this.diffEditor ? "createDiffEditor" : "create"
58
+ ](this.$el, {
59
+ value: value,
60
+ language: language,
61
+ theme: theme,
62
+ ...options,
63
+ });
64
+ this.diffEditor && this._setModel(this.value, this.original);
65
+
66
+ // @event `change`
67
+ const editor = this._getEditor();
68
+ editor.onDidChangeModelContent((event) => {
69
+ const value = editor.getValue();
70
+ if (this.value !== value) {
71
+ this.$emit("change", value, event);
72
+ }
73
+ });
74
+
75
+ this.$emit("editorDidMount", this.editor);
76
+ },
77
+ _setModel(value, original) {
78
+ const { language } = this;
79
+ const originalModel = monaco.editor.createModel(original, language);
80
+ const modifiedModel = monaco.editor.createModel(value, language);
81
+ this.editor.setModel({
82
+ original: originalModel,
83
+ modified: modifiedModel,
84
+ });
85
+ },
86
+ _setValue(value) {
87
+ let editor = this._getEditor();
88
+ if (editor) return editor.setValue(value);
89
+ },
90
+ _getValue() {
91
+ let editor = this._getEditor();
92
+ if (!editor) return "";
93
+ return editor.getValue();
94
+ },
95
+ _getEditor() {
96
+ if (!this.editor) return null;
97
+ return this.diffEditor ? this.editor.getModifiedEditor() : this.editor;
98
+ },
99
+ _setOriginal() {
100
+ const { original } = this.editor.getModel();
101
+ original.setValue(this.original);
102
+ },
103
+ },
104
+ watch: {
105
+ options: {
106
+ deep: true,
107
+ handler(options) {
108
+ this.editor.updateOptions(options);
109
+ },
110
+ },
111
+ value() {
112
+ this.value !== this._getValue() && this._setValue(this.value);
113
+ },
114
+ original() {
115
+ this._setOriginal();
116
+ },
117
+ language() {
118
+ if (!this.editor) return;
119
+ if (this.diffEditor) {
120
+ const { original, modified } = this.editor.getModel();
121
+ monaco.editor.setModelLanguage(original, this.language);
122
+ monaco.editor.setModelLanguage(modified, this.language);
123
+ } else
124
+ monaco.editor.setModelLanguage(this.editor.getModel(), this.language);
125
+ },
126
+ theme() {
127
+ monaco.editor.setTheme(this.theme);
128
+ },
129
+ },
130
+ });
131
+ </script>
@@ -0,0 +1,125 @@
1
+ <template>
2
+ <content-table
3
+ :table-title="title"
4
+ :searchable="isSearchable"
5
+ :hide-header="hideHeader"
6
+ >
7
+ <template #content-right-controls>
8
+ <header-item v-if="showHideBtn">
9
+ <ac-button
10
+ modifier-classes="is-square is-primary"
11
+ :icon-class="toggleHideValue ? 'eye-slash' : 'eye'"
12
+ :disabled="previewYamls.length === 0"
13
+ @click.prevent="toggleHideValue = !toggleHideValue"
14
+ />
15
+ </header-item>
16
+ <slot name="content-action" />
17
+ </template>
18
+ <template #content="{ searchText }">
19
+ <filtered-file-editor
20
+ :search-text="searchText"
21
+ :toggle-hide-value="toggleHideValue"
22
+ :is-preview-loading="isPreviewLoading"
23
+ :is-editor-read-only="isEditorReadOnly"
24
+ :preview-yamls="previewYamls"
25
+ :show-minimap="showMinimap"
26
+ :editor-height="editorHeight"
27
+ @setActiveKey="setActiveKey"
28
+ />
29
+ </template>
30
+ </content-table>
31
+ </template>
32
+ <script>
33
+ import { defineComponent, defineAsyncComponent } from "vue";
34
+ export default defineComponent({
35
+ components: {
36
+ AcButton: defineAsyncComponent(() => import("../button/Button.vue")),
37
+ ContentTable: defineAsyncComponent(() =>
38
+ import("../content/ContentTable.vue")
39
+ ),
40
+ HeaderItem: defineAsyncComponent(() => import("../header/HeaderItem.vue")),
41
+ FilteredFileEditor: defineAsyncComponent(() =>
42
+ import("./FilteredFileEditor.vue")
43
+ )
44
+ },
45
+ props: {
46
+ title: {
47
+ type: String,
48
+ default: "Title"
49
+ },
50
+ isSearchable: {
51
+ type: Boolean,
52
+ default: false
53
+ },
54
+ isPreviewLoading: {
55
+ type: Boolean,
56
+ default: false
57
+ },
58
+ isEditorReadOnly: {
59
+ type: Boolean,
60
+ default: false
61
+ },
62
+ previewYamls: {
63
+ type: Array,
64
+ default: () => {
65
+ [];
66
+ }
67
+ },
68
+ showHideBtn: {
69
+ type: Boolean,
70
+ default: false,
71
+ },
72
+ showMinimap: {
73
+ type: Boolean,
74
+ default: false
75
+ },
76
+ isUpdateActive: {
77
+ type: Boolean,
78
+ default: false
79
+ },
80
+ deleteModalStatus: {
81
+ type: String,
82
+ default: "closed"
83
+ },
84
+ editorHeight: {
85
+ type: Number,
86
+ default: 60
87
+ },
88
+ hideHeader: {
89
+ type: Boolean,
90
+ default: false
91
+ }
92
+ },
93
+ emits: ["activeKey"],
94
+ data() {
95
+ return {
96
+ activeKey: "",
97
+ toggleHideValue: "",
98
+ showDeleteDataModal: false
99
+ };
100
+ },
101
+ computed: {
102
+ activeFile() {
103
+ const activeFile = this.previewYamls.find(
104
+ element => element.uid === this.activeKey
105
+ );
106
+ return activeFile || { content: "", format: "yaml" };
107
+ },
108
+ },
109
+ methods: {
110
+ setActiveKey(key) {
111
+ this.activeKey = key;
112
+ this.toggleHideValue = this.activeFile.isSecret;
113
+ }
114
+ },
115
+ watch: {
116
+ activeKey:{
117
+ immediate: true,
118
+ handler(n){
119
+ this.$emit("activeKey",this.activeKey);
120
+ }
121
+ }
122
+
123
+ }
124
+ });
125
+ </script>