@appscode/design-system 1.0.43-alpha.15 → 1.0.43-alpha.152

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 (117) hide show
  1. package/base/utilities/_default.scss +283 -21
  2. package/base/utilities/_derived-variables.scss +0 -13
  3. package/base/utilities/_initial-variables.scss +78 -56
  4. package/base/utilities/_mixin.scss +10 -17
  5. package/base/utilities/_typography.scss +23 -7
  6. package/base/utilities/dark-theme.scss +25 -0
  7. package/components/_ac-accordion.scss +1 -0
  8. package/components/_ac-alert-box.scss +18 -10
  9. package/components/_ac-card.scss +55 -20
  10. package/components/_ac-code-highlight.scss +7 -1
  11. package/components/_ac-content-layout.scss +4 -4
  12. package/components/_ac-drag.scss +6 -6
  13. package/components/_ac-input.scss +82 -40
  14. package/components/_ac-modal.scss +5 -4
  15. package/components/_ac-multi-select.scss +195 -13
  16. package/components/_ac-options.scss +31 -16
  17. package/components/_ac-select-box.scss +15 -5
  18. package/components/_ac-table.scss +42 -36
  19. package/components/_ac-tabs.scss +72 -23
  20. package/components/_ac-tags.scss +2 -2
  21. package/components/_ac-terminal.scss +272 -0
  22. package/components/_app-drawer.scss +6 -6
  23. package/components/_breadcumb.scss +7 -2
  24. package/components/_buttons.scss +60 -27
  25. package/components/_card-body-wrapper.scss +3 -3
  26. package/components/_dashboard-header.scss +33 -1
  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 +6 -4
  31. package/components/_left-sidebar-menu.scss +200 -46
  32. package/components/_monaco-editor.scss +1 -1
  33. package/components/_navbar.scss +129 -26
  34. package/components/_overview-info.scss +4 -4
  35. package/components/_overview-page.scss +1 -2
  36. package/components/_pagination.scss +10 -2
  37. package/components/_payment-card.scss +28 -12
  38. package/components/_preview-modal.scss +19 -8
  39. package/components/_pricing-table.scss +1 -1
  40. package/components/_progress-bar.scss +5 -5
  41. package/components/_subscription-card.scss +15 -8
  42. package/components/_table-of-content.scss +1 -1
  43. package/components/_tfa.scss +69 -0
  44. package/components/_transitions.scss +261 -0
  45. package/components/_widget-menu.scss +9 -9
  46. package/components/_wizard.scss +31 -19
  47. package/components/ac-toaster/_ac-toasted.scss +5 -5
  48. package/components/bbum/_card-team.scss +18 -10
  49. package/components/bbum/_information-center.scss +17 -3
  50. package/components/bbum/_mobile-desktop.scss +6 -6
  51. package/components/bbum/_post.scss +5 -4
  52. package/components/bbum/_sign-up-notification.scss +6 -6
  53. package/components/bbum/_single-post-preview.scss +9 -9
  54. package/components/bbum/_user-profile.scss +97 -90
  55. package/components/ui-builder/_ui-builder.scss +29 -10
  56. package/components/ui-builder/_vue-open-api.scss +98 -0
  57. package/layouts/_404.scss +2 -1
  58. package/layouts/_code-preview.scss +14 -7
  59. package/main.scss +4 -0
  60. package/package.json +2 -7
  61. package/plugins/theme.js +4 -0
  62. package/vue-components/v2/banner/Banner.vue +2 -2
  63. package/vue-components/v2/breadcrumbs/Breadcrumb.vue +97 -0
  64. package/vue-components/v2/button/Button.vue +5 -0
  65. package/vue-components/v2/button/DownloadBtn.vue +45 -0
  66. package/vue-components/v2/card/PaymentCards.vue +11 -2
  67. package/vue-components/v2/content/ContentTable.vue +12 -7
  68. package/vue-components/v2/editor/Editor.vue +36 -5
  69. package/vue-components/v2/editor/FilteredFileEditor.vue +188 -0
  70. package/vue-components/v2/editor/MonacoEditor.vue +125 -0
  71. package/vue-components/v2/editor/ResourceKeyValueEditor.vue +209 -0
  72. package/vue-components/v2/loaders/ResourceLoader.vue +101 -0
  73. package/vue-components/v2/loaders/SidebarLoader.vue +43 -0
  74. package/vue-components/v2/modal/Modal.vue +37 -12
  75. package/vue-components/v2/modals/DeleteConfirmationModal.vue +77 -0
  76. package/vue-components/v2/modals/JsonShowModal.vue +12 -2
  77. package/vue-components/v2/navbar/Appdrawer.vue +10 -9
  78. package/vue-components/v2/navbar/ThemeMode.vue +120 -0
  79. package/vue-components/v2/navbar/User.vue +166 -15
  80. package/vue-components/v2/preloader/Preloader.vue +5 -5
  81. package/vue-components/v2/sidebar/ClusterSwitcher.vue +126 -0
  82. package/vue-components/v2/sidebar/SidebarItem.vue +23 -1
  83. package/vue-components/v2/sidebar/SidebarItemWithDropDown.vue +19 -20
  84. package/vue-components/v2/table/Table.vue +44 -8
  85. package/vue-components/v2/table/TableRow.vue +17 -8
  86. package/vue-components/v2/table/table-cell/CellValue.vue +31 -4
  87. package/vue-components/v2/table/table-cell/GenericCell.vue +56 -0
  88. package/vue-components/v2/table/table-cell/ObjectCell.vue +4 -1
  89. package/vue-components/v2/tabs/EditorTabs.vue +1 -1
  90. package/vue-components/v3/button/Button.vue +5 -0
  91. package/vue-components/v3/content/ContentTable.vue +5 -0
  92. package/vue-components/v3/editor/Editor.vue +50 -30
  93. package/vue-components/v3/editor/FilteredFileEditor.vue +166 -0
  94. package/vue-components/v3/editor/MonacoEditor.vue +131 -0
  95. package/vue-components/v3/editor/ResourceKeyValueEditor.vue +124 -0
  96. package/vue-components/v3/form/Form.vue +63 -0
  97. package/vue-components/v3/form-fields/Input.vue +10 -10
  98. package/vue-components/v3/header/HeaderItem.vue +5 -0
  99. package/vue-components/v3/header/HeaderItems.vue +5 -0
  100. package/vue-components/v3/loaders/ResourceLoader.vue +83 -0
  101. package/vue-components/v3/loaders/SidebarLoader.vue +34 -0
  102. package/vue-components/v3/modal/Modal.vue +38 -15
  103. package/vue-components/v3/modals/DeleteConfirmationModal.vue +83 -0
  104. package/vue-components/v3/modals/JsonShowModal.vue +25 -16
  105. package/vue-components/v3/navbar/Appdrawer.vue +12 -7
  106. package/vue-components/v3/navbar/ThemeMode.vue +123 -0
  107. package/vue-components/v3/navbar/User.vue +166 -15
  108. package/vue-components/v3/sidebar/ClusterSwitcher.vue +133 -0
  109. package/vue-components/v3/sidebar/SidebarItemWithDropDown.vue +120 -0
  110. package/vue-components/v3/table/MultiInfoTable.vue +143 -0
  111. package/vue-components/v3/table/Table.vue +34 -11
  112. package/vue-components/v3/table/TableContainer.vue +34 -0
  113. package/vue-components/v3/table/TableRow.vue +1 -1
  114. package/vue-components/v3/table/table-cell/CellValue.vue +26 -3
  115. package/vue-components/v3/table/table-cell/GenericCell.vue +62 -0
  116. package/vue-components/v3/table/table-cell/ObjectCell.vue +5 -1
  117. package/vue-components/v3/tabs/EditorTabs.vue +1 -1
