@@ -9,15 +9,17 @@ export interface JiraSettings {
99 name : string ,
1010 email : string ,
1111 apiToken : string ,
12- boardId : string
12+ boardId : string ,
13+ useSprintName : boolean
1314}
1415
1516export const JIRA_DEFAULT_SETTINGS : JiraSettings = {
1617 baseUrl : '{yourserver}.atlassian.net' ,
1718 name : '' ,
1819 email : '' ,
1920 apiToken : '' ,
20- boardId : ''
21+ boardId : '' ,
22+ useSprintName : true ,
2123}
2224
2325export class JiraClient implements ITfsClient {
@@ -32,19 +34,25 @@ export class JiraClient implements ITfsClient{
3234 "Authorization" : `Basic ${ encoded64Key } ` ,
3335 "Content-Type" : "application/json"
3436 }
35-
3637 const BaseURL = `https://${ settings . jiraSettings . baseUrl } /rest/agile/1.0` ;
3738
3839 try {
3940 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
4351 const issuesResponse = await requestUrl ( { method : 'GET' , headers : headers , url : `${ BaseURL } /board/${ settings . jiraSettings . boardId } /sprint/${ currentSprintId } /issue?jql=assignee=\"${ settings . jiraSettings . name } \"` } ) ;
4452
4553 const assignedIssuesInSprint = issuesResponse . json . issues ;
4654
47- const normalizedFolderPath = normalizePath ( settings . targetFolder + '/sprint-' + currentSprintId ) ;
55+ const normalizedFolderPath = normalizePath ( settings . targetFolder + '/sprint-' + sprintIdentifier ) ;
4856
4957 // Ensure folder structure created
5058 VaultHelper . createFolders ( normalizedFolderPath ) ;
@@ -65,7 +73,7 @@ export class JiraClient implements ITfsClient{
6573 const columnIds = boardConfigResponse . json . columnConfig . columns . map ( ( column :any ) => column . name ) ;
6674
6775 // Create or replace Kanban board of current sprint
68- await VaultHelper . createKanbanBoard ( normalizedFolderPath , tasks , columnIds , currentSprintId ) ;
76+ await VaultHelper . createKanbanBoard ( normalizedFolderPath , tasks , columnIds , sprintIdentifier ) ;
6977 }
7078
7179 } catch ( e ) {
@@ -119,7 +127,16 @@ export class JiraClient implements ITfsClient{
119127 plugin . settings . jiraSettings . apiToken = value ;
120128 await plugin . saveSettings ( ) ;
121129 } ) ) ;
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+ ) ;
123140 new Setting ( container )
124141 . setName ( 'Board ID' )
125142 . setDesc ( 'The ID of your Scrum board (the number in the URL when viewing scrum board in browser) ' )
0 commit comments