-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Network): add peer role filter (#1724)
- Loading branch information
1 parent
e86c845
commit 1285049
Showing
12 changed files
with
135 additions
and
12 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
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,24 @@ | ||
import {RadioButton} from '@gravity-ui/uikit'; | ||
|
||
import type {NodesPeerRole} from '../../../types/api/nodes'; | ||
|
||
import {NODES_PEER_ROLES, NODES_PEER_ROLES_TITLES} from './utils'; | ||
|
||
interface PeerRoleFilterProps { | ||
value?: NodesPeerRole; | ||
onChange: (value: NodesPeerRole) => void; | ||
} | ||
|
||
export function PeerRoleFilter({value = 'database', onChange}: PeerRoleFilterProps) { | ||
return ( | ||
<RadioButton value={value} onUpdate={onChange}> | ||
{NODES_PEER_ROLES.map((role) => { | ||
return ( | ||
<RadioButton.Option key={role} value={role}> | ||
{NODES_PEER_ROLES_TITLES[role]} | ||
</RadioButton.Option> | ||
); | ||
})} | ||
</RadioButton> | ||
); | ||
} |
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,23 @@ | ||
import type {NodesPeerRole} from '../../../types/api/nodes'; | ||
import i18n from '../i18n'; | ||
|
||
export const NODES_PEER_ROLES: NodesPeerRole[] = ['database', 'static', 'other', 'any']; | ||
|
||
export const NODES_PEER_ROLES_TITLES: Record<NodesPeerRole, string> = { | ||
get database() { | ||
return i18n('database'); | ||
}, | ||
get static() { | ||
return i18n('static'); | ||
}, | ||
get other() { | ||
return i18n('other'); | ||
}, | ||
get any() { | ||
return i18n('any'); | ||
}, | ||
}; | ||
|
||
export function parseNodesPeerRoleFilter(paramToParse: unknown): NodesPeerRole | undefined { | ||
return NODES_PEER_ROLES.find((peerRoleParam) => peerRoleParam === paramToParse); | ||
} |
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
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
Oops, something went wrong.