console: add regex to highlight item in data tab nav tree

Adding regex expression to test `view`, `table` and `function` routes.
Fixes no highlight issue when clicking on functions in the data tab navigation tree.

GitOrigin-RevId: f278998ec1c98c98e0bfc9cd72d63d673cd74012
This commit is contained in:
Vijay Prasanna 2021-05-26 15:12:37 +05:30 committed by hasura-bot
parent 06bfe650f0
commit 7dbee42f64

View File

@ -38,13 +38,10 @@ const LeafItemsView: React.FC<LeafItemsViewProps> = ({
pathname,
}) => {
const [isOpen, setIsOpen] = useState(false);
const isActive =
pathname.includes(
`/data/${currentSource}/schema/${currentSchema}/tables/${item.name}/`
) ||
pathname.includes(
`/data/${currentSource}/schema/${currentSchema}/views/${item.name}/`
);
const regex = new RegExp(
`\\/data\\/${currentSource}\\/schema\\/${currentSchema}\\/(tables|functions|views)\\/${item.name}\\/`
);
const isActive = regex.test(pathname);
const isView = item.type === 'view';