ソースを参照

Updates focus enrichment types

main
Keith Daulton 1年前
コミット
63770851f4
5個のファイルの変更39行の追加40行の削除
  1. +9
    -7
      src/plus/webviews/focus/focusWebview.ts
  2. +1
    -1
      src/plus/webviews/focus/protocol.ts
  3. +19
    -16
      src/webviews/apps/plus/focus/components/focus-app.ts
  4. +4
    -7
      src/webviews/apps/plus/focus/components/gk-issue-row.ts
  5. +6
    -9
      src/webviews/apps/plus/focus/components/gk-pull-request-row.ts

+ 9
- 7
src/plus/webviews/focus/focusWebview.ts ファイルの表示

@ -418,13 +418,13 @@ export class FocusWebviewProvider implements WebviewProvider {
isCurrentWorktree: pr.isCurrentWorktree ?? false,
hasWorktree: pr.hasWorktree ?? false,
hasLocalBranch: pr.hasLocalBranch ?? false,
enriched: findEnrichedItem(pr, getSettledValue(enrichedItems)),
enriched: findEnrichedItems(pr, getSettledValue(enrichedItems)),
rank: pr.rank,
})),
issues: getSettledValue(issuesResult)?.map(issue => ({
issue: serializeIssue(issue.issue),
reasons: issue.reasons,
enriched: findEnrichedItem(issue, getSettledValue(enrichedItems)),
enriched: findEnrichedItems(issue, getSettledValue(enrichedItems)),
rank: issue.rank,
})),
};
@ -592,7 +592,7 @@ export class FocusWebviewProvider implements WebviewProvider {
}
}
function findEnrichedItem(item: SearchedPullRequestWithRemote | SearchedIssue, enrichedItems?: EnrichedItem[]) {
function findEnrichedItems(item: SearchedPullRequestWithRemote | SearchedIssue, enrichedItems?: EnrichedItem[]) {
if (enrichedItems == null || enrichedItems.length === 0) return;
let result;
@ -605,10 +605,12 @@ function findEnrichedItem(item: SearchedPullRequestWithRemote | SearchedIssue, e
if (result == null) return;
return {
id: result.id,
type: result.type,
};
return [
{
id: result.id,
type: result.type,
},
];
}
function getPrRank(pr: SearchedPullRequest) {

+ 1
- 1
src/plus/webviews/focus/protocol.ts ファイルの表示

@ -22,7 +22,7 @@ export interface SearchResultBase {
enriched?: {
id: EnrichedItem['id'];
type: EnrichedItem['type'];
};
}[];
}
export interface IssueResult extends SearchResultBase {

+ 19
- 16
src/webviews/apps/plus/focus/components/focus-app.ts ファイルの表示

@ -104,9 +104,8 @@ export class GlFocusApp extends LitElement {
rank: number;
state: Record<string, any>;
tags: string[];
isPinned: boolean;
isSnoozed: boolean;
enrichedId?: string;
isPinned?: string;
isSnoozed?: string;
}[] = [];
this.state?.pullRequests?.forEach(
@ -120,8 +119,8 @@ export class GlFocusApp extends LitElement {
rank,
enriched,
}) => {
const isPinned = enriched?.type === 'pin';
const isSnoozed = enriched?.type === 'snooze';
const isPinned = enriched?.find(item => item.type === 'pin')?.id;
const isSnoozed = enriched?.find(item => item.type === 'snooze')?.id;
items.push({
isPullrequest: true,
@ -136,13 +135,12 @@ export class GlFocusApp extends LitElement {
tags: reasons,
isPinned: isPinned,
isSnoozed: isSnoozed,
enrichedId: enriched?.id,
});
},
);
this.state?.issues?.forEach(({ issue, reasons, rank, enriched }) => {
const isPinned = enriched?.type === 'pin';
const isSnoozed = enriched?.type === 'snooze';
const isPinned = enriched?.find(item => item.type === 'pin')?.id;
const isSnoozed = enriched?.find(item => item.type === 'snooze')?.id;
items.push({
isPullrequest: false,
@ -153,7 +151,6 @@ export class GlFocusApp extends LitElement {
tags: reasons,
isPinned: isPinned,
isSnoozed: isSnoozed,
enrichedId: enriched?.id,
});
});
@ -188,16 +185,21 @@ export class GlFocusApp extends LitElement {
const hasMineFilter = this.selectedMineFilter != null && this.selectedMineFilter !== '';
const hasTabFilter = this.selectedTabFilter != null && this.selectedTabFilter !== '';
if (!hasSearch && !hasMineFilter && !hasTabFilter) {
return this.items;
return this.items.filter(i => i.isSnoozed == null);
}
const searchText = this.searchText?.toLowerCase();
return this.items.filter(i => {
if (
hasTabFilter &&
((i.isPullrequest === true && this.selectedTabFilter === 'issues') ||
(i.isPullrequest === false && this.selectedTabFilter === 'prs'))
) {
if (hasTabFilter) {
if (
(i.isSnoozed != null && this.selectedTabFilter !== 'snoozed') ||
(i.isSnoozed == null && this.selectedTabFilter == 'snoozed') ||
(i.isPullrequest === true && this.selectedTabFilter === 'issues') ||
(i.isPullrequest === false && this.selectedTabFilter === 'prs')
) {
return false;
}
} else if (i.isSnoozed != null) {
return false;
}
@ -222,7 +224,8 @@ export class GlFocusApp extends LitElement {
get sortedItems() {
return this.filteredItems.sort((a, b) => {
if (a.isPinned === b.isPinned) {
return a.rank - b.rank;
return 0;
// return a.rank - b.rank;
}
return a.isPinned ? -1 : 1;
});

+ 4
- 7
src/webviews/apps/plus/focus/components/gk-issue-row.ts ファイルの表示

@ -114,15 +114,12 @@ export class GkIssueRow extends LitElement {
@property({ type: Object })
public issue?: IssueShape;
@property({ type: Boolean })
@property()
public pinned = false;
@property({ type: Boolean })
@property()
public snoozed = false;
@property({ attribute: 'enriched-id' })
public enrichedId?: string;
constructor() {
super();
@ -247,7 +244,7 @@ export class GkIssueRow extends LitElement {
onSnoozeClick(_e: Event) {
this.dispatchEvent(
new CustomEvent('snooze-item', {
detail: { item: this.issue!, snooze: this.snoozed ? this.enrichedId : undefined },
detail: { item: this.issue!, snooze: this.snoozed },
}),
);
}
@ -255,7 +252,7 @@ export class GkIssueRow extends LitElement {
onPinClick(_e: Event) {
this.dispatchEvent(
new CustomEvent('pin-item', {
detail: { item: this.issue!, pin: this.pinned ? this.enrichedId : undefined },
detail: { item: this.issue!, pin: this.pinned },
}),
);
}

+ 6
- 9
src/webviews/apps/plus/focus/components/gk-pull-request-row.ts ファイルの表示

@ -155,14 +155,11 @@ export class GkPullRequestRow extends LitElement {
@property({ type: Boolean })
public hasLocalBranch = false;
@property({ type: Boolean })
public pinned = false;
@property({ type: Boolean })
public snoozed = false;
@property()
public pinned?: string;
@property({ attribute: 'enriched-id' })
public enrichedId?: string;
@property()
public snoozed?: string;
constructor() {
super();
@ -395,7 +392,7 @@ export class GkPullRequestRow extends LitElement {
onSnoozeClick(_e: Event) {
this.dispatchEvent(
new CustomEvent('snooze-item', {
detail: { item: this.pullRequest!, snooze: this.snoozed ? this.enrichedId : undefined },
detail: { item: this.pullRequest!, snooze: this.snoozed },
}),
);
}
@ -403,7 +400,7 @@ export class GkPullRequestRow extends LitElement {
onPinClick(_e: Event) {
this.dispatchEvent(
new CustomEvent('pin-item', {
detail: { item: this.pullRequest!, pin: this.pinned ? this.enrichedId : undefined },
detail: { item: this.pullRequest!, pin: this.pinned },
}),
);
}

読み込み中…
キャンセル
保存