feat(KAN-43): rebuild custom fields and link types
CI/CD / preconditions (pull_request) Successful in 1m0s
CI/CD / test_and_check_app (pull_request) Canceled after 0s
CI/CD / Publish immutable image (pull_request) Canceled after 0s

This commit is contained in:
2026-09-15 17:50:10 +02:00
parent b226ee8d48
commit fb4faa6070
15 changed files with 1240 additions and 331 deletions
+94 -13
View File
@@ -55,9 +55,35 @@ function initial() {
{ id: 3, name: 'Normal', position: 1 },
{ id: 4, name: 'Urgent', position: 2 },
],
ticketFieldDefinitions: [],
ticketLinkTypes: [],
fieldTypeOptions: [],
ticketFieldDefinitions: [
{
id: 5,
label: 'Reviewer',
field_type: 'user',
position: 1,
ticket_field_values_count: 2,
},
{
id: 6,
label: 'Complexity',
field_type: 'number',
position: 2,
ticket_field_values_count: 0,
},
],
ticketLinkTypes: [
{
id: 7,
label: 'Blocks',
counterpart_label: 'Blocked by',
position: 1,
ticket_links_count: 1,
},
],
fieldTypeOptions: [
{ label: 'User', value: 'user' },
{ label: 'Number', value: 'number' },
],
};
}
function makePage(
@@ -132,16 +158,30 @@ if (serve) {
response.end('Unavailable');
return;
}
const kind = url.pathname.includes('/types') ? 'type' : 'priority';
const kind = url.pathname.includes('/link-types')
? 'link'
: url.pathname.includes('/fields')
? 'field'
: url.pathname.includes('/types')
? 'type'
: 'priority';
const entries =
kind === 'type' ? data.ticketTypes : data.ticketPriorities;
kind === 'type'
? data.ticketTypes
: kind === 'priority'
? data.ticketPriorities
: kind === 'field'
? data.ticketFieldDefinitions
: data.ticketLinkTypes;
const id = Number(url.pathname.split('/').at(-1));
if (
result === 'validation' ||
(submitted.name &&
((submitted.name || submitted.label) &&
entries.some(
(entry) =>
entry.name === submitted.name && entry.id !== id,
(entry.name ?? entry.label) ===
(submitted.name ?? submitted.label) &&
entry.id !== id,
))
) {
errors =
@@ -150,7 +190,14 @@ if (serve) {
replacement_ticket_type_id:
'Choose a parent-enabled replacement type.',
}
: { name: 'This name is already in use.' };
: kind === 'field'
? { label: 'This field label is already in use.' }
: kind === 'link'
? {
counterpart_name:
'Enter a distinct counterpart label.',
}
: { name: 'This name is already in use.' };
} else if (request.method === 'DELETE') {
entries.splice(
entries.findIndex((item) => item.id === id),
@@ -159,16 +206,43 @@ if (serve) {
} else if (url.pathname.endsWith('/metadata')) {
Object.assign(data.project, submitted);
} else if (request.method === 'POST') {
entries.push({
const created = {
id: nextId++,
position: entries.length + 1,
tickets_count: 0,
...submitted,
});
...(kind === 'type'
? { tickets_count: 0, ...submitted }
: kind === 'priority'
? submitted
: kind === 'field'
? {
label: submitted.label,
field_type: submitted.field_type,
ticket_field_values_count: 0,
}
: {
label: submitted.name,
counterpart_label: submitted.counterpart_name,
ticket_links_count: 0,
}),
};
entries.push(created);
} else {
const item = entries.find((item) => item.id === id);
entries.splice(entries.indexOf(item), 1);
Object.assign(item, submitted);
Object.assign(
item,
kind === 'field'
? {
label: submitted.label,
field_type: submitted.field_type,
}
: kind === 'link'
? {
label: submitted.name,
counterpart_label: submitted.counterpart_name,
}
: submitted,
);
entries.splice(submitted.position - 1, 0, item);
}
entries.forEach((entry, index) => (entry.position = index + 1));
@@ -240,6 +314,13 @@ if (serve) {
);
assert.match(html, /Assigned tickets: 2/);
assert.match(html, /Parent type/);
assert.match(html, /data-ticket-field-definition="5"/);
assert.match(html, /Reviewer/);
assert.match(html, /Stored values: 2/);
assert.match(html, /data-ticket-link-type="7"/);
assert.match(html, /Blocks/);
assert.match(html, /Blocked by/);
assert.match(html, /Ticket relationships: 1/);
assert.match(html, /id="show_author"[^>]*aria-checked="true"/);
assert.match(html, /id="show_story_points"[^>]*aria-checked="false"/);
const single = await render({