Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] DRC-980 Show tooltip on node selector input field #561

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 61 additions & 22 deletions js/src/components/lineage/LineageViewTopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import {
Spacer,
Text,
Tooltip,
VStack,
Code,
Link,
} from "@chakra-ui/react";

import { FiPackage } from "react-icons/fi";
Expand All @@ -33,6 +36,29 @@ import { findByRunType } from "../run/registry";
import { ChevronDownIcon } from "@chakra-ui/icons";
import { trackHistoryAction } from "@/lib/api/track";
import { DisableTooltipMessages } from "@/constants/tooltipMessage";
import { useRecceServerFlag } from "@/lib/hooks/useRecceServerFlag";

const SelectFilterTooltip = () => {
return (
<VStack align={"start"} spacing={0}>
<Text fontSize="10pt" color={"gray.500"} pb={1}>
Select nodes by dbt node selector syntax
</Text>
<Text fontSize="8pt">
<Code fontSize={"8pt"}>model_name</Code> Select a node
</Text>
<Text fontSize="8pt">
<Code fontSize={"8pt"}>model_name+</Code> Select downstream nodes
</Text>
<Text fontSize="8pt">
<Code fontSize={"8pt"}>+model_name</Code> Select upstream nodes
</Text>
<Text fontSize="8pt">
<Code fontSize={"8pt"}>model*</Code> Select by wildcard
</Text>
</VStack>
);
};

const HistoryToggle = () => {
const { isHistoryOpen, showHistory, closeHistory } = useRecceActionContext();
Expand Down Expand Up @@ -215,8 +241,10 @@ const NodeSelectionInput = (props: {
value: string;
onChange: (value: string) => void;
isDisabled?: boolean;
tooltipComponent?: React.ReactNode;
}) => {
const [inputValue, setInputValue] = useState(props.value);
const { data: flags } = useRecceServerFlag();
const inputRef = useRef(null);

useEffect(() => {
Expand All @@ -226,29 +254,39 @@ const NodeSelectionInput = (props: {
}, [props.value]);

return (
<Input
ref={inputRef}
height="24px"
fontSize="10pt"
placeholder="with selectors"
isDisabled={props.isDisabled}
value={inputValue}
onChange={(event) => {
setInputValue(event.target.value);
}}
onKeyUp={(event) => {
if (event.key === "Enter") {
props.onChange(inputValue);
} else if (event.key === "Escape") {
event.preventDefault();
setInputValue(props.value);
if (inputRef.current) {
(inputRef.current as any).blur();
<Tooltip
label={props.tooltipComponent}
placement="bottom-start"
defaultIsOpen={true}
color={"black"}
backgroundColor={"white"}
closeOnClick={false}
isDisabled={!flags?.single_env_onboarding}
>
<Input
ref={inputRef}
height="24px"
fontSize="10pt"
placeholder="with selectors"
isDisabled={props.isDisabled}
value={inputValue}
onChange={(event) => {
setInputValue(event.target.value);
}}
onKeyUp={(event) => {
if (event.key === "Enter") {
props.onChange(inputValue);
} else if (event.key === "Escape") {
event.preventDefault();
setInputValue(props.value);
if (inputRef.current) {
(inputRef.current as any).blur();
}
}
}
}}
onBlur={() => setInputValue(props.value)}
/>
}}
onBlur={() => setInputValue(props.value)}
/>
</Tooltip>
);
};

Expand All @@ -265,6 +303,7 @@ const SelectFilter = ({ isDisabled }: { isDisabled: boolean }) => {
select: value ? value : undefined,
});
}}
tooltipComponent={<SelectFilterTooltip />}
/>
);
};
Expand Down
Loading