Repository navigation
feat(tracker): copy issue templates to another project - #11146
MichaelUray wants to merge 10 commits into
Conversation
Issue templates are stored in a single project and the only action available on them was Edit, so a template had to be recreated by hand for every new project. Add a "Copy to project…" action for issue templates. It opens a popup with the existing project selector (excluding the template's own project) and creates a copy of the template in the chosen project, including its child templates, description, priority, assignee, labels and estimation. Component and milestone belong to the source project and are cleared; a task type is kept only when the target project type provides it. Child templates get fresh ids; comments and attachments are not copied. The data mapping lives in a small pure helper covered by unit tests. Fixes hcengineering#5892 Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
8e6d455 to
939307f
Compare
|
@MichaelUray The data mapping and the unit tests look good. Question: the assignee is copied as is, but they may not be a member of the target project. Should it be cleared in that case, or is it intentional to keep it? |
Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
…copy error Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
Limit the shared Card change to what the template copy dialog needs (closeOnSave and resetting the spinner after a failed action). The translated Close tooltip and native Enter activation on buttons affect every dialog and are dropped from this change, together with their tests and fixtures. Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
|
Thanks for the review!
Also changed: submitting rechecks that the target project is still active and that you are a member, and errors stay in the dialog so you can retry. To support this, the shared Verification (head fe1d1f7): local CI is green (install, build, validate, svelte-check, format, unit tests including the four template-copy suites, bundle). Browser checks on a local stack pass 10/10 in Chromium, Firefox and WebKit: for a target project where the assignee is a member, a public project where they are not, a private project where they are not, and an unassigned template, the copied parent/child templates keep their assignees after reopening, issues created from the copy carry them, copying leaves the target's member list unchanged, and in the private project the non-member can neither see the project nor open the issues. |
|
@MichaelUray Please take a look at the following review comments:
|
…ify the tests Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
… the dialog usable when failure feedback throws Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
|
@ArtyomSavchenko I addressed all four points:
On Could you approve the workflow run for this push? |
Fixes #5892
I added “Copy to project…” for issue templates so I can reuse a template and its children in another project without recreating them by hand.
input: 'any'to accept both a plain template document and the full selection. It is unavailable for issues.submitIssueTemplateCopyrechecks target eligibility and reads the target project type’s task types once for the batch. It creates each selected template separately, with its children embedded and fresh child IDs. This is not an atomic batch; target eligibility is checked before writes, not atomically with them.I preserve the title, description, priority, assignee, estimation, labels, and child templates. I clear components and milestones because they belong to the source project, and retain a task kind only if the target project type provides it. I do not copy comments or attachments; their counters start at zero. Parent mixin/custom attribute data is not copied.
I preserve assignees on both parent and child templates, including non-members, matching the template editor. Copying does not change project membership or grant access. An unassigned parent stays unassigned, allowing the target project’s default assignee to apply when an issue is created. The existing public-project collaborator rule can add a non-member assignee to the project when an issue is subsequently created; that rule does not apply to private projects.
I also preserve relations to the same documents, including documents in the source project. Template relations are one-sided references:
CreateIssueTemplatewrites the template’srelations, andRelatedIssueTemplatesfinds the reverse view by querying that array. Preserving those references lets the copy appear in the existing related-template view without updating the related document. This differs from issue-to-issue relation editing, which explicitly updates both sides for symmetric relations.I handle copy failures in the dialog’s submission helper:
Analytics.handleErrorand shows a localized error notification usingSimpleNotification, with the failed template titles.I limited the shared
Cardchange tocloseOnSave, defaulting totrue. After a synchronousokActionreturns normally, or its returnedPromiseresolves,CardclearsokProcessingand dispatchescloseonly when this option is true. The copy dialog sets it tofalseand closes itself only after all selected templates have copied successfully to the currently selected target. Explicit Close still works. I removed the earlier shared catch/analytics/reset handling:Cardretains upstream behavior for throwing or rejected actions, including leavingokProcessingset on failure. Existing callers keep their previous behavior.I added the three copy-related strings to all 14 tracker locales. I removed the extra jsdom Jest project, custom Svelte transform, component fixtures, and
jest-environment-jsdomdependency introduced in the earlier version. The existing Node/ts-jest configuration remains, with no added dependencies.I kept five focused Node suites, totaling 34 tests:
actions.test.ts: production action registration and filtering for a plain template, one or two selected templates, and issue exclusion.copy.test.tsandissue-template-copy.test.ts: copied/cleared fields, compatible task kinds, fresh child IDs, independent arrays, preserved relations, and parent/child assignees.submitCopy.test.ts: target validation, shared lookups, copying both templates and their children, independent write failures, and lookup recovery.copySubmission.test.ts: target changes during pending work, invalidation/recovery, failure feedback, overlapping submissions, retry without repeating successful copies, and throwing/rejected feedback callbacks.On
992b51c65f, install, build, validate, svelte-check, formatting and the tests pass locally. Browser checks passed 16/16 in each of Chromium, Firefox, and WebKit. I checked the open-template panel menu, list context menus and Cmd/Ctrl+K with one and two selected templates, both templates copied exactly once, and issue exclusion. Archiving the selected target kept the dialog usable; after restoring and reselecting it, retry created both missing copies exactly once. The original parent/child assignee, issue creation, membership, visibility, and private-project access checks also passed.I confirmed the panel-menu regression check fails as expected on
fe515cff1b, where the action usesinput: 'selection'. The browser recovery check covers target rejection before writes; partial-write retry and throwing/rejected feedback are covered by the Node tests, not by browser fault injection.