-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(Bundles/TabletErrorsByBundle): better links [YTFRONT-4119]
- Loading branch information
1 parent
d8605e7
commit 983646c
Showing
8 changed files
with
111 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/ui/src/ui/store/reducers/tablet-errors/url-mapping.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {produce} from 'immer'; | ||
|
||
import type {RootState} from '../../../store/reducers'; | ||
import {initialState} from './tablet-errors-by-bundle'; | ||
import {LocationParameters} from '../../../store/location'; | ||
import { | ||
makeTimeRangeSerialization, | ||
parseSerializeArrayString, | ||
} from '../../../utils/parse-serialize'; | ||
import {updateByLocationParams} from '../../../utils/utils'; | ||
|
||
export const tabletErrorsByBundleParams: LocationParameters = { | ||
teTime: { | ||
stateKey: 'tabletErrors.tabletErrorsByBundle.timeRangeFilter', | ||
initialState: initialState.timeRangeFilter, | ||
options: makeTimeRangeSerialization(initialState.timeRangeFilter), | ||
}, | ||
tePage: { | ||
stateKey: 'tabletErrors.tabletErrorsByBundle.pageFilter', | ||
initialState: initialState.pageFilter, | ||
type: 'number', | ||
}, | ||
teMethods: { | ||
stateKey: 'tabletErrors.tabletErrorsByBundle.methodsFilter', | ||
initialState: initialState.methodsFilter, | ||
options: parseSerializeArrayString, | ||
}, | ||
}; | ||
|
||
export function getTabletErrorsByBundlereparedState(state: RootState, {query}: {query: RootState}) { | ||
return produce(state, (draft) => { | ||
return updateByLocationParams({draft, query}, tabletErrorsByBundleParams); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {Page} from '../../../shared/constants/settings'; | ||
import YT from '../../config/yt-config'; | ||
import type {Tab as NavigationTab} from '../../constants/navigation'; | ||
import {ValueOf} from '../../types'; | ||
|
||
import {TabletErrorsByPathState} from '../../store/reducers/navigation/tabs/tablet-errors/tablet-errors-by-path'; | ||
import {navigationParams} from '../../store/reducers/navigation/url-mapping'; | ||
import {makeURLSearchParams} from './utils'; | ||
|
||
export function makeNavigationLink(params: { | ||
path: string; | ||
cluster?: string; | ||
navmode?: ValueOf<typeof NavigationTab>; | ||
teMode?: 'request_errors'; | ||
teTime?: TabletErrorsByPathState['timeRangeFilter']; | ||
teMethods?: Array<string>; | ||
}) { | ||
const {cluster, ...rest} = params; | ||
const res = `/${cluster || YT.cluster}/${Page.NAVIGATION}`; | ||
const search = makeURLSearchParams(rest, navigationParams).toString(); | ||
return search ? `${res}?${search}` : res; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {LocationParameters} from '../../store/location'; | ||
|
||
export function makeURLSearchParams<T extends object>(params: T, info: LocationParameters) { | ||
const res = new URLSearchParams(); | ||
Object.keys(params).reduce((acc, k) => { | ||
const value = params[k as keyof T]; | ||
if (k in info) { | ||
if (info[k].options?.serialize) { | ||
const tmp = info[k].options?.serialize?.(value); | ||
if (tmp !== undefined) { | ||
res.append(k, tmp + ''); | ||
} | ||
} else { | ||
res.append(k, value + ''); | ||
} | ||
} | ||
return acc; | ||
}, res); | ||
return res; | ||
} |