Pārlūkot izejas kodu

Updates focus enrichment types

main
Keith Daulton pirms 1 gada
vecāks
revīzija
63770851f4
5 mainītis faili ar 39 papildinājumiem un 40 dzēšanām
  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 Parādīt failu

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

+ 1
- 1
src/plus/webviews/focus/protocol.ts Parādīt failu

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

+ 19
- 16
src/webviews/apps/plus/focus/components/focus-app.ts Parādīt failu

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

+ 4
- 7
src/webviews/apps/plus/focus/components/gk-issue-row.ts Parādīt failu

@ -114,15 +114,12 @@ export class GkIssueRow extends LitElement {
@property({ type: Object }) @property({ type: Object })
public issue?: IssueShape; public issue?: IssueShape;
@property({ type: Boolean })
@property()
public pinned = false; public pinned = false;
@property({ type: Boolean })
@property()
public snoozed = false; public snoozed = false;
@property({ attribute: 'enriched-id' })
public enrichedId?: string;
constructor() { constructor() {
super(); super();
@ -247,7 +244,7 @@ export class GkIssueRow extends LitElement {
onSnoozeClick(_e: Event) { onSnoozeClick(_e: Event) {
this.dispatchEvent( this.dispatchEvent(
new CustomEvent('snooze-item', { 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) { onPinClick(_e: Event) {
this.dispatchEvent( this.dispatchEvent(
new CustomEvent('pin-item', { 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 Parādīt failu

@ -155,14 +155,11 @@ export class GkPullRequestRow extends LitElement {
@property({ type: Boolean }) @property({ type: Boolean })
public hasLocalBranch = false; 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() { constructor() {
super(); super();
@ -395,7 +392,7 @@ export class GkPullRequestRow extends LitElement {
onSnoozeClick(_e: Event) { onSnoozeClick(_e: Event) {
this.dispatchEvent( this.dispatchEvent(
new CustomEvent('snooze-item', { 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) { onPinClick(_e: Event) {
this.dispatchEvent( this.dispatchEvent(
new CustomEvent('pin-item', { new CustomEvent('pin-item', {
detail: { item: this.pullRequest!, pin: this.pinned ? this.enrichedId : undefined },
detail: { item: this.pullRequest!, pin: this.pinned },
}), }),
); );
} }

Notiek ielāde…
Atcelt
Saglabāt