@@ -9,15 +9,17 @@ export interface JiraSettings {
9
9
name : string ,
10
10
email : string ,
11
11
apiToken : string ,
12
- boardId : string
12
+ boardId : string ,
13
+ useSprintName : boolean
13
14
}
14
15
15
16
export const JIRA_DEFAULT_SETTINGS : JiraSettings = {
16
17
baseUrl : '{yourserver}.atlassian.net' ,
17
18
name : '' ,
18
19
email : '' ,
19
20
apiToken : '' ,
20
- boardId : ''
21
+ boardId : '' ,
22
+ useSprintName : true ,
21
23
}
22
24
23
25
export class JiraClient implements ITfsClient {
@@ -32,19 +34,25 @@ export class JiraClient implements ITfsClient{
32
34
"Authorization" : `Basic ${ encoded64Key } ` ,
33
35
"Content-Type" : "application/json"
34
36
}
35
-
36
37
const BaseURL = `https://${ settings . jiraSettings . baseUrl } /rest/agile/1.0` ;
37
38
38
39
try {
39
40
const sprintsResponse = await requestUrl ( { method : 'GET' , headers : headers , url : `${ BaseURL } /board/${ settings . jiraSettings . boardId } /sprint?state=active` } )
40
-
41
- const currentSprintId = sprintsResponse . json . values [ 0 ] . id ;
42
-
41
+ const currentSprintId = sprintsResponse . json . values [ 0 ] . id
42
+ const currentSprintName = sprintsResponse . json . values [ 0 ] . name
43
+ . replace ( / S p r i n t / , '' )
44
+ . replace ( / B o a r d / , '' )
45
+ . replace ( / ^ \s + | \s + $ / g, '' )
46
+ . replace ( / [ ^ a - z 0 - 9 - ] / g, '' )
47
+ . replace ( / \s + / g, '-' )
48
+ . replace ( / - + / g, '-' )
49
+
50
+ const sprintIdentifier = settings . jiraSettings . useSprintName ? currentSprintName : currentSprintId
43
51
const issuesResponse = await requestUrl ( { method : 'GET' , headers : headers , url : `${ BaseURL } /board/${ settings . jiraSettings . boardId } /sprint/${ currentSprintId } /issue?jql=assignee=\"${ settings . jiraSettings . name } \"` } ) ;
44
52
45
53
const assignedIssuesInSprint = issuesResponse . json . issues ;
46
54
47
- const normalizedFolderPath = normalizePath ( settings . targetFolder + '/sprint-' + currentSprintId ) ;
55
+ const normalizedFolderPath = normalizePath ( settings . targetFolder + '/sprint-' + sprintIdentifier ) ;
48
56
49
57
// Ensure folder structure created
50
58
VaultHelper . createFolders ( normalizedFolderPath ) ;
@@ -65,7 +73,7 @@ export class JiraClient implements ITfsClient{
65
73
const columnIds = boardConfigResponse . json . columnConfig . columns . map ( ( column :any ) => column . name ) ;
66
74
67
75
// Create or replace Kanban board of current sprint
68
- await VaultHelper . createKanbanBoard ( normalizedFolderPath , tasks , columnIds , currentSprintId ) ;
76
+ await VaultHelper . createKanbanBoard ( normalizedFolderPath , tasks , columnIds , sprintIdentifier ) ;
69
77
}
70
78
71
79
} catch ( e ) {
@@ -119,7 +127,16 @@ export class JiraClient implements ITfsClient{
119
127
plugin . settings . jiraSettings . apiToken = value ;
120
128
await plugin . saveSettings ( ) ;
121
129
} ) ) ;
122
-
130
+ new Setting ( container )
131
+ . setName ( 'Use Sprint Name (rather than id)' )
132
+ . setDesc ( "Uses the Sprint's human assigned name" )
133
+ . addToggle ( text => text
134
+ . setValue ( plugin . settings . jiraSettings . useSprintName )
135
+ . onChange ( async ( value ) => {
136
+ plugin . settings . jiraSettings . useSprintName = value ;
137
+ await plugin . saveSettings ( ) ;
138
+ } )
139
+ ) ;
123
140
new Setting ( container )
124
141
. setName ( 'Board ID' )
125
142
. setDesc ( 'The ID of your Scrum board (the number in the URL when viewing scrum board in browser) ' )
0 commit comments