Skip to content

Commit

Permalink
Merge pull request #149 from TinkoffCreditSystems/bug/148
Browse files Browse the repository at this point in the history
[#148] add new function read board Id for update JIRA Cloud 2021-09-30
  • Loading branch information
pavelpower authored Sep 1, 2021
2 parents c6f041c + db55e63 commit 053926e
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react": "^7.24.0",
"html-loader": "^0.5.5",
"html-webpack-plugin": "3.0.4",
"husky": "^4.3.8",
Expand Down
2 changes: 1 addition & 1 deletion src/charts/AddChartGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export default class extends PageModification {
}

getModificationId() {
return `add-sla-${this.getSearchParam('rapidView')}`;
return `add-sla-${this.getBoardId()}`;
}

waitForLoading() {
Expand Down
2 changes: 1 addition & 1 deletion src/charts/AddSlaLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export default class extends PageModification {
}

getModificationId() {
return `add-sla-${this.getSearchParam('rapidView')}`;
return `add-sla-${this.getBoardId()}`;
}

waitForLoading() {
Expand Down
2 changes: 1 addition & 1 deletion src/column-limits/BoardPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class extends PageModification {
}

getModificationId() {
return `add-wip-limits-${this.getSearchParam('rapidView')}`;
return `add-wip-limits-${this.getBoardId()}`;
}

waitForLoading() {
Expand Down
2 changes: 1 addition & 1 deletion src/column-limits/SettingsPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class SettingsWIPLimits extends PageModification {
}

getModificationId() {
return `add-wip-settings-${this.getSearchParam('rapidView')}`;
return `add-wip-settings-${this.getBoardId()}`;
}

waitForLoading() {
Expand Down
56 changes: 55 additions & 1 deletion src/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,53 @@ export const Routes = {
ALL: 'ALL',
};

export const getSearchParam = param => new URLSearchParams(window.location.search).get(param);
export const getSearchParam = param => {
return new URLSearchParams(window.location.search).get(param);
};

/*
sheme old https://companyname.atlassian.net/secure/RapidBoard.jspa?projectKey=PN&rapidView=12
sheme new https://companyname.atlassian.net/jira/software/c/projects/PN/boards/12
*/
export const getBoardIdFromURL = () => {
if (window.location.href.indexOf('rapidView') > 0) {
return getSearchParam('rapidView');
}

const matchRapidView = window.location.pathname.match(/boards\/(\d+)/im);
if (matchRapidView != null) {
return matchRapidView[1];
}

return null;
};

export const getProjectKeyFromURL = () => {
if (window.location.href.indexOf('projectKey') > 0) {
return getSearchParam('projectKey');
}

// eslint-disable-next-line no-useless-escape
const matchProjectKey = window.location.pathname.match(/projects\/([^\/]+)/im);
if (matchProjectKey != null) {
return matchProjectKey[1];
}

return null;
};

/*
cloud update 2021-09-30
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=filter
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=columns
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=swimlanes
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=swimlanes
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=cardColors
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=cardLayout
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=cardLayout
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=detailView
https://mycompany.atlassian.net/jira/software/c/projects/MP/boards/138?config=roadmapConfig
*/

export const getCurrentRoute = () => {
const { pathname, search } = window.location;
Expand All @@ -26,6 +72,14 @@ export const getCurrentRoute = () => {
return Routes.BOARD;
}

// cloud update 2021-09-30
if (/boards\/(\d+)/im.test(pathname)) {
if (params.get('config')) return Routes.SETTINGS;
if (params.get('view') === 'reporting') return Routes.REPORTS;

return Routes.BOARD;
}

if (pathname.startsWith('/browse')) {
return params.get('jql') ? Routes.SEARCH : Routes.ISSUE;
}
Expand Down
16 changes: 8 additions & 8 deletions src/shared/PageModification.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSearchParam } from '../routing';
import { getBoardIdFromURL, getSearchParam } from '../routing';
import { waitForElement } from './utils';
import {
deleteBoardProperty,
Expand Down Expand Up @@ -54,39 +54,39 @@ export class PageModification {
getBoardProperty(property) {
const { cancelRequest, abortPromise } = this.createAbortPromise();
this.sideEffects.push(cancelRequest);
return getBoardProperty(getSearchParam('rapidView'), property, { abortPromise });
return getBoardProperty(getBoardIdFromURL(), property, { abortPromise });
}

getBoardConfiguration() {
const { cancelRequest, abortPromise } = this.createAbortPromise();
this.sideEffects.push(cancelRequest);
return getBoardConfiguration(getSearchParam('rapidView', { abortPromise }));
return getBoardConfiguration(getBoardIdFromURL(), { abortPromise });
}

updateBoardProperty(property, value) {
const { cancelRequest, abortPromise } = this.createAbortPromise();
this.sideEffects.push(cancelRequest);
return updateBoardProperty(getSearchParam('rapidView'), property, value, { abortPromise });
return updateBoardProperty(getBoardIdFromURL(), property, value, { abortPromise });
}

deleteBoardProperty(property) {
const { cancelRequest, abortPromise } = this.createAbortPromise();
this.sideEffects.push(cancelRequest);
return deleteBoardProperty(getSearchParam('rapidView'), property, { abortPromise });
return deleteBoardProperty(getBoardIdFromURL(), property, { abortPromise });
}

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

return getBoardEditData(getSearchParam('rapidView', { abortPromise }));
return getBoardEditData(getBoardIdFromURL(), { abortPromise });
}

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

return getBoardEstimationData(getSearchParam('rapidView', { abortPromise }));
return getBoardEstimationData(getBoardIdFromURL(), { abortPromise });
}

searchIssues(jql, params = {}) {
Expand Down Expand Up @@ -186,6 +186,6 @@ export class PageModification {
}

getBoardId() {
return this.getSearchParam('rapidView');
return getBoardIdFromURL();
}
}
4 changes: 2 additions & 2 deletions src/shared/jiraApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import isNil from '@tinkoff/utils/is/nil';
import path from '@tinkoff/utils/object/path';
import pathOr from '@tinkoff/utils/object/pathOr';
import { defaultHeaders } from './defaultHeaders';
import { getSearchParam } from '../routing';
import { getBoardIdFromURL } from '../routing';

export const configVersion = 'v1';
const getPropName = property => `${property}${configVersion}`;
Expand Down Expand Up @@ -42,7 +42,7 @@ const getBoardProperties = boardId => {
delete invalidatedProperties[cacheKey];

return requestJira({
url: boardPropertiesUrl(getSearchParam('rapidView')),
url: boardPropertiesUrl(getBoardIdFromURL()),
memoryCacheForce,
type: 'json',
});
Expand Down
5 changes: 5 additions & 0 deletions src/shared/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@
flex: 0.7;
background: red;
}

.ghx-flags {
border-radius: 2px 2px !important;
background: yellow !important;
}
2 changes: 1 addition & 1 deletion src/swimlane/SwimlaneLimits.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class extends PageModification {
}

getModificationId() {
return `add-swimlane-limits-${this.getSearchParam('rapidView')}`;
return `add-swimlane-limits-${this.getBoardId()}`;
}

appendStyles() {
Expand Down
2 changes: 1 addition & 1 deletion src/swimlane/SwimlaneSettingsPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class SwimlaneSettingsLimit extends PageModification {
}

getModificationId() {
return `add-swimlane-settings-${this.getSearchParam('rapidView')}`;
return `add-swimlane-settings-${this.getBoardId()}`;
}

waitForLoading() {
Expand Down
2 changes: 1 addition & 1 deletion src/swimlane/SwimlaneStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class extends PageModification {
}

getModificationId() {
return `add-swimlane-stats-${this.getSearchParam('rapidView')}`;
return `add-swimlane-stats-${this.getBoardId()}`;
}

waitForLoading() {
Expand Down
2 changes: 1 addition & 1 deletion src/tetris-planning/TetrisPlanning.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class extends PageModification {
}

getModificationId() {
return `tetris-planning-${this.getSearchParam('rapidView')}`;
return `tetris-planning-${this.getBoardId()}`;
}

waitForLoading() {
Expand Down
4 changes: 2 additions & 2 deletions src/tetris-planning/TetrisPlanningButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class extends PageModification {
}

getModificationId() {
return `add-tetris-button-${this.getSearchParam('rapidView')}`;
return `add-tetris-button-${this.getBoardId()}`;
}

waitForLoading() {
Expand Down Expand Up @@ -47,7 +47,7 @@ export default class extends PageModification {
this.insertHTML(
document.body,
'beforeend',
formatTemplateForInserting(template).replace(/\$BOARD/g, this.getSearchParam('rapidView'))
formatTemplateForInserting(template).replace(/\$BOARD/g, this.getBoardId())
);

this.insertHTML(
Expand Down

0 comments on commit 053926e

Please sign in to comment.