@appscode/design-system 1.0.43-alpha.77 → 1.0.43-alpha.80

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.
@@ -376,7 +376,10 @@
376
376
 
377
377
  .multiselect {
378
378
  height: 50px;
379
- width: 234px;
379
+
380
+ // commented out to set full width select box when right content is not present
381
+ // width: 234px;
382
+
380
383
  left: 0px;
381
384
  top: -5px;
382
385
 
@@ -27,6 +27,13 @@
27
27
  }
28
28
 
29
29
  .vue-openapi-form {
30
+ margin-left: -20px;
31
+ .is-warning {
32
+ font-size: 12px;
33
+ color: #ea3d2f;
34
+ padding-left: 10px;
35
+ }
36
+
30
37
  .ac-nested-elements {
31
38
  &:first-child {
32
39
  margin-left: 0;
@@ -67,13 +74,6 @@
67
74
  }
68
75
  }
69
76
 
70
- .vue-openapi-form .is-warning {
71
- font-size: 12px;
72
- color: #ea3d2f;
73
- font-family: Roboto, sans-serif;
74
- padding-left: 10px;
75
- }
76
-
77
77
  .v-tooltip-open {
78
78
  background-color: $ac-white;
79
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appscode/design-system",
3
- "version": "1.0.43-alpha.77",
3
+ "version": "1.0.43-alpha.80",
4
4
  "description": "A design system for Appscode websites and dashboards made using Bulma",
5
5
  "main": "main.scss",
6
6
  "scripts": {
@@ -3,7 +3,8 @@
3
3
  <img
4
4
  width="40"
5
5
  :src="getProviderIcon(selectedCluster && selectedCluster.provider)"
6
- alt=""
6
+ onerror="this.onerror=null;this.src='https://cdn.appscode.com/images/cloud-provider-icons/Generic.png';"
7
+ alt="provider-icon"
7
8
  />
8
9
  </div>
9
10
  <multiselect
@@ -11,8 +12,8 @@
11
12
  v-model="selectedCluster"
12
13
  placeholder="Selected Cluster"
13
14
  label="name"
14
- track-by="uid"
15
- :options="options"
15
+ track-by="name"
16
+ :options="clusterOptions"
16
17
  :allow-empty="false"
17
18
  deselectLabel=""
18
19
  selectLabel=""
@@ -22,6 +23,7 @@
22
23
  <div class="is-flex is-align-items-center">
23
24
  <img
24
25
  :src="getProviderIcon(props.option.provider)"
26
+ onerror="this.onerror=null;this.src='https://cdn.appscode.com/images/cloud-provider-icons/Generic.png';"
25
27
  alt="No cluster selected"
26
28
  /><span
27
29
  ><span>{{ props.option.displayName }}</span></span
@@ -33,6 +35,7 @@
33
35
  <img
34
36
  class="mr-15"
35
37
  :src="getProviderIcon(props.option.provider)"
38
+ onerror="this.onerror=null;this.src='https://cdn.appscode.com/images/cloud-provider-icons/Generic.png';"
36
39
  alt="No cluster selected"
37
40
  />
38
41
  <div>
@@ -45,7 +48,6 @@
45
48
  </template>
46
49
 
47
50
  <script>
48
- import { mapGetters } from "vuex";
49
51
  export default {
50
52
  props: {
51
53
  sidebarCollapsed: {
@@ -56,18 +58,14 @@ export default {
56
58
  type: Boolean,
57
59
  default: false,
58
60
  },
59
- username: {
60
- type: String,
61
- default: "",
62
- },
63
- imagePath: {
64
- type: Object,
65
- default: () => ({}),
61
+ clusterOptions: {
62
+ type: Array,
63
+ default: [],
66
64
  },
67
65
  value: {
68
- type: Object,
69
- default: () => ({}),
70
- },
66
+ type: String,
67
+ default: "",
68
+ }
71
69
  },
72
70
 
73
71
  components: {
@@ -77,93 +75,48 @@ export default {
77
75
  data() {
78
76
  return {
79
77
  selectedCluster: null,
80
- clusters: [],
81
- options: [],
78
+ selectedClusterName: "",
82
79
  };
83
80
  },
84
81
 
85
- computed: {
86
- selectClusterOptions() {
87
- return this.clusters
88
- .filter(
89
- (cluster) =>
90
- cluster.status.phase === "Connected" ||
91
- cluster.status.phase === "PrivateConnected"
92
- )
93
- .map((cluster) => {
94
- return {
95
- name: cluster.spec.name,
96
- displayName: cluster.spec.displayName,
97
- provider: cluster.spec.provider,
98
- uid: cluster.spec.uid,
99
- location: cluster.spec.location,
100
- };
101
- });
102
- },
103
- },
104
-
105
82
  methods: {
106
- async checkStatus(clusterName) {
107
- try {
108
- await this.$axios.get(
109
- `/clusters/${this.username}/${clusterName}/status`
110
- );
111
- return true;
112
- } catch (err) {
113
- return false;
114
- }
115
- },
116
- async getClusters() {
117
- if (this.username) {
118
- const url = `/clusters/${this.username}`;
119
-
120
- try {
121
- const resp = await this.$axios.get(url);
122
- this.clusters = (resp.data && resp.data.items) || [];
123
-
124
- // preselect the cluster
125
- const selectedCluster = this.clusters.find(
126
- (cluster) => cluster.spec.name === this.$route.params.cluster
127
- );
128
- this.selectedCluster = {
129
- name: selectedCluster.spec.name,
130
- displayName: selectedCluster.spec.displayName,
131
- provider: selectedCluster.spec.provider,
132
- uid: selectedCluster.spec.uid,
133
- location: selectedCluster.spec.location,
134
- };
135
- } catch (e) {
136
- console.log(e);
137
- }
138
- }
139
- },
140
-
141
83
  getProviderIcon(provider) {
142
- return this.imagePath[provider] || this.imagePath["default"];
84
+ return `https://cdn.appscode.com/images/cloud-provider-icons/${provider}.png`;
143
85
  },
144
86
  },
145
87
 
146
- created() {
147
- this.getClusters();
148
- },
149
-
150
88
  watch: {
151
89
  value: {
152
- deep: true,
153
90
  immediate: true,
154
91
  handler(n) {
155
- this.selectedCluster = n;
92
+ this.selectedClusterName = n;
156
93
  },
157
94
  },
158
- selectClusterOptions: {
95
+ selectedCluster: {
96
+ deep: true,
97
+ handler(n) {
98
+ this.selectedClusterName = n.name;
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
+ this.$emit("input", n);
110
+ },
111
+ clusterOptions: {
159
112
  deep: true,
160
113
  immediate: true,
161
114
  async handler(list) {
162
- this.options = [];
163
115
  if (list) {
164
116
  list.forEach(async (item) => {
165
- const resp = await this.checkStatus(item.name);
166
- if (resp) this.options.push(item);
117
+ if(item.name === this.selectedClusterName) {
118
+ this.selectedCluster = item;
119
+ }
167
120
  });
168
121
  }
169
122
  },
@@ -1,9 +1,10 @@
1
1
  <template>
2
- <div class="is-cluster-logo" v-if="sidebarCollapsed">
2
+ <div v-if="sidebarCollapsed" class="is-cluster-logo">
3
3
  <img
4
4
  width="40"
5
5
  :src="getProviderIcon(selectedCluster && selectedCluster.provider)"
6
- alt=""
6
+ onerror="this.onerror=null;this.src='https://cdn.appscode.com/images/cloud-provider-icons/Generic.png';"
7
+ alt="provider-icon"
7
8
  />
8
9
  </div>
9
10
  <multiselect
@@ -11,28 +12,30 @@
11
12
  v-model="selectedCluster"
12
13
  placeholder="Selected Cluster"
13
14
  label="name"
14
- track-by="uid"
15
- :options="options"
15
+ track-by="name"
16
+ :options="clusterOptions"
16
17
  :allow-empty="false"
17
- deselectLabel=""
18
- selectLabel=""
19
- selectedLabel=""
18
+ deselect-label=""
19
+ select-label=""
20
+ selected-label=""
20
21
  >
21
- <template slot="singleLabel" slot-scope="props">
22
+ <template #singleLabel="props">
22
23
  <div class="is-flex is-align-items-center">
23
24
  <img
24
25
  :src="getProviderIcon(props.option.provider)"
26
+ onerror="this.onerror=null;this.src='https://cdn.appscode.com/images/cloud-provider-icons/Generic.png';"
25
27
  alt="No cluster selected"
26
28
  /><span
27
29
  ><span>{{ props.option.displayName }}</span></span
28
30
  >
29
31
  </div>
30
32
  </template>
31
- <template slot="option" slot-scope="props">
33
+ <template #option="props">
32
34
  <div class="is-flex is-align-items-center">
33
35
  <img
34
36
  class="mr-15"
35
37
  :src="getProviderIcon(props.option.provider)"
38
+ onerror="this.onerror=null;this.src='https://cdn.appscode.com/images/cloud-provider-icons/Generic.png';"
36
39
  alt="No cluster selected"
37
40
  />
38
41
  <div>
@@ -45,129 +48,86 @@
45
48
  </template>
46
49
 
47
50
  <script>
48
- import { defineComponent, defineAsyncComponent } from "vue";
49
- export default defineComponent({
50
- props: {
51
- sidebarCollapsed: {
52
- type: Boolean,
53
- default: false,
51
+ import { defineComponent, defineAsyncComponent } from 'vue'
52
+ export default defineComponent({
53
+ components: {
54
+ Multiselect: defineAsyncComponent(() =>
55
+ import('vue-multiselect').then((module) => module.default)
56
+ ),
54
57
  },
55
- mouseHover: {
56
- type: Boolean,
57
- default: false,
58
- },
59
- username: {
60
- type: String,
61
- default: "",
62
- },
63
- imagePath: {
64
- type: Object,
65
- default: () => ({}),
66
- },
67
- value: {
68
- type: Object,
69
- default: () => ({}),
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
+ },
70
75
  },
71
- },
72
-
73
- components: {
74
- Multiselect: () => import("vue-multiselect"),
75
- },
76
76
 
77
- data() {
78
- return {
79
- selectedCluster: null,
80
- clusters: [],
81
- options: [],
82
- };
83
- },
77
+ emits: ['update:modelValue'],
84
78
 
85
- computed: {
86
- selectClusterOptions() {
87
- return this.clusters
88
- .filter(
89
- (cluster) =>
90
- cluster.status.phase === "Connected" ||
91
- cluster.status.phase === "PrivateConnected"
92
- )
93
- .map((cluster) => {
94
- return {
95
- name: cluster.spec.name,
96
- displayName: cluster.spec.displayName,
97
- provider: cluster.spec.provider,
98
- uid: cluster.spec.uid,
99
- location: cluster.spec.location,
100
- };
101
- });
102
- },
103
- },
104
-
105
- methods: {
106
- async checkStatus(clusterName) {
107
- try {
108
- await this.$axios.get(
109
- `/clusters/${this.username}/${clusterName}/status`
110
- );
111
- return true;
112
- } catch (err) {
113
- return false;
79
+ data() {
80
+ return {
81
+ selectedCluster: null,
82
+ selectedClusterName: null,
114
83
  }
115
84
  },
116
- async getClusters() {
117
- if (this.username) {
118
- const url = `/clusters/${this.username}`;
119
-
120
- try {
121
- const resp = await this.$axios.get(url);
122
- this.clusters = (resp.data && resp.data.items) || [];
123
85
 
124
- // preselect the cluster
125
- const selectedCluster = this.clusters.find(
126
- (cluster) => cluster.spec.name === this.$route.params.cluster
127
- );
128
- this.selectedCluster = {
129
- name: selectedCluster.spec.name,
130
- displayName: selectedCluster.spec.displayName,
131
- provider: selectedCluster.spec.provider,
132
- uid: selectedCluster.spec.uid,
133
- location: selectedCluster.spec.location,
134
- };
135
- } catch (e) {
136
- console.log(e);
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
+ })
137
108
  }
138
- }
139
- },
140
-
141
- getProviderIcon(provider) {
142
- return this.imagePath[provider] || this.imagePath["default"];
143
- },
144
- },
145
-
146
- created() {
147
- this.getClusters();
148
- },
149
109
 
150
- watch: {
151
- value: {
152
- deep: true,
153
- immediate: true,
154
- handler(n) {
155
- this.selectedCluster = n;
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
+ },
156
124
  },
157
125
  },
158
- selectClusterOptions: {
159
- deep: true,
160
- immediate: true,
161
- async handler(list) {
162
- this.options = [];
163
- if (list) {
164
- list.forEach(async (item) => {
165
- const resp = await this.checkStatus(item.name);
166
- if (resp) this.options.push(item);
167
- });
168
- }
126
+
127
+ methods: {
128
+ getProviderIcon(provider) {
129
+ return `https://cdn.appscode.com/images/cloud-provider-icons/${provider}.png`
169
130
  },
170
131
  },
171
- },
172
- });
173
- </script>
132
+ })
133
+ </script>