|
2 | 2 | import ContextMenu from '$lib/components/contextmenu/ContextMenu.svelte'; |
3 | 3 | import ContextMenuItem from '$lib/components/contextmenu/ContextMenuItem.svelte'; |
4 | 4 | import ContextMenuSection from '$lib/components/contextmenu/ContextMenuSection.svelte'; |
| 5 | + import { getForgePrService } from '$lib/forge/interface/forgePrService'; |
| 6 | + import { updatePrDescriptionTables } from '$lib/forge/shared/stackFooter'; |
| 7 | + import { User } from '$lib/stores/user'; |
5 | 8 | import { BranchController } from '$lib/vbranches/branchController'; |
6 | 9 | import { VirtualBranch } from '$lib/vbranches/types'; |
7 | 10 | import { getContext, getContextStore } from '@gitbutler/shared/context'; |
8 | 11 | import Button from '@gitbutler/ui/Button.svelte'; |
9 | 12 | import Modal from '@gitbutler/ui/Modal.svelte'; |
10 | 13 | import Toggle from '@gitbutler/ui/Toggle.svelte'; |
11 | 14 | import Tooltip from '@gitbutler/ui/Tooltip.svelte'; |
| 15 | + import { isDefined } from '@gitbutler/ui/utils/typeguards'; |
12 | 16 |
|
13 | 17 | interface Props { |
14 | 18 | prUrl?: string; |
|
26 | 30 |
|
27 | 31 | const branchStore = getContextStore(VirtualBranch); |
28 | 32 | const branchController = getContext(BranchController); |
| 33 | + const prService = getForgePrService(); |
| 34 | + const user = getContextStore(User); |
29 | 35 |
|
30 | 36 | let deleteBranchModal: Modal; |
31 | 37 | let allowRebasing = $state<boolean>(); |
|
37 | 43 | allowRebasing = branch.allowRebasing; |
38 | 44 | }); |
39 | 45 |
|
| 46 | + const allPrIds = $derived(branch.series.map((series) => series.forgeId).filter(isDefined)); |
| 47 | +
|
40 | 48 | async function toggleAllowRebasing() { |
41 | 49 | branchController.updateBranchAllowRebasing(branch.id, !allowRebasing); |
42 | 50 | } |
|
113 | 121 | }} |
114 | 122 | /> |
115 | 123 | </ContextMenuSection> |
| 124 | + {#if $user && $user.role?.includes('admin')} |
| 125 | + <ContextMenuSection label="admin only"> |
| 126 | + <ContextMenuItem |
| 127 | + label="Update PR footers" |
| 128 | + disabled={allPrIds.length === 0} |
| 129 | + onclick={() => { |
| 130 | + if ($prService && branch) { |
| 131 | + const allPrIds = branch.series.map((series) => series.forgeId).filter(isDefined); |
| 132 | + updatePrDescriptionTables($prService, allPrIds); |
| 133 | + } |
| 134 | + contextMenuEl?.close(); |
| 135 | + }} |
| 136 | + /> |
| 137 | + </ContextMenuSection> |
| 138 | + {/if} |
116 | 139 | </ContextMenu> |
117 | 140 |
|
118 | 141 | <Modal |
|
0 commit comments