@@ -10,14 +10,16 @@
10
10
  <ac-button
11
11
  modifier-classes="is-square is-primary"
12
12
  icon-class="copy"
13
- v-clipboard:copy="`${editorTitle}: &quot;${editorContent}&quot;`"
13
+ v-clipboard:copy="
14
+ `${editorTitle}: ${JSON.stringify(parsedContent, null, 4)}`
15
+ "
14
16
  v-clipboard:success="onCopy"
15
17
  v-clipboard:error="onError"
16
18
  />
17
19
  </header-item>
18
20
  </template>
19
21
  <editor
20
- :value="JSON.stringify(parsedContent, null, 4)"
22
+ :model-value="JSON.stringify(parsedContent, null, 4)"
21
23
  :read-only="true"
22
24
  language="json"
23
25
  :show-minimap="false"
@@ -28,36 +30,43 @@
28
30
  <script>
29
31
  import { defineComponent, defineAsyncComponent } from "vue";
30
32
  import { useToast } from "vue-toastification";
33
+ import Preloader from "../../v2/preloader/Preloader.vue";
34
+ import Banner from "../../v2/banner/Banner.vue";
31
35
 
32
36
  export default defineComponent({
33
37
  props: {
34
38
  open: {
35
39
  type: Boolean,
36
- default: false,
40
+ default: false
37
41
  },
38
42
  editorTitle: {
39
43
  type: String,
40
- default: "",
44
+ default: ""
41
45
  },
42
46
  editorContent: {
43
47
  type: null,
44
- default: () => ({}),
45
- },
48
+ default: () => ({})
49
+ }
46
50
  },
47
51
  emits: ["closemodal"],
48
52
  components: {
49
53
  Modal: defineAsyncComponent(() =>
50
- import("../modal/Modal.vue").then((module) => module.default)
51
- ),
52
- Editor: defineAsyncComponent(() =>
53
- import("../editor/Editor.vue").then((module) => module.default)
54
+ import("../modal/Modal.vue").then(module => module.default)
54
55
  ),
56
+ Editor: defineAsyncComponent({
57
+ loader: () =>
58
+ import("../editor/Editor.vue").then(module => module.default),
59
+ loadingComponent: Preloader,
60
+ delay: 200,
61
+ errorComponent: Banner,
62
+ timeout: 60000,
63
+ }),
55
64
  AcButton: defineAsyncComponent(() =>
56
- import("../button/Button.vue").then((module) => module.default)
65
+ import("../button/Button.vue").then(module => module.default)
57
66
  ),
58
67
  HeaderItem: defineAsyncComponent(() =>
59
- import("../../v2/header/HeaderItem.vue").then((module) => module.default)
60
- ),
68
+ import("../../v2/header/HeaderItem.vue").then(module => module.default)
69
+ )
61
70
  },
