@appscode/design-system 1.0.43-alpha.14 → 1.0.43-alpha.140

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 (112) 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 +74 -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 +29 -1
  69. package/vue-components/v2/editor/FilteredFileEditor.vue +159 -0
  70. package/vue-components/v2/editor/ResourceKeyValueEditor.vue +196 -0
  71. package/vue-components/v2/loaders/ResourceLoader.vue +90 -0
  72. package/vue-components/v2/loaders/SidebarLoader.vue +32 -0
  73. package/vue-components/v2/modal/Modal.vue +33 -12
  74. package/vue-components/v2/modals/DeleteConfirmationModal.vue +77 -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 +120 -0
  78. package/vue-components/v2/navbar/User.vue +166 -15
  79. package/vue-components/v2/preloader/Preloader.vue +5 -5
  80. package/vue-components/v2/sidebar/ClusterSwitcher.vue +126 -0
  81. package/vue-components/v2/sidebar/SidebarItem.vue +23 -1
  82. package/vue-components/v2/sidebar/SidebarItemWithDropDown.vue +19 -20
  83. package/vue-components/v2/table/Table.vue +44 -8
  84. package/vue-components/v2/table/TableRow.vue +17 -8
  85. package/vue-components/v2/table/table-cell/CellValue.vue +31 -4
  86. package/vue-components/v2/table/table-cell/GenericCell.vue +56 -0
  87. package/vue-components/v2/table/table-cell/ObjectCell.vue +4 -1
  88. package/vue-components/v2/tabs/EditorTabs.vue +1 -1
  89. package/vue-components/v3/button/Button.vue +5 -0
  90. package/vue-components/v3/content/ContentTable.vue +5 -0
  91. package/vue-components/v3/dropdown/DropdownMenu.vue +1 -1
  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 +124 -0
  95. package/vue-components/v3/editor/ResourceKeyValueEditor.vue +124 -0
  96. package/vue-components/v3/header/HeaderItem.vue +5 -0
  97. package/vue-components/v3/header/HeaderItems.vue +5 -0
  98. package/vue-components/v3/loaders/ResourceLoader.vue +83 -0
  99. package/vue-components/v3/loaders/SidebarLoader.vue +34 -0
  100. package/vue-components/v3/modal/Modal.vue +10 -1
  101. package/vue-components/v3/modals/JsonShowModal.vue +13 -4
  102. package/vue-components/v3/navbar/Appdrawer.vue +12 -7
  103. package/vue-components/v3/navbar/ThemeMode.vue +128 -0
  104. package/vue-components/v3/navbar/User.vue +166 -15
  105. package/vue-components/v3/sidebar/ClusterSwitcher.vue +133 -0
  106. package/vue-components/v3/sidebar/SidebarItemWithDropDown.vue +120 -0
  107. package/vue-components/v3/table/Table.vue +28 -5
  108. package/vue-components/v3/table/TableRow.vue +1 -1
  109. package/vue-components/v3/table/table-cell/CellValue.vue +26 -3
  110. package/vue-components/v3/table/table-cell/GenericCell.vue +62 -0
  111. package/vue-components/v3/table/table-cell/ObjectCell.vue +5 -1
  112. package/vue-components/v3/tabs/EditorTabs.vue +1 -1
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <div>
3
+ <content-loader :width="200" :height="350" :speed="2">
4
+ <rect x="0" y="24" rx="3" ry="3" width="200" height="20" />
5
+ <rect x="20" y="49" rx="3" ry="3" width="200" height="20" />
6
+ <rect x="20" y="74" rx="3" ry="3" width="200" height="20" />
7
+ <rect x="20" y="124" rx="3" ry="3" width="200" height="20" />
8
+
9
+ <rect x="0" y="149" rx="3" ry="3" width="200" height="20" />
10
+ <rect x="20" y="174" rx="3" ry="3" width="200" height="20" />
11
+ <rect x="20" y="199" rx="3" ry="3" width="200" height="20" />
12
+ <rect x="20" y="249" rx="3" ry="3" width="200" height="20" />
13
+
14
+ <rect x="0" y="274" rx="3" ry="3" width="200" height="20" />
15
+ <rect x="20" y="299" rx="3" ry="3" width="200" height="20" />
16
+ <rect x="20" y="324" rx="3" ry="3" width="200" height="20" />
17
+ <rect x="20" y="349" rx="3" ry="3" width="200" height="20" />
18
+
19
+ <rect x="0" y="374" rx="3" ry="3" width="200" height="20" />
20
+ </content-loader>
21
+ </div>
22
+ </template>
23
+
24
+ <script>
25
+ import { defineAsyncComponent, defineComponent } from 'vue'
26
+ export default defineComponent({
27
+ name: 'LoaderElement',
28
+ components: {
29
+ ContentLoader: defineAsyncComponent(() =>
30
+ import('vue-content-loader').then((module) => module.ContentLoader)
31
+ ),
32
+ },
33
+ })
34
+ </script>
@@ -17,6 +17,7 @@
17
17
  <header-item>
