Skip to content

Commit 8882a61

Browse files
hakan458hakan458niklubricardoantoniocm
authored
feat: UTC-443: Add per-dimension agreements to DM (#9031)
Co-authored-by: hakan458 <hakan@heartex.com> Co-authored-by: niklub <niklub@users.noreply.github.com> Co-authored-by: ricardoantoniocm <ricardoantoniocm@users.noreply.github.com> Co-authored-by: Ricardo Cabral <ricardo.cabralm@gmail.com>
1 parent 33539f5 commit 8882a61

File tree

6 files changed

+60
-2
lines changed

6 files changed

+60
-2
lines changed

label_studio/data_manager/managers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,22 @@ def annotate_queryset(
804804
queryset, fields_for_evaluation=None, all_fields=False, excluded_fields_for_evaluation=None, request=None
805805
):
806806
annotations_map = get_annotations_map()
807+
# If we have dynamic control-tag level agreement columns, inject into annotation map
808+
# without mutating the global map
809+
if flag_set('fflag_utc_428_consensus_control_tag_agreement', user='auto'):
810+
inject_path = getattr(settings, 'GET_DYNAMIC_DM_ANNOTATIONS', None)
811+
if inject_path:
812+
overlay_func = load_func(inject_path)
813+
# Expect a dict of {field_name: function that annotates the queryset}
814+
overlay_map = overlay_func(request=request, project=getattr(queryset.first(), 'project', None)) or {}
815+
if isinstance(overlay_map, dict) and overlay_map:
816+
# Ensure dynamic fields are evaluated even if not explicitly selected
817+
if fields_for_evaluation is None:
818+
fields_for_evaluation = list(overlay_map.keys())
819+
else:
820+
fields_for_evaluation = list(set(fields_for_evaluation) | set(overlay_map.keys()))
821+
# Merge overlay with base map for this call only
822+
annotations_map = {**annotations_map, **overlay_map}
807823

808824
if fields_for_evaluation is None:
809825
fields_for_evaluation = []

web/libs/datamanager/src/components/CellViews/Agreement/Agreement.jsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,20 @@ export const Agreement = (cell) => {
2929
const { value, original: task } = cell;
3030
const sdk = useSDK();
3131
const [content, setContent] = useState(null);
32-
const isAgreementPopoverEnabled =
33-
window.APP_SETTINGS.billing?.enterprise && ff.isActive(FF_AVERAGE_AGREEMENT_SCORE_POPOVER);
32+
const basePopoverEnabled = window.APP_SETTINGS.billing?.enterprise && ff.isActive(FF_AVERAGE_AGREEMENT_SCORE_POPOVER);
33+
34+
const colId =
35+
(cell && cell.column && typeof cell.column.id === "string" && cell.column.id) ||
36+
(cell &&
37+
cell.column &&
38+
cell.column.original &&
39+
typeof cell.column.original.alias === "string" &&
40+
cell.column.original.alias) ||
41+
"";
42+
43+
const colPath = String(colId).split(":").pop() || "";
44+
const isDimensionAgreementColumn = colPath.startsWith("dimension_agreement__");
45+
const isAgreementPopoverEnabled = basePopoverEnabled && !isDimensionAgreementColumn;
3446

3547
const handleClick = isAgreementPopoverEnabled
3648
? (e) => {

web/libs/datamanager/src/components/CellViews/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ export function normalizeCellAlias(alias) {
2323
// remove trailing separators to make `toStudlyCaps` safe
2424
const safeAlias = alias.replace(/[-_\s]+$/g, "");
2525

26+
// Treat dimension agreement columns like the built-in agreement column
27+
// so they use the same percentage formatting and coloring.
28+
if (safeAlias === "agreement" || safeAlias.startsWith("dimension_agreement__")) {
29+
return "Agreement";
30+
}
31+
2632
return toStudlyCaps(safeAlias);
2733
}

web/libs/datamanager/src/components/MainView/DataView/Table.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,22 @@ export const DataView = injector(
131131
{original?.readableType ?? parent.title}
132132
</Tag>,
133133
);
134+
} else if (typeof original?.alias === "string" && original.alias.startsWith("dimension_agreement__")) {
135+
// Show a short tag for per-dimension agreement columns (root columns, no parent)
136+
children.push(
137+
<Tag
138+
key="column-type"
139+
color="blue"
140+
style={{
141+
fontWeight: "500",
142+
fontSize: 14,
143+
cursor: "pointer",
144+
padding: "0 6px",
145+
}}
146+
>
147+
{original.readableType}
148+
</Tag>,
149+
);
134150
}
135151

136152
if (help && decoration?.help !== false) {

web/libs/datamanager/src/stores/Tabs/tab_column.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ export const TabColumn = types
187187
},
188188

189189
get readableType() {
190+
// Show a friendly tag for per-dimension agreement columns
191+
if (typeof self.alias === "string") {
192+
if (self.alias.startsWith("dimension_agreement__")) {
193+
return "agreement";
194+
}
195+
}
190196
return ViewColumnTypeShort(self.currentType);
191197
},
192198

web/libs/ui/src/lib/select/select.module.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
text-overflow: ellipsis;
1313
height: var(--select-trigger-height);
1414
width: 100%;
15+
background: var(--color-neutral-background);
16+
transition: background 150ms ease-out, border-color 150ms ease-out;
1517

1618
/* body/medium */
1719
font-size: var(--select-trigger-font-size);

0 commit comments

Comments
 (0)