62
71
  computed: {
63
72
  parsedContent() {
@@ -66,7 +75,7 @@ export default defineComponent({
66
75
  } catch (e) {
67
76
  return this.editorContent;
68
77
  }
69
- },
78
+ }
70
79
  },
71
80
  setup() {
72
81
  const toast = useToast();
@@ -81,7 +90,7 @@ export default defineComponent({
81
90
  },
82
91
  closeModal() {
83
92
  this.$emit("closemodal", true);
84
- },
85
- },
93
+ }
94
+ }
86
95
  });
87
96
  </script>
@@ -1,10 +1,13 @@
1
1
  <template>
2
- <div class="app-drawer-wrapper">
3
- <div class="drawer-icon">
2
+ <div class="app-drawer-wrapper is-flex">
3
+ <div
4
+ class="drawer-icon is-flex is-justify-content-center is-align-items-center"
5
+ >
4
6
  <svg
5
7
  class="gb_We"
6
8
  focusable="false"
7
9
  viewBox="0 0 24 24"
10
+ style="width: 22px;margin-top: 2px;"
8
11
  :style="{ fill: 'white' }"
9
12
  >
10
13
  <path
@@ -46,13 +49,15 @@ export default defineComponent({
46
49
  props: {
47
50
  apps: {
48
51
  type: Array,
49
- default: () => [],
50
- },
52
+ default: () => []
53
+ }
51
54
  },
52
55
  components: {
53
56
  NavbarItemContent: defineAsyncComponent(() =>
54
- import("../../v2/navbar/NavbarItemContent.vue").then((module) => module.default)
55
- ),
56
- },
57
+ import("../../v2/navbar/NavbarItemContent.vue").then(
58
+ module => module.default
59
+ )
60
+ )
61
+ }
57
62
  });
