Skip to content

Commit

Permalink
fix(*): allow deletion of label by setting empty key or empty value (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Skraye authored Oct 14, 2024
1 parent a47e293 commit a95d317
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ui/src/components/executions/SetLabels.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@
methods: {
setLabels() {
const filtered = filterLabels(this.executionLabels)
console.log("executionLabels", this.executionLabels)
console.log("filtered", filtered)
if(filtered.error) {
this.$toast().error(this.$t("wrong labels"))
return;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/executions/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ interface FilterResult {
}

export const filterLabels = (labels: Label[]): FilterResult => {
const invalid = labels.some(label => label.key === null || label.value === null);
const invalid = labels.some(label => label.key === null || label.value === null || label.key === "" || label.value === "");
return invalid ? {labels, error: true} : {labels};
};
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ private Execution setLabels(Execution execution, List<Label> labels) {

Execution newExecution = execution
.toBuilder()
.labels(newLabels.entrySet().stream().map(entry -> new Label(entry.getKey(), entry.getValue())).toList())
.labels(newLabels.entrySet().stream().map(entry -> new Label(entry.getKey(), entry.getValue())).filter(label -> !label.key().isEmpty() || !label.value().isEmpty()).toList())
.build();
eventPublisher.publishEvent(new CrudEvent<>(newExecution, execution, CrudEventType.UPDATE));

Expand Down

0 comments on commit a95d317

Please sign in to comment.