mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
A card had exactly one release, scrum.releaseId. Jira import kept only the first fix version of an issue and reported the rest as lost, Jira export wrote no fix versions at all, and the card UI could not show or pick more than one release. A card's releases are now a list, scrum.releaseIds, with releaseId kept as its first entry so older servers, importers and REST readers still see one. Existing cards are not migrated: every reader goes through cardReleaseIds(), which reads the list and the old single field the same way, so cards saved either way work side by side, and a card moves to the new form on its next Scrum save. A save with releaseIds replaces the list; a save with only releaseId, from an older client, replaces the first release and keeps the others, and null clears them. Every release must belong to the board, checked in one query; duplicates collapse and a releaseId that contradicts the list is refused. Copies and moves to another board link each release by name. The native transfer writes one release exactly as before and adds releaseIds only for cards with several, and remaps each of them on import. Jira import maps every fix version and Jira export writes them all as fixVersions. Board View / Sprints shows each release's cards and how many are done, counting a card in each of its releases. Scrum History checks and guards every release, and rule e-mails name them all. The Product Backlog and card details use a multiple select. tests/scrumMultipleReleases.test.cjs covers the rules and fails if any code reads the single field directly; a Playwright spec drives the UI. New text is in English, pending Transifex. Thanks to xet7 !
62 lines
3.0 KiB
JavaScript
62 lines
3.0 KiB
JavaScript
'use strict';
|
|
|
|
const { normalizeScrumMetadata, cardReleaseIds } = require('./scrum');
|
|
const categories = new Map([['new', 'todo'], ['indeterminate', 'doing'], ['done', 'done']]);
|
|
const jiraCategories = new Map([...categories].map(([key, value]) => [value, key]));
|
|
|
|
function jiraScrumMetadata(fields = {}) {
|
|
const card = {};
|
|
if (fields.issuetype?.name !== undefined && fields.issuetype.name !== null) {
|
|
Object.assign(card, normalizeScrumMetadata('card', { issueType: fields.issuetype.name }));
|
|
}
|
|
const category = categories.get(fields.status?.statusCategory?.key);
|
|
return { card, list: category ? { category } : {} };
|
|
}
|
|
|
|
// Jira statuses are grouped into lists by name by the existing importer.
|
|
// Check the whole file before writes so two categories cannot silently merge.
|
|
function jiraScrumListCategories(issues) {
|
|
const result = new Map();
|
|
for (const issue of issues) {
|
|
const fields = issue.fields || {};
|
|
const { list } = jiraScrumMetadata(fields);
|
|
if (!list.category) continue;
|
|
const name = fields.status?.name || 'Imported';
|
|
if (result.has(name) && result.get(name) !== list.category) {
|
|
throw new Error('Jira statuses with the same name have conflicting Scrum categories');
|
|
}
|
|
result.set(name, list.category);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// A release as the Jira fix version the importer reads back
|
|
// (models/lib/jiraScrumPlanning.js): its Jira id when it came from Jira, its
|
|
// WeKan id otherwise; released or not; its planned end as the release date.
|
|
function jiraFixVersion(release) {
|
|
const jiraId = release.provenance?.system === 'jira' && release.provenance.recordId;
|
|
const end = release.plannedEnd || release.releasedAt;
|
|
const date = end && Number.isFinite(new Date(end).getTime()) ? new Date(end).toISOString().slice(0, 10) : null;
|
|
return { id: String(jiraId || release._id), name: release.name, released: release.state === 'released',
|
|
...(date ? { releaseDate: date } : {}), ...(release.notes ? { description: release.notes } : {}) };
|
|
}
|
|
|
|
// `releases` is a Map of the board's releases by id: each of the card's
|
|
// releases on that board is one fix version, in the card's order. A release
|
|
// that is not the board's, or no longer exists, is left out.
|
|
function jiraScrumMetadataExport(card, list, wanted = null, releases = null) {
|
|
if (wanted && !wanted.has('scrum')) return {};
|
|
const issueType = card.scrum?.issueType;
|
|
const category = jiraCategories.get(list?.scrum?.category);
|
|
const fixVersions = releases ? cardReleaseIds(card.scrum).map(id => releases.get(id))
|
|
.filter(release => release && release.boardId === card.boardId && typeof release.name === 'string' && release.name.trim())
|
|
.map(jiraFixVersion) : [];
|
|
return {
|
|
...(typeof issueType === 'string' && issueType ? { issuetype: { name: issueType } } : {}),
|
|
...(category ? { statusCategory: { key: category } } : {}),
|
|
...(fixVersions.length ? { fixVersions } : {}),
|
|
};
|
|
}
|
|
|
|
module.exports = { jiraScrumMetadata, jiraScrumListCategories, jiraScrumMetadataExport };
|