Skip to content

Commit

Permalink
feat: attach closing PRs only
Browse files Browse the repository at this point in the history
Treat PRs like normal work items and list them (i.e. in epics),
unless they close a respective issue.

This enables a more straight forward representation of task lists
including (nested) PRs.
  • Loading branch information
nikku committed Nov 30, 2022
1 parent 0b406ca commit 86d4ac6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 43 deletions.
41 changes: 23 additions & 18 deletions packages/board/src/Card.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<script>
import {
isOpen,
isMerged,
isPull,
noDuplicates
} from './util';
Expand Down Expand Up @@ -35,6 +33,15 @@
export let onSelect;
function isClosingPull(link) {
const {
type,
target
} = link;
return isPull(target) && type === 'CLOSED_BY';
}
let showChildren = false;
let hovered = false;
Expand All @@ -46,28 +53,26 @@
$: labels = item.labels.filter(l => !l.column_label);
$: pull_request = item.pull_request;
$: links = item.links || [];
$: embeddedLinks = links.filter(
(link) => !isPull(link.target) && link.type !== 'LINKED_BY'
).sort(
$: links = (item.links || []).sort(
(a, b) => {
return linkOrder[a.type] - linkOrder[b.type];
}
);
$: embeddedLinks = links.filter(
(link) => !isClosingPull(link) && link.type !== 'LINKED_BY'
);
$: shownLinks = embeddedLinks.filter(link => showChildren || link.type !== 'PARENT_OF');
$: children = embeddedLinks.filter(l => l.type === 'PARENT_OF');
$: completedChildren = children.filter(l => l.target.state === 'closed');
$: prLinks = links.filter(
link => isPull(link.target) && (
isOpen(link.target) || (
isMerged(link.target) && link.type === 'CLOSED_BY'
)
)
).filter(noDuplicates(link => link.target.id));
link => isClosingPull(link)
).filter(
noDuplicates(link => link.target.id + link.ref)
);
$: repositoryName = `${repository.owner.login}/${repository.name}`;
Expand Down Expand Up @@ -183,9 +188,7 @@

{#if children.length}
<EpicIcon item={ item } linkType="PARENT_OF" />
{/if}

{#if pull_request}
{:else if pull_request}
<PullRequestIcon item={ item } />
{/if}

Expand Down Expand Up @@ -251,7 +254,7 @@
{#if shownLinks.length}
<div class="board-card-links embedded">
{#each shownLinks as link}
<CardLink item={link.target} type={ link.type } onSelect={ onSelect } />
<CardLink item={ link.target } type={ link.type } ref={ link.ref } onSelect={ onSelect } />
{/each}
</div>
{/if}
Expand All @@ -262,7 +265,9 @@
{#if prLinks.length}
<div class="board-card-links attached">
{#each prLinks as link}
<CardLink item={ link.target } type={ link.type } onSelect={ onSelect } />
<CardLink item={ link.target } type={ link.type } ref={ link.ref } onSelect={ onSelect }>
<CardStatus item={ link.target } />
</CardLink>
{/each}
</div>
{/if}
Expand Down
43 changes: 18 additions & 25 deletions packages/board/src/CardLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import LinkIcon from './components/LinkIcon.svelte';
import CollaboratorLinks from './CollaboratorLinks.svelte';
import CardStatus from './CardStatus.svelte';
import {
isApplyFilterClick,
Expand Down Expand Up @@ -31,14 +30,14 @@
$: cardUrl = `https://github.com/${ repositoryName }/issues/${ number }${ ref || '' }`;
$: linkTitle = ({
CHILD_OF: 'Parent of',
DEPENDS_ON: 'Required by',
PARENT_OF: 'Child of',
CLOSED_BY: 'Closes',
REQUIRED_BY: 'Depends on',
CLOSES: 'Closed by',
CHILD_OF: 'Child of',
DEPENDS_ON: 'Depends on',
PARENT_OF: 'Parent of',
CLOSED_BY: 'Closed by',
REQUIRED_BY: 'Required by',
CLOSES: 'Closes',
LINKED_TO: 'Linked to',
LINKED_BY: 'Linked to'
LINKED_BY: 'Linked by'
})[type] || type;
function handleSelection(qualifier, value) {
Expand Down Expand Up @@ -87,33 +86,27 @@
rel="noopener noreferrer"
class="issue-number"
on:click={ handleSelection('ref', item.key) }
title="{ repositoryName }#{ number } · { linkTitle } this issue"
title="{ linkTitle } { repositoryName }#{ number }"
>
{#if pull_request}
{#if pull_request }
<PullRequestIcon item={ item } />
{:else}
{#if type === 'PARENT_OF'}
<LinkIcon name="issue" state={ state } />
{/if}

{#if type === 'CHILD_OF'}
{:else if type === 'CHILD_OF'}
<LinkIcon name="epic" />
{/if}

{#if type === 'DEPENDS_ON' || type === 'CLOSED_BY'}
{:else if type === 'DEPENDS_ON' || type === 'CLOSED_BY' }
<LinkIcon name="depends-on" state={ state } />
{/if}

{#if type === 'REQUIRED_BY' || type === 'CLOSES' }
{:else if type === 'REQUIRED_BY' || type === 'CLOSES' }
{#if state === 'open'}
<LinkIcon name="linked-to" />
<LinkIcon name="linked-to" state={ state } />
{:else}
<LinkIcon name="issue" state={ state } />
{/if}
{/if}

{#if type === 'LINKED_TO'}
<LinkIcon name="linked-to" />
{:else if type === 'LINKED_TO'}
<LinkIcon name="linked-to" state={ state } />
{:else}
<LinkIcon name="issue" state={ state } />
{/if}
{/if}

Expand All @@ -127,5 +120,5 @@
</span>
</div>

<CardStatus item={ item } />
<slot></slot>
</div>

0 comments on commit 86d4ac6

Please sign in to comment.