58
63
  </script>
@@ -0,0 +1,123 @@
1
+ <template>
2
+ <div>
3
+ <button
4
+ v-if="themeMode"
5
+ class="button ac-nav-button"
6
+ @click="toggleTheme"
7
+ :title="themeModes[themeMode].displayName"
8
+ >
9
+ <i :class="`fa ${themeModes[themeMode].iconClass} width-15`" />
10
+ </button>
11
+ <div class="ac-menu-content theme-choice">
12
+ <ul class="is-flex is-flex-direction-row is-justify-content-space-around">
13
+ <li
14
+ v-for="theme of Object.keys(themeModes)"
15
+ :title="themeModes[theme].displayName"
16
+ @click="themeMode = theme"
17
+ :class="{ 'is-active': themeMode === theme }"
18
+ :key="theme"
19
+ >
20
+ <i :class="['fa', themeModes[theme].iconClass]" />
21
+ </li>
22
+ </ul>
23
+ </div>
24
+ </div>
25
+ </template>
26
+ <script>
27
+ import { defineComponent } from "vue";
28
+
29
+ export default defineComponent({
30
+ data() {
31
+ return {
32
+ themeMode: "",
33
+ themeModes: {
34
+ system: {
35
+ displayName: "System Theme",
36
+ iconClass: "fa-desktop",
37
+ },
38
+ light: {
39
+ displayName: "Light Theme",
40
+ iconClass: "fa-sun-o",
41
+ },
42
+ dark: {
43
+ displayName: "Dark Theme",
44
+ iconClass: "fa-moon-o",
45
+ },
46
+ },
47
+ };
48
+ },
49
+
50
+ emits: ["set:theme"],
51
+
52
+ mounted() {
53
+ // get theme mode from localStorage or set default one
54
+ this.themeMode = localStorage.getItem("themeMode") || "light";
55
+ },
56
+
57
+ unmounted() {
58
+ this.removeColorSchemeEventListener();
59
+ },
60
+
61
+ watch: {
62
+ themeMode: {
63
+ handler(n) {
64
+ this.onThemeModeChange(n);
65
+ },
66
+ },
67
+ },
68
+
69
+ methods: {
70
+ // handle theme mode button click
71
+ toggleTheme() {
72
+ if (this.themeMode === "light") this.themeMode = "dark";
73
+ else if (this.themeMode === "dark") this.themeMode = "system";
74
+ else if (this.themeMode === "system") this.themeMode = "light";
75
+ },
76
+
77
+ // triggered when theme mode is updated
78
+ onThemeModeChange(n) {
79
+ localStorage.setItem("themeMode", n);
80
+
81
+ let theme = n;
82
+ if (n === "system") {
83
+ const isDarkMode =
84
+ window.matchMedia &&
85
+ window.matchMedia("(prefers-color-scheme: dark)").matches;
86
+ this.addColorSchemeEventListener();
87
+ theme = isDarkMode ? "dark" : "light";
88
+ } else {
89
+ this.removeColorSchemeEventListener();
90
+ }
91
+ this.$emit("set:theme", theme);
92
+ this.handleDarkThemeClass(theme);
93
+ },
94
+
95
+ // add proper css class to update the ui theme
96
+ handleDarkThemeClass(currentTheme) {
97
+ if (currentTheme === "light") {
98
+ document.documentElement.classList.remove("is-dark-theme");
99
+ } else {
100
+ document.documentElement.classList.add("is-dark-theme");
101
+ }
102
+ },
103
+
104
+ // add system theme listener event
105
+ addColorSchemeEventListener() {
106
+ window
107
+ .matchMedia("(prefers-color-scheme: dark)")
108
+ .addEventListener("change", this.handleSystemThemeChange);
109
+ },
110
+
111
+ // remove system theme listener event
112
+ removeColorSchemeEventListener() {
113
+ window
114
+ .matchMedia("(prefers-color-scheme: dark)")
115
+ .removeEventListener("change", this.handleSystemThemeChange);
116
+ },
117
+
118
+ handleSystemThemeChange() {
119
+ this.onThemeModeChange(this.themeMode);
120
+ },
121
+ },
122
+ });
123
+ </script>
@@ -7,31 +7,106 @@
7
7
  <img :src="user.avatar_url" alt="User Photo" />
