-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add state provider status popup (#2217)
- Loading branch information
1 parent
e0cce3e
commit e8455a1
Showing
8 changed files
with
129 additions
and
5 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import type { GetFailoverParamsQuery } from 'src/generated/graphql-typing-ts'; | ||
import type { GetFailoverParamsQuery, StateProviderStatus } from 'src/generated/graphql-typing-ts'; | ||
import type { Maybe } from 'src/models'; | ||
|
||
export type Failover = Maybe<GetFailoverParamsQuery>; | ||
export type { StateProviderStatus }; |
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
68 changes: 68 additions & 0 deletions
68
...FailoverModal/components/FailoverModalForm/FailoverModalFormStateProviderStatusAction.tsx
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,68 @@ | ||
/* eslint-disable @typescript-eslint/ban-ts-comment */ | ||
import React, { useCallback } from 'react'; | ||
import { css } from '@emotion/css'; | ||
import { useEvent, useStore } from 'effector-react'; | ||
// @ts-ignore | ||
import { Button, IconFailed, IconSuccess, Text, UriLabel, withPopover } from '@tarantool.io/ui-kit'; | ||
|
||
import { cluster } from 'src/models'; | ||
|
||
import { FailoverStateProvider } from './FailoverModalForm.types'; | ||
|
||
export const styles = { | ||
root: css` | ||
display: flex; | ||
flex-direction: column; | ||
flex-wrap: nowrap; | ||
gap: 4px; | ||
`, | ||
header: css` | ||
display: block; | ||
margin-bottom: 8px; | ||
`, | ||
}; | ||
|
||
const PopoverRoot = withPopover(Button); | ||
const { $stateProviderStatus, stateProviderStatusGetEvent, getStateProviderStatusFx } = cluster.failover; | ||
|
||
export const FailoverModalFormStateProviderStatusAction = ({ | ||
stateProvider, | ||
}: { | ||
stateProvider: FailoverStateProvider; | ||
}) => { | ||
const stateProviderStatusPending = useStore(getStateProviderStatusFx.pending); | ||
const stateProviderStatus = useStore($stateProviderStatus); | ||
const event = useEvent(stateProviderStatusGetEvent); | ||
const handleClick = useCallback(() => { | ||
event(); | ||
}, [event]); | ||
|
||
return ( | ||
<PopoverRoot | ||
size="xs" | ||
type="button" | ||
onClick={handleClick} | ||
loading={stateProviderStatusPending} | ||
disabled={stateProviderStatusPending} | ||
popoverContent={ | ||
stateProviderStatusPending || !stateProviderStatus || stateProviderStatus.length === 0 ? undefined : ( | ||
<div className={styles.root}> | ||
<Text className={styles.header}> | ||
{stateProvider === 'etcd2' ? 'etcd' : stateProvider} state provider status: | ||
</Text> | ||
{stateProviderStatus.map((value, index) => ( | ||
<UriLabel | ||
key={index} | ||
uri={value.uri} | ||
title={value.status ? 'status: true' : 'status: false'} | ||
icon={value.status ? IconSuccess : IconFailed} | ||
/> | ||
))} | ||
</div> | ||
) | ||
} | ||
> | ||
status | ||
</PopoverRoot> | ||
); | ||
}; |
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