Skip to content

Commit db55e63

Browse files
Павел АхметчановПавел Ахметчанов
authored andcommitted
[#148] add new function read board Id for update JIRA Cloud 2021-09-30
1 parent c6f041c commit db55e63

File tree

14 files changed

+81
-22
lines changed

14 files changed

+81
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"eslint-plugin-import": "^2.22.1",
9797
"eslint-plugin-jsx-a11y": "^6.4.1",
9898
"eslint-plugin-prettier": "^3.3.1",
99-
"eslint-plugin-react": "^7.22.0",
99+
"eslint-plugin-react": "^7.24.0",
100100
"html-loader": "^0.5.5",
101101
"html-webpack-plugin": "3.0.4",
102102
"husky": "^4.3.8",

src/charts/AddChartGrid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ export default class extends PageModification {
248248
}
249249

250250
getModificationId() {
251-
return `add-sla-${this.getSearchParam('rapidView')}`;
251+
return `add-sla-${this.getBoardId()}`;
252252
}
253253

254254
waitForLoading() {

src/charts/AddSlaLine.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export default class extends PageModification {
273273
}
274274

275275
getModificationId() {
276-
return `add-sla-${this.getSearchParam('rapidView')}`;
276+
return `add-sla-${this.getBoardId()}`;
277277
}
278278

279279
waitForLoading() {

src/column-limits/BoardPage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class extends PageModification {
1212
}
1313

1414
getModificationId() {
15-
return `add-wip-limits-${this.getSearchParam('rapidView')}`;
15+
return `add-wip-limits-${this.getBoardId()}`;
1616
}
1717

1818
waitForLoading() {

src/column-limits/SettingsPage/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default class SettingsWIPLimits extends PageModification {
4747
}
4848

4949
getModificationId() {
50-
return `add-wip-settings-${this.getSearchParam('rapidView')}`;
50+
return `add-wip-settings-${this.getBoardId()}`;
5151
}
5252

5353
waitForLoading() {

src/routing.js

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,53 @@ export const Routes = {
1111
ALL: 'ALL',
1212
};
1313

14-
export const getSearchParam = param => new URLSearchParams(window.location.search).get(param);
14+
export const getSearchParam = param => {
15+
return new URLSearchParams(window.location.search).get(param);
16+
};
17+
18+
/*
19+
sheme old https://companyname.atlassian.net/secure/RapidBoard.jspa?projectKey=PN&rapidView=12
20+
sheme new https://companyname.atlassian.net/jira/software/c/projects/PN/boards/12
21+
*/
22+
export const getBoardIdFromURL = () => {
23+
if (window.location.href.indexOf('rapidView') > 0) {
24+
return getSearchParam('rapidView');
25+
}
26+
27+
const matchRapidView = window.location.pathname.match(/boards\/(\d+)/im);
28+
if (matchRapidView != null) {
29+
return matchRapidView[1];
30+
}
31+
32+
return null;
33+
};
34+
35+
export const getProjectKeyFromURL = () => {
36+
if (window.location.href.indexOf('projectKey') > 0) {
37+
return getSearchParam('projectKey');
38+
}
39+
40+
// eslint-disable-next-line no-useless-escape
41+
const matchProjectKey = window.location.pathname.match(/projects\/([^\/]+)/im);
42+
if (matchProjectKey != null) {
43+
return matchProjectKey[1];
44+
}
45+
46+
return null;
47+
};
48+
49+
/*
50+
cloud update 2021-09-30
51+
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=filter
52+
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=columns
53+
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=swimlanes
54+
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=swimlanes
55+
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=cardColors
56+
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=cardLayout
57+
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=cardLayout
58+
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=detailView
59+
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=roadmapConfig
60+
*/
1561

1662
export const getCurrentRoute = () => {
1763
const { pathname, search } = window.location;
@@ -26,6 +72,14 @@ export const getCurrentRoute = () => {
2672
return Routes.BOARD;
2773
}
2874

75+
// cloud update 2021-09-30
76+
if (/boards\/(\d+)/im.test(pathname)) {
77+
if (params.get('config')) return Routes.SETTINGS;
78+
if (params.get('view') === 'reporting') return Routes.REPORTS;
79+
80+
return Routes.BOARD;
81+
}
82+
2983
if (pathname.startsWith('/browse')) {
3084
return params.get('jql') ? Routes.SEARCH : Routes.ISSUE;
3185
}

src/shared/PageModification.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getSearchParam } from '../routing';
1+
import { getBoardIdFromURL, getSearchParam } from '../routing';
22
import { waitForElement } from './utils';
33
import {
44
deleteBoardProperty,
@@ -54,39 +54,39 @@ export class PageModification {
5454
getBoardProperty(property) {
5555
const { cancelRequest, abortPromise } = this.createAbortPromise();
5656
this.sideEffects.push(cancelRequest);
57-
return getBoardProperty(getSearchParam('rapidView'), property, { abortPromise });
57+
return getBoardProperty(getBoardIdFromURL(), property, { abortPromise });
5858
}
5959

6060
getBoardConfiguration() {
6161
const { cancelRequest, abortPromise } = this.createAbortPromise();
6262
this.sideEffects.push(cancelRequest);
63-
return getBoardConfiguration(getSearchParam('rapidView', { abortPromise }));
63+
return getBoardConfiguration(getBoardIdFromURL(), { abortPromise });
6464
}
6565

6666
updateBoardProperty(property, value) {
6767
const { cancelRequest, abortPromise } = this.createAbortPromise();
6868
this.sideEffects.push(cancelRequest);
69-
return updateBoardProperty(getSearchParam('rapidView'), property, value, { abortPromise });
69+
return updateBoardProperty(getBoardIdFromURL(), property, value, { abortPromise });
7070
}
7171

7272
deleteBoardProperty(property) {
7373
const { cancelRequest, abortPromise } = this.createAbortPromise();
7474
this.sideEffects.push(cancelRequest);
75-
return deleteBoardProperty(getSearchParam('rapidView'), property, { abortPromise });
75+
return deleteBoardProperty(getBoardIdFromURL(), property, { abortPromise });
7676
}
7777

7878
getBoardEditData() {
7979
const { cancelRequest, abortPromise } = this.createAbortPromise();
8080
this.sideEffects.push(cancelRequest);
8181

82-
return getBoardEditData(getSearchParam('rapidView', { abortPromise }));
82+
return getBoardEditData(getBoardIdFromURL(), { abortPromise });
8383
}
8484

8585
getBoardEstimationData() {
8686
const { cancelRequest, abortPromise } = this.createAbortPromise();
8787
this.sideEffects.push(cancelRequest);
8888

89-
return getBoardEstimationData(getSearchParam('rapidView', { abortPromise }));
89+
return getBoardEstimationData(getBoardIdFromURL(), { abortPromise });
9090
}
9191

9292
searchIssues(jql, params = {}) {
@@ -186,6 +186,6 @@ export class PageModification {
186186
}
187187

188188
getBoardId() {
189-
return this.getSearchParam('rapidView');
189+
return getBoardIdFromURL();
190190
}
191191
}

src/shared/jiraApi.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import isNil from '@tinkoff/utils/is/nil';
1212
import path from '@tinkoff/utils/object/path';
1313
import pathOr from '@tinkoff/utils/object/pathOr';
1414
import { defaultHeaders } from './defaultHeaders';
15-
import { getSearchParam } from '../routing';
15+
import { getBoardIdFromURL } from '../routing';
1616

1717
export const configVersion = 'v1';
1818
const getPropName = property => `${property}${configVersion}`;
@@ -42,7 +42,7 @@ const getBoardProperties = boardId => {
4242
delete invalidatedProperties[cacheKey];
4343

4444
return requestJira({
45-
url: boardPropertiesUrl(getSearchParam('rapidView')),
45+
url: boardPropertiesUrl(getBoardIdFromURL()),
4646
memoryCacheForce,
4747
type: 'json',
4848
});

src/shared/styles.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@
1717
flex: 0.7;
1818
background: red;
1919
}
20+
21+
.ghx-flags {
22+
border-radius: 2px 2px !important;
23+
background: yellow !important;
24+
}

src/swimlane/SwimlaneLimits.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class extends PageModification {
1313
}
1414

1515
getModificationId() {
16-
return `add-swimlane-limits-${this.getSearchParam('rapidView')}`;
16+
return `add-swimlane-limits-${this.getBoardId()}`;
1717
}
1818

1919
appendStyles() {

0 commit comments

Comments
 (0)