Skip to content

Commit

Permalink
Merge pull request #1614 from vincent99/master
Browse files Browse the repository at this point in the history
Fleet fixes (#1612)
  • Loading branch information
vincent99 authored Oct 4, 2020
2 parents 4fb39d4 + 053b7a1 commit 126c5eb
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 58 deletions.
12 changes: 6 additions & 6 deletions assets/translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ suffix:
assignTo:
title: |-
{count, plural,
=1 { Assign Cluster To... }
other { Assign {count} Clusters To... }
=1 { Assign Cluster To… }
other { Assign {count} Clusters To… }
}
labelsTitle: |-
{count, plural,
=1 { Assign Cluster To... }
other { Assign {count} Clusters To... }
=1 { Assign Cluster To… }
other { Assign {count} Clusters To… }
}
asyncButton:
Expand Down Expand Up @@ -450,8 +450,8 @@ fleet:
label: Deploy To
targetDisplay:
advanced: Advanced
cluster: "Cluster: {name}"
clusterGroup: "Group: {name}"
cluster: "Cluster"
clusterGroup: "Group"
all: All
local: Local
workspace:
Expand Down
2 changes: 1 addition & 1 deletion components/ActionMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default {
<ul class="list-unstyled menu" :style="style">
<li v-for="opt in options" :key="opt.action" :class="{divider: opt.divider}" @click="execute(opt, $event)">
<i v-if="opt.icon" :class="{icon: true, [opt.icon]: true}" />
{{ opt.label }}
<span v-html="opt.label" />
</li>
</ul>
</div>
Expand Down
35 changes: 20 additions & 15 deletions components/AssignTo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,28 @@ export default {
:scrollable="true"
>
<Card v-if="loaded">
<h4 slot="title" class="text-default-text">
{{ t('assignTo.title', {count: resourceCount}) }}
</h4>
<h4 slot="title" class="text-default-text" v-html="t('assignTo.title', {count: resourceCount}, true)" />
<div slot="body" class="pl-10 pr-10">
<LabeledSelect v-model="moveTo" label="Workspace" :options="workspaceOptions" />
<KeyValue
key="labels"
v-model="labels"
class="mt-20"
:add-label="t('labels.addSetLabel')"
:pad-left="false"
:read-allowed="false"
/>
<Banner v-for="(err, i) in errors" :key="i" color="error" :label="err" />
<form>
<LabeledSelect
v-model="moveTo"
label="Workspace"
:options="workspaceOptions"
placement="bottom"
/>
<KeyValue
key="labels"
v-model="labels"
class="mt-20"
:add-label="t('labels.addSetLabel')"
:pad-left="false"
:read-allowed="false"
/>
<Banner v-for="(err, i) in errors" :key="i" color="error" :label="err" />
</form>
</div>
<div slot="actions">
Expand Down
2 changes: 1 addition & 1 deletion components/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default {
background: var(--nav-bg);
display: grid;
& .card-body {
overflow: hidden;
overflow: auto;
padding: 20px;
}
& .card-actions {
Expand Down
2 changes: 2 additions & 0 deletions components/FleetClusters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ export default {
value: 'status.display.readyBundles',
sort: 'status.summary.ready',
search: false,
align: 'center',
},
{
name: 'reposReady',
labelKey: 'tableHeaders.reposReady',
value: 'status.display.readyBundles',
sort: 'status.summary.ready',
search: false,
align: 'center',
},
FLEET_SUMMARY,
{
Expand Down
2 changes: 1 addition & 1 deletion components/SortableTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export default {
@mouseleave="setBulkActionOfInterest(null)"
>
<i v-if="act.icon" :class="act.icon" />
{{ act.label }}
<span v-html="act.label" />
</button>
<span />
<label v-if="actionAvailability" class="action-availability">
Expand Down
2 changes: 1 addition & 1 deletion components/form/KeyValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ export default {
column-gap: $column-gutter;
&.extra-column {
grid-template-columns: 1fr 1fr min-content;
grid-template-columns: 1fr 1fr 100px;
}
& > .col {
Expand Down
5 changes: 4 additions & 1 deletion config/labels-annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export const CATALOG = {

const CATTLE_REGEX = /cattle\.io\//;

export const FLEET = { CLUSTER_NAME: 'management.cattle.io/cluster-name' };
export const FLEET = {
CLUSTER_DISPLAY_NAME: 'management.cattle.io/cluster-display-name',
CLUSTER_NAME: 'management.cattle.io/cluster-name'
};

export const RKE = { EXTERNAL_IP: 'rke.cattle.io/external-ip' };

Expand Down
1 change: 0 additions & 1 deletion detail/fleet.cattle.io.clustergroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default {
},
async fetch() {
await this.$store.dispatch('management/findAll', { type: FLEET.WORKSPACE });
await this.$store.dispatch('management/findAll', { type: FLEET.CLUSTER });
},
Expand Down
2 changes: 1 addition & 1 deletion detail/management.cattle.io.fleetworkspace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
</script>

<template>
<div>
<div class="mt-20">
<div class="row">
<div class="col span-4">
<CountBox :count="value.counts.gitRepos" :name="gitRepoLabel" :primary-color-var="'--sizzle-3'" />
Expand Down
6 changes: 3 additions & 3 deletions edit/fleet.cattle.io.clustergroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ export default {
},
clustersForWorkspace() {
const namespace = this.metadata?.namespace;
const namespace = this.value.metadata?.namespace;
if ( !namespace ) {
return [];
}
const workspace = this.$store.getters['management/byId'](FLEET.WORKSPACE, this.namespace);
const workspace = this.$store.getters['management/byId'](FLEET.WORKSPACE, namespace);
if ( workspace ) {
return workspace.clusters;
Expand Down Expand Up @@ -126,7 +126,7 @@ export default {
v-if="!isView"
v-model="value"
:mode="mode"
:namespaced="true"
:namespaced="false"
namespace-label="nameNsDescription.workspace.label"
:namespace-type="FLEET_WORKSPACE"
/>
Expand Down
20 changes: 7 additions & 13 deletions list/fleet.cattle.io.clustergroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
AGE,
STATE,
NAME,
WORKSPACE, FLEET_SUMMARY
FLEET_SUMMARY
} from '@/config/table-headers';
import { removeObject } from '@/utils/array';
export default {
name: 'ListClusterGroup',
Expand All @@ -31,23 +30,19 @@ export default {
const out = [
STATE,
NAME,
WORKSPACE,
{
name: 'clusters',
labelKey: 'tableHeaders.clustersReady',
value: 'status.display.readyClusters',
sort: 'status.display.readyClusters',
search: ['status.nonReadyClusterCount', 'status.clusterCount'],
align: 'center',
width: 100,
},
FLEET_SUMMARY,
AGE
];
if ( this.groupBy || !this.groupable ) {
removeObject(out, WORKSPACE);
}
return out;
},
},
Expand All @@ -62,16 +57,15 @@ export default {
:schema="schema"
:headers="headers"
:rows="rows"
:group-by="groupBy"
:paging="true"
paging-label="sortableTable.paging.resource"
:paging-params="pagingParams"
key-field="_key"
v-on="$listeners"
>
<template #cell:clusters="{row}">
<span v-if="row.status.nonReadyClusterCount" class="text-warning">{{ row.status.clusterCount - row.status.nonReadyClusterCount }}/{{ row.status.clusterCount }}</span>
<span v-else>{{ row.status.clusterCount }}</span>
<template v-if="row.status">
<span v-if="row.status.nonReadyClusterCount" class="text-warning">{{ row.status.clusterCount - row.status.nonReadyClusterCount }}/{{ row.status.clusterCount }}</span>
<span v-else>{{ row.status.clusterCount }}</span>
</template>
<span v-else class="text-muted">&mdash;</span>
</template>
</ResourceTable>
</template>
4 changes: 2 additions & 2 deletions models/fleet.cattle.io.cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default {

insertAt(out, 3, {
action: 'assignTo',
label: 'Assign to...',
label: 'Assign to&hellip;',
icon: 'icon icon-copy',
bulkable: true,
bulkAction: 'assignToBulk',
Expand Down Expand Up @@ -75,7 +75,7 @@ export default {
},

nameDisplay() {
return this.metadata?.labels?.[FLEET_LABELS.CLUSTER_NAME] || this.metadata?.name || this.id;
return this.metadata?.labels?.[FLEET_LABELS.CLUSTER_DISPLAY_NAME] || this.metadata?.name || this.id;
},

state() {
Expand Down
2 changes: 1 addition & 1 deletion models/fleet.cattle.io.clustergroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {

targetClusters() {
const workspace = this.$getters['byId'](FLEET.WORKSPACE, this.metadata.namespace);
const expressions = convert(this.spec?.matchLabels || {}, this.spec?.matchExpressions || []);
const expressions = convert(this.spec?.selector?.matchLabels || {}, this.spec?.selector?.matchExpressions || []);

if ( !expressions.length ) {
return workspace.clusters;
Expand Down
27 changes: 16 additions & 11 deletions models/fleet.cattle.io.gitrepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { convert, matching, convertSelectorObj } from '@/utils/selector';
import jsyaml from 'js-yaml';
import { escapeHtml } from '@/utils/string';
import { FLEET } from '@/config/types';
import { FLEET as FLEET_ANNOTATIONS } from '@/config/labels-annotations';
import { addObjects, findBy, insertAt } from '@/utils/array';
import { set } from '@/utils/object';

Expand Down Expand Up @@ -245,16 +246,20 @@ export default {
}

if ( target.clusterSelector ) {
const expressions = convert(target.clusterSelector.matchLabels, target.clusterSelector.matchExpressions);

if ( expressions.length === 1 &&
expressions[0].key === 'name' &&
expressions[0].operation === 'In' &&
expressions[0].values.length === 1
) {
cluster = expressions[0].values[0];
if ( !mode ) {
mode = 'cluster';
if ( Object.keys(target.clusterSelector).length === 0 ) {
mode = 'all';
} else {
const expressions = convert(target.clusterSelector.matchLabels, target.clusterSelector.matchExpressions);

if ( expressions.length === 1 &&
expressions[0].key === FLEET_ANNOTATIONS.CLUSTER_NAME &&
expressions[0].operator === 'In' &&
expressions[0].values.length === 1
) {
cluster = expressions[0].values[0];
if ( !mode ) {
mode = 'cluster';
}
}
}
}
Expand All @@ -266,7 +271,7 @@ export default {

return {
mode,
modeDisplay: this.t(`fleet.gitRepo.targetDisplay."${ mode }"`, { name: cluster || clusterGroup || '?' }),
modeDisplay: this.t(`fleet.gitRepo.targetDisplay."${ mode }"`),
cluster,
clusterGroup,
advanced
Expand Down

0 comments on commit 126c5eb

Please sign in to comment.