8
8
  </div>
9
9
  </button>
10
- <navbar-item-content>
11
- <div v-if="user.username" class="user-profile-wrapper">
10
+ <navbar-item-content class="navbar-dropdown-wrapper">
11
+ <div v-if="user.username" class="user-profile-wrapper" @mouseleave="onMouseLeave()">
12
12
  <div class="profile-area">
13
13
  <div class="profile-photo">
14
- <img :src="user.avatar_url" alt="User Photo" />
14
+ <img :src="user.avatar_url" alt="User Photo" class="width-50 height-50" />
15
15
  <button class="camera-icon"></button>
16
16
  </div>
17
- <div class="profile-info">
18
- <p>{{ user.username.toUpperCase() }}</p>
17
+ <div class="profile-info" style="width: calc(100% - 60px);">
18
+ <p :title="user.username.toUpperCase()" class="line-break-anywhere is-ellipsis-1">{{ user.username.toUpperCase() }}</p>
19
19
  <a :href="`mailto:${user.email}`"> {{ user.email }}</a>
20
20
  </div>
21
21
  </div>
22
- <ul>
23
- <li>
22
+ <transition-group name="list" tag="ul">
23
+ <li key="settings">
24
24
  <a :href="`${serverDomain}/user/settings/`">Settings</a>
25
25
  </li>
