@@ -8,7 +8,35 @@ import { TProjectConfig } from '../interfaces/TProjetConfig';
8
8
9
9
type TLabeledIssues = Record < string , IWrappedIssue [ ] > ;
10
10
11
- const getIssuesForLabel = ( label : string , wrappedIssues : IWrappedIssue [ ] ) => {
11
+ const NONE_LABEL = 'codespaces-board-undefined-label' ;
12
+
13
+ const sortIssuesListByUsername = ( issues : IWrappedIssue [ ] ) => {
14
+ const result = issues . sort ( ( issue1 , issue2 ) => {
15
+ if ( ! issue1 . issue . assignees . length ) {
16
+ return 1 ;
17
+ }
18
+
19
+ if ( ! issue2 . issue . assignees . length ) {
20
+ return - 1 ;
21
+ }
22
+
23
+ if ( issue1 . issue . assignees [ 0 ] . login < issue2 . issue . assignees [ 0 ] . login ) {
24
+ return - 1 ;
25
+ }
26
+ if ( issue1 . issue . assignees [ 0 ] . login > issue2 . issue . assignees [ 0 ] . login ) {
27
+ return 1 ;
28
+ }
29
+
30
+ return 0 ;
31
+ } ) ;
32
+
33
+ return result ;
34
+ } ;
35
+
36
+ const getIssuesForLabel = (
37
+ label : string ,
38
+ wrappedIssues : IWrappedIssue [ ] ,
39
+ ) : IWrappedIssue [ ] => {
12
40
const result = wrappedIssues . filter ( ( { issue } ) => {
13
41
const foundLabel = issue . labels . find ( ( issueLabel ) => {
14
42
return issueLabel . name === label ;
@@ -20,21 +48,21 @@ const getIssuesForLabel = (label: string, wrappedIssues: IWrappedIssue[]) => {
20
48
return result ;
21
49
} ;
22
50
23
- const NONE_LABEL = 'codespaces-board-undefined-label' ;
24
-
25
51
const groupIssuesByLabels = (
26
52
issues : IWrappedIssue [ ] ,
27
53
projectConfig : TProjectConfig ,
28
54
) : TLabeledIssues => {
29
55
const result : TLabeledIssues = { } ;
30
56
31
- const labels = ( typeof projectConfig === 'number' )
32
- ? [ ]
33
- : projectConfig . trackLabels ?? [ ] ;
57
+ const labels =
58
+ typeof projectConfig === 'number' ? [ ] : projectConfig . trackLabels ?? [ ] ;
34
59
35
60
const includedIssues = new Set < IWrappedIssue > ( ) ;
36
61
for ( let label of labels ) {
37
- const issuesForLabel = getIssuesForLabel ( label , issues ) ;
62
+ const issuesForLabel = sortIssuesListByUsername (
63
+ getIssuesForLabel ( label , issues ) ,
64
+ ) ;
65
+
38
66
result [ label ] = issuesForLabel ;
39
67
40
68
for ( let issueForLabel of issuesForLabel ) {
@@ -63,9 +91,10 @@ const renderIssuesSection = (
63
91
) => {
64
92
const issueItems = [ title ] ;
65
93
66
- const isCheckList = ( typeof projectConfig === 'number' )
67
- ? undefined
68
- : projectConfig . isCheckListItems ;
94
+ const isCheckList =
95
+ typeof projectConfig === 'number'
96
+ ? undefined
97
+ : projectConfig . isCheckListItems ;
69
98
70
99
for ( let wrappedIssue of issues ) {
71
100
const { column, issue } = wrappedIssue ;
@@ -125,8 +154,7 @@ export const renderIssuesBlock = (
125
154
return undefined ;
126
155
}
127
156
128
- return [
129
- renderTitle ( title ) ,
130
- renderIssuesList ( issues , projectConfig ) ,
131
- ] . join ( '\n' ) ;
157
+ return [ renderTitle ( title ) , renderIssuesList ( issues , projectConfig ) ] . join (
158
+ '\n' ,
159
+ ) ;
132
160
} ;
0 commit comments