-
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.
feat(Navigation/Flow): add new tab [YTFRONT-3978]
- Loading branch information
1 parent
a6b09f7
commit 1ef39d7
Showing
12 changed files
with
142 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.yt-navigation-flow { | ||
&__view-mode { | ||
margin-bottom: 20px; | ||
} | ||
} |
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,36 @@ | ||
import React from 'react'; | ||
import {useDispatch, useSelector} from 'react-redux'; | ||
import cn from 'bem-cn-lite'; | ||
|
||
import {RadioButton} from '@gravity-ui/uikit'; | ||
|
||
import {getFlowViewMode} from '../../../../store/selectors/flow'; | ||
import { | ||
FLOW_VIEW_MODES, | ||
FlowViewMode, | ||
setFlowViewMode, | ||
} from '../../../../store/reducers/flow/filters'; | ||
|
||
import './Flow.scss'; | ||
|
||
const block = cn('yt-navigation-flow'); | ||
|
||
const MODE_OPTIONS = FLOW_VIEW_MODES.map((value) => { | ||
return {value, content: value}; | ||
}); | ||
|
||
export function Flow() { | ||
const dispatch = useDispatch(); | ||
const viewMode = useSelector(getFlowViewMode); | ||
return ( | ||
<div className={block()}> | ||
<RadioButton<FlowViewMode> | ||
className={block('view-mode')} | ||
options={MODE_OPTIONS} | ||
value={viewMode} | ||
onUpdate={(value) => dispatch(setFlowViewMode(value))} | ||
/> | ||
<div>Not implemented</div> | ||
</div> | ||
); | ||
} |
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,12 @@ | ||
import React from 'react'; | ||
import withLazyLoading from '../../../../hocs/withLazyLoading'; | ||
|
||
function importFlow() { | ||
return import(/* webpackChunkName: "navigation-flow" */ './Flow'); | ||
} | ||
|
||
export const Flow = withLazyLoading( | ||
React.lazy(async () => { | ||
return {default: (await importFlow()).Flow}; | ||
}), | ||
); |
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,33 @@ | ||
import {PayloadAction, createSlice} from '@reduxjs/toolkit'; | ||
|
||
export type FlowFiltersState = { | ||
flowViewMode: FlowViewMode; | ||
}; | ||
|
||
export const initialState: FlowFiltersState = { | ||
flowViewMode: 'control', | ||
}; | ||
|
||
export const FLOW_VIEW_MODES = [ | ||
'control', | ||
'spec', | ||
'monitoring', | ||
'logs', | ||
'layout', | ||
'graph', | ||
] as const; | ||
|
||
export type FlowViewMode = (typeof FLOW_VIEW_MODES)[number]; | ||
|
||
export const filtersSlice = createSlice({ | ||
name: 'flow.filters', | ||
initialState, | ||
reducers: { | ||
setFlowViewMode(state, {payload}: PayloadAction<FlowViewMode>) { | ||
state.flowViewMode = payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const {setFlowViewMode} = filtersSlice.actions; | ||
export const filters = filtersSlice.reducer; |
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,5 @@ | ||
import {combineReducers} from 'redux'; | ||
|
||
import {filters} from './filters'; | ||
|
||
export const flow = combineReducers({filters}); |
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 produce from 'immer'; | ||
import {RootState} from '..'; | ||
import {updateIfChanged} from '../../../utils/utils'; | ||
import {LocationParameters} from '../../../store/location'; | ||
|
||
import {initialState as filtersInitialState} from './filters'; | ||
|
||
export const mapNodeFlowParams: LocationParameters = { | ||
flowMode: { | ||
stateKey: 'flow.filters.flowViewMode', | ||
initialState: filtersInitialState.flowViewMode, | ||
}, | ||
}; | ||
|
||
export function getNavigationMapNodeFlowPreparedState( | ||
state: RootState, | ||
{query}: {query: RootState}, | ||
) { | ||
return produce(state, (draft: RootState) => { | ||
updateIfChanged(draft.flow.filters, 'flowViewMode', query.flow.filters.flowViewMode); | ||
}); | ||
} |
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,3 @@ | ||
import {RootState} from '../../../store/reducers'; | ||
|
||
export const getFlowViewMode = (state: RootState) => state.flow.filters.flowViewMode; |
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