Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ui): prevent system labels to be shown in set labels dialog #7539

Merged
merged 2 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ui/src/components/flows/FlowRun.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</script>

<script>
import {mapState} from "vuex";
import {mapState, mapGetters} from "vuex";
import {executeTask} from "../../utils/submitTask"
import InputsForm from "../../components/inputs/InputsForm.vue";
import LabelInput from "../../components/labels/LabelInput.vue";
Expand Down Expand Up @@ -108,6 +108,7 @@
computed: {
...mapState("execution", ["flow", "execution"]),
...mapState("core", ["guidedProperties"]),
...mapGetters("misc", ["configs"]),
haveBadLabels() {
return this.executionLabels.some(label => (label.key && !label.value) || (!label.key && label.value));
},
Expand All @@ -132,7 +133,8 @@
},
fillInputsFromExecution(){
// Add all labels except the one from flow to prevent duplicates
this.executionLabels = this.getExecutionLabels().filter(item => !item.key.startsWith("system."));
const toIgnore = this.configs.hiddenLabelsPrefixes || [];
this.executionLabels = this.getExecutionLabels().filter(item => !toIgnore.some(prefix => item.key.startsWith(prefix)));

if (!this.flow.inputs) {
return;
Expand Down
21 changes: 18 additions & 3 deletions ui/src/components/labels/LabelInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div class="flex-shrink-1">
<el-button-group class="d-flex">
<el-button :icon="Plus" @click="addItem" />
<el-button :icon="Minus" @click="removeItem(index)" :disabled="index === 0 && locals.length === 1" />
<el-button :icon="Minus" @click="removeItem(index)" />
</el-button-group>
</div>
</div>
Expand All @@ -31,6 +31,8 @@


<script>
import {mapGetters} from "vuex";

export default {
props: {
labels: {
Expand All @@ -49,13 +51,21 @@
}
},
emits: ["update:labels"],
computed: {
...mapGetters("misc", ["configs"]),
},
created() {
const toIgnore = this.configs.hiddenLabelsPrefixes || [];

if (this.labels.length === 0) {
this.addItem();
} else {
this.locals = this.labels
this.locals = this.labels.filter(item => !item || !toIgnore.some(prefix => item.key?.startsWith(prefix)))
if(this.locals.length === 0) {
this.addItem();
}
}
this.localExisting = this.existingLabels.map(label => label.key);
this.localExisting = this.existingLabels.filter(item => !item || !toIgnore.some(prefix => item.key?.startsWith(prefix))).map(label => label.key);
},
methods: {
addItem() {
Expand All @@ -64,6 +74,11 @@
},
removeItem(index) {
this.locals.splice(index, 1);

if (this.locals.length === 0) {
this.addItem();
}

this.$emit("update:labels", this.locals);
},
update(index, value, prop) {
Expand Down