18
18
  <ac-button
19
19
  modifier-classes="is-square is-transparent"
20
+ :disabled="isCloseOptionDisabled"
20
21
  :icon-image="crossIcon"
21
22
  @click.stop="destroyModal"
22
23
  />
@@ -36,7 +37,10 @@
36
37
  <!-- modal body end -->
37
38
 
38
39
  <!-- modal footer start -->
39
- <div class="ac-modal-footer action-footer">
40
+ <div class="ac-modal-footer action-footer is-flex is-align-items-center is-justify-content-space-between">
41
+ <div>
42
+ <slot name="modal-footer-left" />
43
+ </div>
40
44
  <buttons class="has-text-right is-block">
41
45
  <slot name="modal-footer-controls" />
42
46
  </buttons>
@@ -64,6 +68,10 @@ export default defineComponent({
64
68
  type: String,
65
69
  default: "",
66
70
  },
71
+ isCloseOptionDisabled: {
72
+ type: Boolean,
73
+ default: false,
74
+ }
67
75
  },
68
76
  emits: ["closemodal"],
69
77
 
@@ -116,6 +124,7 @@ export default defineComponent({
116
124
  document.addEventListener("keydown", this.onKeyDown);
117
125
  },
118
126
  destroyModal() {
127
+ if (this.isCloseOptionDisabled) return;
119
128
  this.showModal = false;
120
129
  document.removeEventListener("keydown", this.onKeyDown);
121
130
 
@@ -10,7 +10,9 @@
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
  />
@@ -28,6 +30,8 @@
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: {
@@ -49,9 +53,14 @@ export default defineComponent({
49
53
  Modal: defineAsyncComponent(() =>
50
54
  import("../modal/Modal.vue").then((module) => module.default)
51
55
  ),
52
- Editor: defineAsyncComponent(() =>
53
- import("../editor/Editor.vue").then((module) => module.default)
54
- ),
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: 20000,
63
+ }),
55
64
  AcButton: defineAsyncComponent(() =>
56
65
  import("../button/Button.vue").then((module) => module.default)
57
66
  ),
@@ -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,128 @@
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
+ destroyed() {
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")
73
+ this.themeMode = "dark";
74
+ else if(this.themeMode === "dark")
75
+ this.themeMode = "system";
76
+ else if(this.themeMode === "system")
77
+ this.themeMode = "light";
78
+ },
79
+
80
+ // triggered when theme mode is updated
81
+ onThemeModeChange(n) {
82
+ localStorage.setItem("themeMode", n);
83
+
84
+ let theme = n;
85
+ if(n === "system") {
86
+ const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
87
+ this.addColorSchemeEventListener();
88
+ theme = isDarkMode ? "dark" : "light";
89
+ } else {
90
+ this.removeColorSchemeEventListener();
91
+ }
92
+ this.$emit("set:theme", theme);
93
+ this.handleDarkThemeClass(theme);
94
+ },
95
+
96
+ // add proper css class to update the ui theme
97
+ handleDarkThemeClass(currentTheme) {
98
+ if(currentTheme === "light") {
99
+ document.documentElement.classList.remove("is-dark-theme");
100
+ } else {
101
+ document.documentElement.classList.add("is-dark-theme");
102
+ }
103
+ },
104
+
105
+ // add system theme listener event
106
+ addColorSchemeEventListener() {
107
+ window
108
+ .matchMedia("(prefers-color-scheme: dark)")
109
+ .addEventListener(
110
+ "change", this.handleSystemThemeChange
111
+ );
112
+ },
113
+
114
+ // remove system theme listener event
115
+ removeColorSchemeEventListener() {
116
+ window
117
+ .matchMedia("(prefers-color-scheme: dark)")
118
+ .removeEventListener(
119
+ "change", this.handleSystemThemeChange
120
+ );
121
+ },
122
+
123
+ handleSystemThemeChange() {
124
+ this.onThemeModeChange(this.themeMode);
125
+ },
126
+ }
127
+ });
128
+ </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>