Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/shridhar-tl/jira-assistant
Browse files Browse the repository at this point in the history
… into package
  • Loading branch information
shridhar-tl committed Nov 13, 2023
2 parents 3852d9d + 8fa1122 commit 023490b
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 22 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
}
},
"dependencies": {
"@forge/api": "^2.19.3",
"@forge/api": "^2.20.0",
"@forge/bridge": "^3.0.0",
"@forge/resolver": "^1.5.19",
"@forge/resolver": "^1.5.21",
"@fortawesome/fontawesome-free": "6.4.2",
"@fullcalendar/core": "6.1.9",
"@fullcalendar/daygrid": "6.1.9",
Expand All @@ -69,12 +69,12 @@
"dexie": "3.2.4",
"espree": "9.6.1",
"exceljs": "4.4.0",
"firebase": "10.5.0",
"firebase": "10.6.0",
"jquery": "3.7.1",
"js-sql-parser": "1.4.1",
"js-sql-parser": "1.5.0",
"jsd-report": "0.1.11",
"jspdf": "2.5.1",
"jspdf-autotable": "3.7.0",
"jspdf-autotable": "3.7.1",
"moment": "2.29.4",
"moment-timezone": "0.5.43",
"papaparse": "5.4.1",
Expand All @@ -90,19 +90,19 @@
"react-dnd": "14.0.4",
"react-dnd-html5-backend": "14.0.2",
"react-dom": "18.2.0",
"react-router-dom": "6.17.0",
"react-router-dom": "6.18.0",
"react-scripts": "5.0.1",
"static-eval": "2.1.0",
"zustand": "4.4.3"
"zustand": "4.4.6"
},
"devDependencies": {
"@craco/craco": "^7.1.0",
"cross-env": "^7.0.3",
"eslint": "^8.51.0",
"eslint": "^8.53.0",
"eslint-plugin-react-hooks": "^4.6.0",
"gh-pages": "^6.0.0",
"react-app-alias": "^2.2.2",
"sass": "^1.69.4",
"sass": "^1.69.5",
"webpack-bundle-analyzer": "^4.9.1"
},
"scripts": {
Expand Down
40 changes: 40 additions & 0 deletions src/components/ReportSelectList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import { SelectBox } from '../controls';
import { inject } from 'src/services';
import { useNavigate } from 'react-router-dom';

function ReportSelectList({ reportId, reportType, reportPath }) {
const [reportsList, setList] = React.useState();
const navigate = useNavigate();

React.useEffect(() => {
getReportsList(reportType).then(setList);
}, [reportType]);

const changeHandler = React.useCallback((reportId) => {
if (reportId) {
navigate(`${reportPath}/${reportId}`);
}
}, [navigate, reportPath]);

if (!reportsList?.length) {
return null;
}

return (<SelectBox className="report-picker" dataset={reportsList} value={parseInt(reportId)} valueField="value"
onChange={changeHandler} placeholder="Select a report to edit" />);
}

export default ReportSelectList;

async function getReportsList(reportType) {
const { $report } = inject('ReportService');

const result = await $report.getReportsList();

const reportsList = result
.filter(q => q.reportType === reportType)
.map(q => ({ value: q.id, label: q.queryName }));

return reportsList;
}
56 changes: 44 additions & 12 deletions src/content-scripts/jira-board.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,51 @@ import { waitAndGet } from "./utils";

export async function applyBoardLogic(currentPage, settings, firstTime, applyModifications) {
if (currentPage === Pages.Board) {
$('.ghx-columns div.js-issue .ja-issue-el').remove();

const triggerFunc = triggerWLTracking.bind({ settings, applyModifications });

const selector = '.ghx-columns div.js-issue';
const issues = firstTime ? (await waitAndGet(selector)) : $(selector);
issues.each((i, el) => {
el = $(el);
const issueKey = el.attr('data-issue-key');
const issueId = el.attr('data-issue-id');

const controls = el.find(isCloud ? '.ghx-stat-fields .ghx-row:first-child' : '.ghx-card-footer');
addTimerControls(currentPage, controls, issueKey, settings, issueId, triggerFunc);
});
if (isCloud) {
await handleForCloudJira(triggerFunc, firstTime, currentPage, settings);
} else {
await handleForPrivateJiraInstance(triggerFunc, firstTime, currentPage, settings);
}
}
}

async function handleForCloudJira(triggerFunc, firstTime, currentPage, settings) {
$('#ak-main-content div[data-test-id="platform-board-kit.ui.card.card"] span.ghx-field.ja-issue-el').remove();
const selector = '#ak-main-content div[data-test-id="platform-board-kit.ui.card.card"]';

const issues = firstTime ? (await waitAndGet(selector)) : $(selector);
issues.each((i, el) => {
el = $(el);
let issueKey = el.attr('id');
if (!issueKey?.startsWith('card-')) {
return;
}
issueKey = issueKey.substring(5);

let issueId = el.attr('data-rbd-draggable-id');
if (!issueId?.startsWith('ISSUE::')) {
return;
}
issueId = issueId.substring(7);

const controls = el.find('> div > div > div > div:last-child:not(:first-child) > div:first-child:last-child > div:first-child');
addTimerControls(currentPage, controls, issueKey, settings, issueId, triggerFunc);
});
}

async function handleForPrivateJiraInstance(triggerFunc, firstTime, currentPage, settings) {
$('.ghx-columns div.js-issue .ja-issue-el').remove();

const selector = '.ghx-columns div.js-issue';
const issues = firstTime ? (await waitAndGet(selector)) : $(selector);
issues.each((i, el) => {
el = $(el);
const issueKey = el.attr('data-issue-key');
const issueId = el.attr('data-issue-id');

const controls = el.find('.ghx-card-footer');
addTimerControls(currentPage, controls, issueKey, settings, issueId, triggerFunc);
});
}
3 changes: 3 additions & 0 deletions src/views/reports/pivot-report/Style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.p-dropdown.report-picker {
width: 250px !important;
}
5 changes: 4 additions & 1 deletion src/views/reports/pivot-report/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import { usePivotConfig, useReportData } from './store/pivot-config';
import { loadReport } from './utils/common';
import EditorControls from './editor/controls';
import EditorBody from './editor/body';
import ReportSelectList from '../../../components/ReportSelectList';
import './Style.scss';

function PivotReport() {
const { reportId } = useParams();
const { reportId, userId } = useParams();
const [editMode, toggleEdit] = useToggler(!reportId);

React.useEffect(() => {
Expand All @@ -23,6 +25,7 @@ function PivotReport() {
const hasParams = parameters && Object.keys(parameters).length > 0;

const customActions = (<>
<ReportSelectList reportType="pivot" reportId={reportId} reportPath={`/${userId}/reports/pivot`} />
{hasParams && <Button type="secondary" icon="fa fa-list-check" className="mx-1"
onClick={toggleParameters} title="Show report parameters" />}
<Button type="secondary" icon="fa fa-edit" className="mx-1"
Expand Down

0 comments on commit 023490b

Please sign in to comment.