Switching flow pages to local/globalOutputRefs

- I also noticed that initialSelection was no longer working so I
fixed that as well.

rancher/dashboard#1127
rancher/dashboard#1126
This commit is contained in:
Cody Jackson 2020-09-21 16:42:28 -07:00
parent d6d43bfdce
commit 2babda32aa
6 changed files with 54 additions and 18 deletions

View File

@ -353,6 +353,15 @@ export default {
}
},
select(nodes) {
nodes.forEach((node) => {
const id = get(node, this.keyField);
const input = $(`label[data-node-id="${ id }"]`);
input.trigger('click');
});
},
applyTableAction(action, args, event) {
const opts = { alt: isAlternate(event) };

View File

@ -74,8 +74,9 @@ export const getters = {
// Enable a bulkaction if some of the selected items can perform the action
out.forEach((bulkAction) => {
const actionEnabledForSomeSelected = state.tableSelected.some((node) => {
return node.availableActions
.some(action => action.action === bulkAction.action && action.enabled);
const availableActions = node.availableActions || [];
return availableActions.some(action => action.action === bulkAction.action && action.enabled);
});
bulkAction.enabled = state.tableSelected.length > 0 && actionEnabledForSomeSelected;

View File

@ -7,7 +7,8 @@ export default {
extends: Flow,
async fetch() {
this.outputs = await this.$store.dispatch('cluster/findAll', { type: LOGGING.CLUSTER_OUTPUTS }) || [];
this.allOutputs = await this.$store.dispatch('cluster/findAll', { type: LOGGING.CLUSTER_OUTPUTS }) || [];
this.initialSelection = [...this.value.outputs];
},
data() {
@ -15,6 +16,7 @@ export default {
this.value.metadata.namespace = 'cattle-logging-system';
return {
outputRefsKey: 'globalOutputRefs',
noOutputsBanner: this.t('logging.clusterFlow.noOutputsBanner'),
tableHeaders: [
{ ...NAME, labelKey: 'tableHeaders.clusterOutput' },

View File

@ -31,8 +31,6 @@ export default {
},
data() {
this.value.metadata.namespace = 'default';
return {
allOutputs: [],
noOutputsBanner: this.t('logging.flow.noOutputsBanner'),
@ -60,23 +58,30 @@ export default {
watch: {
'$fetchState.pending': {
handler() {
if (!this.$fetchState.pending) {
this.$nextTick(() => {
this.selectInitial();
});
}
this.selectInitial();
}
},
mode() {
this.selectInitial();
}
},
mounted() {
this.selectInitial();
},
methods: {
onSelection(selected) {
if (!this.isView) {
this.value.spec = this.value.spec || {};
this.value.spec.outputRefs = selected.map(s => s.name);
const outputRefs = selected.map(s => s.name);
this.value.setOutputRefs(outputRefs);
}
},
selectInitial() {
this.$refs.table.update(this.initialSelection, []);
if (!this.$fetchState.pending) {
this.$nextTick(() => {
this.$refs.table.select(this.initialSelection, []);
});
}
}
}
};
@ -98,7 +103,6 @@ export default {
@cancel="done"
>
<NameNsDescription v-if="!isView" v-model="value" :mode="mode" :namespaced="isNamespaced" />
<Tabbed :side-tabs="true">
<Tab name="outputs" :label="t('logging.flow.outputs')">
<Banner v-if="!isView" :color="bannerColor">

View File

@ -7,11 +7,21 @@ export default {
},
outputs() {
const outputRefs = this?.spec?.outputRefs || [];
const outputRefs = this?.spec?.globalOutputRefs || this?.spec?.outputRefs || [];
return this.allOutputs.filter(output => outputRefs.includes(output.name));
},
setOutputRefs() {
return (outputRefs) => {
this.spec = this.spec || {};
this.spec.globalOutputRefs = outputRefs;
// outputRefs is deprecated so we're clearing it.
this.spec.outputRefs = undefined;
};
},
outputProviders() {
const duplicatedProviders = this.outputs
.flatMap(output => output.providers);
@ -23,7 +33,7 @@ export default {
return [
{
nullable: false,
path: 'spec.outputRefs',
path: 'spec.globalOutputRefs',
required: true,
translationKey: 'logging.flow.outputs',
type: 'array'

View File

@ -7,11 +7,21 @@ export default {
},
outputs() {
const outputRefs = this?.spec?.outputRefs || [];
const outputRefs = this?.spec?.outputRefs || this?.spec?.localOutputRefs || [];
return this.allOutputs.filter(output => outputRefs.includes(output.name));
},
setOutputRefs() {
return (outputRefs) => {
this.spec = this.spec || {};
this.spec.localOutputRefs = outputRefs;
// outputRefs is deprecated so we're clearing it.
this.spec.outputRefs = undefined;
};
},
outputProviders() {
const duplicatedProviders = this.outputs
.flatMap(output => output.providers);
@ -23,7 +33,7 @@ export default {
return [
{
nullable: false,
path: 'spec.outputRefs',
path: 'spec.localOutputRefs',
required: true,
translationKey: 'logging.flow.outputs',
type: 'array'