Skip to content

Commit 60d0e2b

Browse files
committed
chore(heureka): adds checks for detailsFor and improve filter prop handling
1 parent 1024761 commit 60d0e2b

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

apps/heureka/src/hooks/useUrlState.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
useGlobalsShowPanel,
1010
useGlobalsActiveView,
1111
useGlobalsActions,
12+
useGlobalsShowServiceDetail,
13+
useGlobalsShowIssueDetail,
1214
useServiceActiveFilters,
1315
useIssueMatchesActiveFilters,
1416
useComponentActiveFilters,
@@ -24,6 +26,8 @@ const useUrlState = () => {
2426

2527
const activeView = useGlobalsActiveView()
2628
const detailsFor = useGlobalsShowPanel()
29+
const showServiceDetail = useGlobalsShowServiceDetail()
30+
const showIssueDetail = useGlobalsShowIssueDetail()
2731
const { setShowPanel, setActiveView, setServiceDetail, setIssueDetail, syncDetailsWithURL } = useGlobalsActions()
2832
const serviceActiveFilters = useServiceActiveFilters()
2933
const issueMatchesActiveFilters = useIssueMatchesActiveFilters()
@@ -69,8 +73,19 @@ const useUrlState = () => {
6973

7074
const updatedState = {
7175
[constants.ACTIVE_VIEW]: activeView, // Include active view
72-
...syncFiltersWithURL(),
73-
...syncDetailsWithURL(),
76+
...syncFiltersWithURL(serviceActiveFilters, issueMatchesActiveFilters, componentActiveFilters),
77+
...(detailsFor
78+
? syncDetailsWithURL(
79+
showServiceDetail,
80+
showIssueDetail,
81+
detailsFor === constants.PANEL_SERVICE ? constants.PANEL_SERVICE : constants.PANEL_ISSUE
82+
)
83+
: {
84+
// Remove detailsFor from URL when details Panel is closed
85+
[constants.DETAILS_FOR]: undefined,
86+
[constants.SERVICE_NAME]: undefined,
87+
[constants.ISSUE_ID]: undefined,
88+
}),
7489
}
7590

7691
// Construct the URL state
@@ -79,12 +94,14 @@ const useUrlState = () => {
7994
urlStateManager.push(updatedState)
8095
}
8196
}, [
82-
detailsFor,
8397
activeView,
98+
isURLRead,
99+
detailsFor,
100+
showServiceDetail,
101+
showIssueDetail,
84102
serviceActiveFilters,
85103
issueMatchesActiveFilters,
86104
componentActiveFilters,
87-
isURLRead,
88105
syncFiltersWithURL,
89106
syncDetailsWithURL,
90107
])

apps/heureka/src/lib/slices/createFiltersSlice.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const createFiltersSlice = (set, get) => ({
157157
`filters.setFiltersFromURL`
158158
),
159159

160-
syncFiltersWithURL: () => {
160+
syncFiltersWithURL: (serviceFilters, issueFilters, componentFilters) => {
161161
const encodedSearchTerm = btoa(
162162
JSON.stringify({
163163
[ISSUEMATCHES]: get().filters[ISSUEMATCHES].search,
@@ -167,9 +167,9 @@ const createFiltersSlice = (set, get) => ({
167167
)
168168

169169
const activeFilters = {
170-
[ISSUEMATCHES]: get().filters[ISSUEMATCHES].activeFilters,
171-
[SERVICES]: get().filters[SERVICES].activeFilters,
172-
[COMPONENTS]: get().filters[COMPONENTS].activeFilters,
170+
[ISSUEMATCHES]: issueFilters,
171+
[SERVICES]: serviceFilters,
172+
[COMPONENTS]: componentFilters,
173173
}
174174

175175
return {

apps/heureka/src/lib/slices/createGlobalsSlice.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,11 @@ const createGlobalsSlice = (set, get, options) => ({
124124
),
125125

126126
// Sync details state with the URL
127-
syncDetailsWithURL: () => {
128-
const state = get().globals
127+
syncDetailsWithURL: (serviceDetail, issueDetail, panelType) => {
129128
const updatedState = {
130-
[constants.DETAILS_FOR]: state.showPanel,
131-
// Include `iid` or `svn` immediately after `d:issue/service`
132-
[state.showPanel === constants.PANEL_SERVICE ? constants.SERVICE_NAME : constants.ISSUE_ID]:
133-
state.showPanel === constants.PANEL_SERVICE ? state.showServiceDetail : state.showIssueDetail,
129+
[constants.DETAILS_FOR]: panelType,
130+
[panelType === constants.PANEL_SERVICE ? constants.SERVICE_NAME : constants.ISSUE_ID]:
131+
panelType === constants.PANEL_SERVICE ? serviceDetail : issueDetail,
134132
}
135133
return updatedState
136134
},

0 commit comments

Comments
 (0)