From fae117cf213b3a7d24be6819bbcbd4dd99bccdd2 Mon Sep 17 00:00:00 2001
From: nknguyenhc <87511888+nknguyenhc@users.noreply.github.com>
Date: Sun, 11 Feb 2024 17:08:22 +0800
Subject: [PATCH 1/2] Refactor label model
Usage of `label.name` is removed from:
* Label filter bar component, search
---
src/app/core/models/label.model.ts | 12 ++----------
.../label-filter-bar/label-filter-bar.component.html | 2 +-
.../issue-pr-card-labels.component.ts | 6 +++---
3 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/src/app/core/models/label.model.ts b/src/app/core/models/label.model.ts
index 18799a193..1e44fab6d 100644
--- a/src/app/core/models/label.model.ts
+++ b/src/app/core/models/label.model.ts
@@ -2,23 +2,15 @@
* Represents a label and its attributes.
*/
export class Label implements SimpleLabel {
- readonly category: string;
- readonly name: string;
- readonly formattedName: string; // 'category'.'name' (e.g. severity.Low) if a category exists or 'name' if the category does not exist.
+ readonly formattedName: string;
color: string;
definition?: string;
constructor(label: { name: string; color: string; definition?: string }) {
- const containsDotRegex = /\.\b/g; // contains dot in middle of name
- [this.category, this.name] = containsDotRegex.test(label.name) ? label.name.split('.') : [undefined, label.name];
- this.formattedName = this.category === undefined || this.category === '' ? this.name : this.category.concat('.', this.name);
+ this.formattedName = label.name;
this.color = label.color;
this.definition = label.definition;
}
-
- public equals(label: Label) {
- return this.name === label.name && this.category === label.category;
- }
}
/**
diff --git a/src/app/shared/filter-bar/label-filter-bar/label-filter-bar.component.html b/src/app/shared/filter-bar/label-filter-bar/label-filter-bar.component.html
index 7f2438f42..1f4c7ce6c 100644
--- a/src/app/shared/filter-bar/label-filter-bar/label-filter-bar.component.html
+++ b/src/app/shared/filter-bar/label-filter-bar/label-filter-bar.component.html
@@ -26,7 +26,7 @@
[value]="label.formattedName"
[selected]="selectedLabelNames.includes(label.formattedName)"
class="list-option"
- [class.hidden]="filter(input.value, label.name)"
+ [class.hidden]="filter(input.value, label.formattedName)"
>