-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into auto-updater
- Loading branch information
Showing
94 changed files
with
1,356 additions
and
3,310 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,27 @@ | ||
import {PropsWithChildren, forwardRef, useMemo, useState} from 'react'; | ||
|
||
import {Button, ButtonProps} from 'antd'; | ||
|
||
type Props = PropsWithChildren< | ||
ButtonProps & { | ||
hoverProps?: ButtonProps; | ||
} | ||
>; | ||
|
||
const HoverableButton = forwardRef<HTMLButtonElement, Props>((props, ref) => { | ||
const {hoverProps = {}, children, ...buttonProps} = props; | ||
const [isHovered, setIsHovered] = useState(false); | ||
|
||
const thisProps = useMemo( | ||
() => (isHovered ? {...buttonProps, ...hoverProps} : buttonProps), | ||
[isHovered, buttonProps, hoverProps] | ||
); | ||
|
||
return ( | ||
<Button ref={ref} {...thisProps} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}> | ||
{children} | ||
</Button> | ||
); | ||
}); | ||
|
||
export default HoverableButton; |
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 @@ | ||
export {default} from './HoverableButton'; |
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
49 changes: 49 additions & 0 deletions
49
src/components/organisms/ExplorerPane/DryRunsPane/CommandRenderer.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,49 @@ | ||
import {memo, useState} from 'react'; | ||
|
||
import {useAppSelector} from '@redux/hooks'; | ||
|
||
import {CommandPreview} from '@shared/models/preview'; | ||
|
||
import {usePreviewTrigger} from './usePreviewTrigger'; | ||
|
||
import * as S from './styled'; | ||
|
||
type IProps = { | ||
id: string; | ||
}; | ||
|
||
const CommandRenderer: React.FC<IProps> = props => { | ||
const {id} = props; | ||
|
||
const command = useAppSelector(state => state.config.projectConfig?.savedCommandMap?.[id]); | ||
|
||
const isPreviewed = useAppSelector( | ||
state => state.main.preview?.type === 'command' && state.main.preview.commandId === command?.id | ||
); | ||
const thisPreview: CommandPreview = {type: 'command', commandId: id}; | ||
const {isOptimisticLoading, triggerPreview, renderPreviewControls} = usePreviewTrigger(thisPreview); | ||
const mightBePreview = isPreviewed || isOptimisticLoading; | ||
|
||
const [isHovered, setIsHovered] = useState<boolean>(false); | ||
|
||
if (!command) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<S.ItemContainer | ||
indent={22} | ||
isHovered={isHovered} | ||
isPreviewed={mightBePreview} | ||
onMouseEnter={() => setIsHovered(true)} | ||
onMouseLeave={() => setIsHovered(false)} | ||
onClick={triggerPreview} | ||
> | ||
<S.ItemName isPreviewed={mightBePreview}>{command.label}</S.ItemName> | ||
{isOptimisticLoading && <S.ReloadIcon spin />} | ||
{renderPreviewControls()} | ||
</S.ItemContainer> | ||
); | ||
}; | ||
|
||
export default memo(CommandRenderer); |
Oops, something went wrong.