Skip to content

Commit d8404f2

Browse files
Aleksy Lisowskipiotrczarnas
Aleksy Lisowski
authored andcommitted
Merged PR 2675: incident tabs
- opening incident tab correctly - getting IncidentsHistograms correctly
2 parents faf25e4 + e753d3b commit d8404f2

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

dqops/src/main/frontend/src/components/IncidentsLayout/IncidentsTree.tsx

+16-12
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,22 @@ const IncidentsTree = () => {
6060
};
6161

6262
const openCorrectTabFromUrl = () => {
63-
if (
64-
window.location.pathname === '/incidents' ||
65-
window.location.pathname === '/incidents/'
66-
) {
67-
return;
68-
}
63+
// if (
64+
// window.location.pathname === '/incidents' ||
65+
// window.location.pathname === '/incidents/'
66+
// ) {
67+
// return;
68+
// }
6969

7070
const path = window.location.pathname.split('/');
7171
const connection = path[2];
7272
const selectedConnection = connections.find(
7373
(x) => x.connection === connection
7474
);
75-
7675
if (selectedConnection && !path[3]) {
7776
openFirstLevelTab(selectedConnection);
7877
} else if (path[3]) {
78+
console.log(selectedConnection, path);
7979
const connection = path[2] || '';
8080
const year = Number(path[3]);
8181
const month = Number(path[4]);
@@ -95,13 +95,17 @@ const IncidentsTree = () => {
9595
})
9696
);
9797

98-
dispatch(
99-
setActiveFirstLevelTab(
100-
ROUTES.INCIDENT_DETAIL(connection, year, month, incidentId)
101-
)
102-
);
10398
history.push(ROUTES.INCIDENT_DETAIL(connection, year, month, incidentId));
10499
}
100+
if (
101+
activeTab &&
102+
activeTab !== window.location.pathname &&
103+
(window.location.pathname === '/incidents/' ||
104+
window.location.pathname === '/incidents')
105+
) {
106+
dispatch(setActiveFirstLevelTab(activeTab));
107+
history.push(activeTab);
108+
}
105109
};
106110

107111
useEffect(() => {

dqops/src/main/frontend/src/components/IncidentsLayout/index.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ const IncidentsLayout = ({ route }: LayoutProps) => {
4747
history.push(`/incidents`);
4848
return;
4949
}
50+
if (tabIndex === 0 && pageTabs.length > 1) {
51+
history.push(pageTabs[1]?.url);
52+
dispatch(setActiveFirstLevelTab(pageTabs[1]?.url));
53+
return;
54+
}
5055
history.push(pageTabs[tabIndex - 1]?.url || pageTabs[0]?.url);
5156
dispatch(
5257
setActiveFirstLevelTab(pageTabs[tabIndex - 1]?.url || pageTabs[0]?.url)

dqops/src/main/frontend/src/pages/IncidentDetail/HistogramChart.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
getIncidentsHistograms,
99
setIncidentsHistogramFilter
1010
} from '../../redux/actions/incidents.actions';
11+
import { IRootState } from '../../redux/reducers';
1112
import {
1213
IncidentHistogramFilter,
1314
IncidentIssueFilter
@@ -44,6 +45,7 @@ export const HistogramChart = ({
4445
histograms: IncidentIssueHistogramModel;
4546
histogramFilter: IncidentHistogramFilter;
4647
} = useSelector(getFirstLevelIncidentsState);
48+
const { activeTab } = useSelector((state: IRootState) => state.incidents);
4749
const dispatch = useActionDispatch();
4850

4951
useEffect(() => {
@@ -60,9 +62,8 @@ export const HistogramChart = ({
6062

6163
useEffect(() => {
6264
if (!histogramFilter) return;
63-
64-
dispatch(getIncidentsHistograms(histogramFilter));
65-
}, [histogramFilter]);
65+
dispatch(getIncidentsHistograms(histogramFilter ?? {}));
66+
}, [histogramFilter, activeTab]);
6667

6768
const onChangeFilter = (obj: Partial<IncidentHistogramFilter>) => {
6869
dispatch(

0 commit comments

Comments
 (0)