26
- <template v-if="user.is_admin">
27
- <li>
28
- <a :href="`${serverDomain}/admin`"> Site Administration </a>
29
- </li>
30
- </template>
31
- <li>
26
+ <li v-if="user.is_admin" key="site-admin">
27
+ <a :href="`${serverDomain}/admin`">Site Administration</a>
28
+ </li>
29
+ <li v-if="showAccountSwitcher" :class="`is-${dropDownStatus}`" key="switcher">
30
+ <a class="
31
+ ac-dropdown-button
32
+ is-fullwidth
33
+ is-flex
34
+ is-justify-content-space-between
35
+ is-align-items-center
36
+ "
37
+ @click="toggleList()"
38
+ >
39
+ <span>Switch Account</span>
40
+ <span
41
+ ><i
42
+ :class="`fa fa-angle-${
43
+ dropDownStatus === 'open' ? 'up' : 'down'
44
+ }`"
45
+ ></i
46
+ ></span>
47
+ </a>
48
+ <transition-group name="list" tag="ul"
49
+ class="ac-vscrollbar"
50
+ ref="dropdownItems"
51
+ :style="{ maxHeight: dropDownSectionHeight }"
52
+ >
53
+ <li
54
+ v-for="(org, idx) in formattedOrganizations"
55
+ :key="org.username"
56
+ >
57
+ <a
58
+ class="is-flex is-align-items-center"
59
+ @click="onOrganizationClick(org.username)"
60
+ >
61
+ <div class="width-30 height-30 image">
62
+ <img
63
+ :src="org.avatar_url"
64
+ class="ac-user-profile is-rounded"
65
+ alt="icon"
66
+ />
67
+ </div>
68
+ <div
69
+ class="
70
+ is-flex
71
+ is-align-items-center
72
+ is-justify-content-space-between
73
+ is-fullwidth
74
+ ml-10
75
+ "
76
+ >
77
+ <div class="org-info">
78
+ <strong :title="org.username" class="line-break-anywhere is-ellipsis-1">{{ org.username }}</strong>
79
+ <p>
80
+ {{
81
+ org.isPersonalAccount
82
+ ? "Personal Account"
83
+ : "Organization"
84
+ }}
85
+ </p>
86
+ </div>
87
+ <span
88
+ v-if="idx === 0"
89
+ class="
90
+ material-icons-outlined
91
+ font-size-18
92
+ ml-10
93
+ is-pulled-right
94
+ "
95
+ >
96
+ check
97
+ </span>
98
+ </div>
99
+ </a>
100
+ </li>
101
+ </transition-group>
102
+ </li>
103
+ <li key="dashboard">
104
+ <a :href="`${serverDomain}/dashboard`"> Dashboard </a>
105
+ </li>
106
+ <li key="signout">
32
107
  <a :href="`${serverDomain}/user/logout`"> Sign out </a>
33
108
  </li>
34
- </ul>
109
+ </transition-group>
35
110
  </div>
36
111
  </navbar-item-content>
37
112
  </navbar-item>
@@ -42,6 +117,7 @@ import { defineComponent, defineAsyncComponent } from "vue";
42
117
 
43
118
  export default defineComponent({
44
119
  props: {
120
+ // active user info
45
121
  user: {
46
122
  type: Object,
47
123
  default: () => ({}),
@@ -50,6 +126,15 @@ export default defineComponent({
50
126
  type: String,
51
127
  default: "",
52
128
  },
129
+ showAccountSwitcher: {
130
+ type: Boolean,
131
+ default: false,
132
+ },
133
+ // all available organization list including personal account
134
+ organizations: {
135
+ type: Array,
136
+ default: () => [],
137
+ },
53
138
  },
54
139
 
55
140
  components: {
@@ -60,5 +145,71 @@ export default defineComponent({
60
145
  import("../../v2/navbar/NavbarItemContent.vue").then((module) => module.default)
61
146
  ),
62
147
  },
148
+
149
+ computed: {
150
+ formattedOrganizations() {
151
+ let activeUser;
152
+ const filteredList = this.organizations.filter((item) => {
153
+ if (item.username === this.user.username) {
154
+ activeUser = item;
155
+ } else {
156
+ return true;
157
+ }
158
+ return false;
159
+ });
160
+
161
+ filteredList.unshift(activeUser);
162
+
163
+ return filteredList || [];
164
+ },
165
+ },
166
+
167
+ data() {
168
+ return {
169
+ dropDownStatus: "close",
170
+ dropDownSectionHeight: null,
171
+ };
172
+ },
173
+
174
+ methods: {
175
+ toggleList() {
176
+ this.dropDownStatus = this.dropDownStatus === "open" ? "close" : "open";
177
+ this.$nextTick(() => {
178
+ this.$refs["dropdownItems"].$el.scrollTo(0, 0);
179
+ });
180
+ },
181
+ onOrganizationClick(orgName) {
182
+ this.$refs["dropdownItems"].$el.scrollTo(0, 0);
183
+ this.$emit("activeorg$set", orgName);
184
+ },
185
+ onMouseLeave() {
186
+ this.dropDownStatus = "close";
187
+ }
188
+ },
189
+
190
+ watch: {
191
+ dropDownStatus: {
192
+ immediate: true,
193
+ handler(n) {
194
+ if (n === "open") {
195
+ this.$nextTick(() => {
196
+ const dropDownUl = this.$refs["dropdownItems"];
197
+ if (dropDownUl)
198
+ this.dropDownSectionHeight = `${dropDownUl.scrollHeight}px`;
199
+ });
200
+ } else {
201
+ this.dropDownSectionHeight = null;
202
+ }
203
+ },
204
+ },
205
+ },
63
206
  });
64
- </script>
207
+ </script>
208
+ <style lang="scss" scoped>
209
+ .ac-vscrollbar {
210
+ overflow: auto !important;
211
+ }
212
+ .line-break-anywhere {
213
+ line-break: anywhere;
214
+ }
215
+ </style>
@@ -0,0 +1,133 @@
1
+ <template>
2
+ <div v-if="sidebarCollapsed" class="is-cluster-logo">
3
+ <img
4
+ width="40"
5
+ :src="getProviderIcon(selectedCluster && selectedCluster.provider)"
6
+ onerror="this.onerror=null;this.src='https://cdn.appscode.com/images/cloud-provider-icons/Generic.png';"
7
+ alt="provider-icon"
8
+ />
9
+ </div>
10
+ <multiselect
11
+ v-else
12
+ v-model="selectedCluster"
13
+ placeholder="Selected Cluster"
14
+ label="name"
15
+ track-by="name"
16
+ :options="clusterOptions"
17
+ :allow-empty="false"
18
+ deselect-label=""
19
+ select-label=""
20
+ selected-label=""
21
+ >
22
+ <template #singleLabel="props">
23
+ <div class="is-flex is-align-items-center">
24
+ <img
25
+ :src="getProviderIcon(props.option.provider)"
26
+ onerror="this.onerror=null;this.src='https://cdn.appscode.com/images/cloud-provider-icons/Generic.png';"
27
+ alt="No cluster selected"
28
+ /><span
29
+ ><span>{{ props.option.displayName }}</span></span
30
+ >
31
+ </div>
32
+ </template>
33
+ <template #option="props">
34
+ <div class="is-flex is-align-items-center">
35
+ <img
36
+ class="mr-15"
37
+ :src="getProviderIcon(props.option.provider)"
38
+ onerror="this.onerror=null;this.src='https://cdn.appscode.com/images/cloud-provider-icons/Generic.png';"
39
+ alt="No cluster selected"
40
+ />
41
+ <div>
42
+ <p>{{ props.option.displayName }}</p>
43
+ <p class="location">{{ props.option.location }}</p>
44
+ </div>
45
+ </div>
46
+ </template>
47
+ </multiselect>
48
+ </template>
49
+
50
+ <script>
51
+ import { defineComponent, defineAsyncComponent } from 'vue'
52
+ export default defineComponent({
53
+ components: {
54
+ Multiselect: defineAsyncComponent(() =>
55
+ import('vue-multiselect').then((module) => module.default)
56
+ ),
57
+ },
58
+ props: {
59
+ sidebarCollapsed: {
60
+ type: Boolean,
61
+ default: false,
62
+ },
63
+ mouseHover: {
64
+ type: Boolean,
65
+ default: false,
66
+ },
67
+ clusterOptions: {
68
+ type: Array,
69
+ default: () => [],
70
+ },
71
+ modelValue: {
72
+ type: String,
73
+ default: '',
74
+ },
75
+ },
76
+
77
+ emits: ['update:modelValue'],
78
+
79
+ data() {
80
+ return {
81
+ selectedCluster: null,
82
+ selectedClusterName: null,
83
+ }
84
+ },
85
+
86
+ watch: {
87
+ modelValue: {
88
+ immediate: true,
89
+ handler(n) {
90
+ this.selectedClusterName = n
91
+ },
92
+ },
93
+ selectedCluster: {
94
+ deep: true,
95
+ handler(n) {
96
+ if (this.selectedClusterName !== n.name) {
97
+ this.selectedClusterName = n.name
98
+ }
99
+ },
100
+ },
101
+ selectedClusterName(n) {
102
+ if (n !== this.selectedCluster.name) {
103
+ this.clusterOptions.forEach((item) => {
104
+ if (this.selectedClusterName === item.name) {
105
+ this.selectedCluster = item
106
+ }
107
+ })
108
+ }
109
+
110
+ this.$emit('update:modelValue', n)
111
+ },
112
+ clusterOptions: {
113
+ deep: true,
114
+ immediate: true,
115
+ async handler(list) {
116
+ if (list) {
117
+ list.forEach((item) => {
118
+ if (this.selectedClusterName === item.name) {
119
+ this.selectedCluster = item
120
+ }
121
+ })
122
+ }
123
+ },
124
+ },
125
+ },
126
+
127
+ methods: {
128
+ getProviderIcon(provider) {
129
+ return `https://cdn.appscode.com/images/cloud-provider-icons/${provider}.png`
130
+ },
131
+ },
132
+ })
133
+ </script>