diff --git a/web/src/app/app/datasets/[datasetId]/_DatasetsIndividualHeader/DatasetHeaderOptions.tsx b/web/src/app/app/datasets/[datasetId]/_DatasetsIndividualHeader/DatasetHeaderOptions.tsx index 1c449749a..472ef3630 100644 --- a/web/src/app/app/datasets/[datasetId]/_DatasetsIndividualHeader/DatasetHeaderOptions.tsx +++ b/web/src/app/app/datasets/[datasetId]/_DatasetsIndividualHeader/DatasetHeaderOptions.tsx @@ -48,7 +48,7 @@ DatasetsHeaderOptions.displayName = 'DatasetsHeaderOptions'; const keyToRoute = (datasetId: string, key: DatasetApps) => { const record: Record = { [DatasetApps.PERMISSIONS]: createBusterRoute({ - route: BusterRoutes.APP_DATASETS_ID_PERMISSIONS, + route: BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW, datasetId }), [DatasetApps.OVERVIEW]: createBusterRoute({ diff --git a/web/src/app/app/datasets/[datasetId]/permissions/PermissionAppSegments.tsx b/web/src/app/app/datasets/[datasetId]/permissions/PermissionAppSegments.tsx index 78e3c3292..676422303 100644 --- a/web/src/app/app/datasets/[datasetId]/permissions/PermissionAppSegments.tsx +++ b/web/src/app/app/datasets/[datasetId]/permissions/PermissionAppSegments.tsx @@ -1,9 +1,9 @@ 'use client'; -import React, { useEffect, useRef, useState } from 'react'; +import React, { useRef } from 'react'; import { AppSegmented } from '@/components'; import { PermissionApps } from './config'; -import { useMemoizedFn, useMount, useSet } from 'ahooks'; +import { useMemoizedFn, useSet } from 'ahooks'; import { SegmentedValue } from 'antd/es/segmented'; import { Divider } from 'antd'; import { diff --git a/web/src/app/app/datasets/[datasetId]/permissions/PermissionsAppContainer.tsx b/web/src/app/app/datasets/[datasetId]/permissions/PermissionsAppContainer.tsx index 73975618a..8243fce66 100644 --- a/web/src/app/app/datasets/[datasetId]/permissions/PermissionsAppContainer.tsx +++ b/web/src/app/app/datasets/[datasetId]/permissions/PermissionsAppContainer.tsx @@ -2,19 +2,11 @@ import React, { useEffect, useState } from 'react'; import { PermissionAppSegments } from './PermissionAppSegments'; -import { AnimatePresence, motion } from 'framer-motion'; import { useParams } from 'next/navigation'; import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; import { PermissionApps } from './config'; import { BusterRoutes } from '@/routes'; -const memoizedAnimation = { - initial: { opacity: 0 }, - animate: { opacity: 1 }, - exit: { opacity: 0 }, - transition: { duration: 0.125 } -}; - const routeToApp: Record = { [BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: PermissionApps.OVERVIEW, [BusterRoutes.APP_DATASETS_ID_PERMISSIONS_PERMISSION_GROUPS]: PermissionApps.PERMISSION_GROUPS, @@ -30,9 +22,11 @@ export const PermissionsAppContainer: React.FC<{ const [selectedApp, setSelectedApp] = useState(PermissionApps.OVERVIEW); useEffect(() => { - setSelectedApp(routeToApp[currentRoute]); + setSelectedApp(routeToApp[currentRoute] || PermissionApps.OVERVIEW); }, [currentRoute]); + console.log(currentRoute, routeToApp[currentRoute]); + return ( <> diff --git a/web/src/app/app/datasets/[datasetId]/permissions/page.tsx b/web/src/app/app/datasets/[datasetId]/permissions/page.tsx index 814c22a10..665ada424 100644 --- a/web/src/app/app/datasets/[datasetId]/permissions/page.tsx +++ b/web/src/app/app/datasets/[datasetId]/permissions/page.tsx @@ -1,8 +1,11 @@ -import { redirect } from 'next/navigation'; +import { permanentRedirect } from 'next/navigation'; import { BusterRoutes, createBusterRoute } from '@/routes'; export default async function Page({ params: { datasetId } }: { params: { datasetId: string } }) { - return redirect( - createBusterRoute({ route: BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW, datasetId }) + return permanentRedirect( + createBusterRoute({ + route: BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW, + datasetId + }) ); } diff --git a/web/src/app/app/settings/users/[userId]/UserDatasetListContainer.tsx b/web/src/app/app/settings/users/[userId]/UserDatasetListContainer.tsx index 3b3c47ff9..6040256fa 100644 --- a/web/src/app/app/settings/users/[userId]/UserDatasetListContainer.tsx +++ b/web/src/app/app/settings/users/[userId]/UserDatasetListContainer.tsx @@ -5,7 +5,6 @@ import { BusterListRowItem, InfiniteListContainer } from '@/components/list'; -import { PermissionLineageBreadcrumb } from '@/app/app/_components/PermissionComponents'; import { DatasetPermissionOverviewUser } from '@/api/buster-rest'; import { Text } from '@/components/text'; diff --git a/web/src/app/app/settings/users/[userId]/UserHeader.tsx b/web/src/app/app/settings/users/[userId]/UserHeader.tsx index 9e3a5b4e4..2c84ec925 100644 --- a/web/src/app/app/settings/users/[userId]/UserHeader.tsx +++ b/web/src/app/app/settings/users/[userId]/UserHeader.tsx @@ -19,7 +19,7 @@ const UserInfo: React.FC<{ user: OrganizationUser }> = ({ user }) => {
- {user.name} + {user.name} {user.email} diff --git a/web/src/app/app/settings/users/[userId]/UsersBackButton.tsx b/web/src/app/app/settings/users/[userId]/UsersBackButton.tsx new file mode 100644 index 000000000..940f4a228 --- /dev/null +++ b/web/src/app/app/settings/users/[userId]/UsersBackButton.tsx @@ -0,0 +1,32 @@ +'use client'; + +import { BackButton } from '@/components'; +import { useAppLayoutContextSelector } from '@/context/BusterAppLayout'; +import { createBusterRoute, BusterRoutes } from '@/routes'; +import { useMemo } from 'react'; + +export const UsersBackButton = ({}: {}) => { + const previousPath = useAppLayoutContextSelector((state) => state.previousPath); + const previousRoute = useAppLayoutContextSelector((state) => state.previousRoute); + + const { + route, + text + }: { + route: string; + text: string; + } = useMemo(() => { + // if (previousPath) { + // return { + // route: previousPath, + // text: 'Users' + // }; + // } + return { + route: createBusterRoute({ route: BusterRoutes.APP_SETTINGS_USERS }), + text: 'Users' + }; + }, [previousRoute]); + + return ; +}; diff --git a/web/src/app/app/settings/users/[userId]/layout.tsx b/web/src/app/app/settings/users/[userId]/layout.tsx index 1ea62844d..81eb41163 100644 --- a/web/src/app/app/settings/users/[userId]/layout.tsx +++ b/web/src/app/app/settings/users/[userId]/layout.tsx @@ -1,14 +1,10 @@ -import { BackButton } from '@/components/buttons/BackButton'; -import { createBusterRoute, BusterRoutes } from '@/routes'; import React from 'react'; +import { UsersBackButton } from './UsersBackButton'; export default function Layout({ children }: { children: React.ReactNode }) { return (
- + {children}
); diff --git a/web/src/context/BusterAppLayout/useAppLayout.tsx b/web/src/context/BusterAppLayout/useAppLayout.tsx index 84e5777e6..a3a45e260 100644 --- a/web/src/context/BusterAppLayout/useAppLayout.tsx +++ b/web/src/context/BusterAppLayout/useAppLayout.tsx @@ -2,7 +2,7 @@ import { BusterRoutesWithArgsRoute, createBusterRoute } from '@/routes/busterRoutes'; import { pathNameToRoute } from '@/routes/helpers'; -import { useMemoizedFn } from 'ahooks'; +import { useMemoizedFn, usePrevious } from 'ahooks'; import { useRouter, usePathname, useSelectedLayoutSegment, useParams } from 'next/navigation'; import React, { PropsWithChildren } from 'react'; import { @@ -17,6 +17,8 @@ export const useAppLayout = () => { const params = useParams(); const currentSegment = useSelectedLayoutSegment(); const currentRoute = pathNameToRoute(pathname, params); + const previousRoute = usePrevious(currentRoute); + const previousPath = usePrevious(pathname); const [openThreadsModal, setOpenThreadsModal] = React.useState(false); const [openInviteModal, setOpenInviteModal] = React.useState(false); const [openSupportModal, setOpenSupportModal] = React.useState(false); @@ -51,7 +53,9 @@ export const useAppLayout = () => { openInviteModal, onChangePage, pathname, + previousPath, openSupportModal, + previousRoute, onToggleSupportModal }; }; diff --git a/web/src/hooks/useDebounceSearch.ts b/web/src/hooks/useDebounceSearch.ts index 08f39979d..a37ff935b 100644 --- a/web/src/hooks/useDebounceSearch.ts +++ b/web/src/hooks/useDebounceSearch.ts @@ -1,5 +1,6 @@ import { useDebounceFn, useMemoizedFn } from 'ahooks'; import { useEffect, useState, useTransition } from 'react'; +import isEqual from 'lodash/isEqual'; interface UseDebounceSearchProps { items: T[]; @@ -45,7 +46,9 @@ export const useDebounceSearch = ({ }); useEffect(() => { - setFilteredItems(items); + if (!isEqual(items, filteredItems)) { + setFilteredItems(items); + } }, [items]); return { diff --git a/web/src/routes/busterRoutes/busterAppRoutes.ts b/web/src/routes/busterRoutes/busterAppRoutes.ts index 14cefce26..c69829757 100644 --- a/web/src/routes/busterRoutes/busterAppRoutes.ts +++ b/web/src/routes/busterRoutes/busterAppRoutes.ts @@ -13,7 +13,6 @@ export enum BusterAppRoutes { APP_DATASETS = '/app/datasets', APP_DATASETS_ID = '/app/datasets/:datasetId', APP_DATASETS_ID_OVERVIEW = '/app/datasets/:datasetId/overview', - APP_DATASETS_ID_PERMISSIONS = '/app/datasets/:datasetId/permissions', APP_DATASETS_ID_PERMISSIONS_OVERVIEW = '/app/datasets/:datasetId/permissions/overview', APP_DATASETS_ID_PERMISSIONS_PERMISSION_GROUPS = '/app/datasets/:datasetId/permissions/permission-groups', APP_DATASETS_ID_PERMISSIONS_USERS = '/app/datasets/:datasetId/permissions/users', @@ -103,10 +102,6 @@ export type BusterAppRoutesWithArgs = { route: BusterAppRoutes.APP_DATASETS_ID_OVERVIEW; datasetId: string; }; - [BusterAppRoutes.APP_DATASETS_ID_PERMISSIONS]: { - route: BusterAppRoutes.APP_DATASETS_ID_PERMISSIONS; - datasetId: string; - }; [BusterAppRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: { route: BusterAppRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW; datasetId: string; diff --git a/web/src/routes/helpers.tsx b/web/src/routes/helpers.tsx index 3553ad6e0..53f73cad8 100644 --- a/web/src/routes/helpers.tsx +++ b/web/src/routes/helpers.tsx @@ -11,10 +11,11 @@ export const pathNameToRoute = (pathName: string, params: any): BusterRoutes => [BusterRoutes.APP_DASHBOARD_ID]: BusterRoutes.APP_DASHBOARDS, [BusterRoutes.APP_COLLECTIONS_ID]: BusterRoutes.APP_COLLECTIONS, [BusterRoutes.APP_DATASETS_ID]: BusterRoutes.APP_DATASETS, - [BusterRoutes.APP_DATASETS_ID_PERMISSIONS]: BusterRoutes.APP_DATASETS, + [BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: BusterRoutes.APP_DATASETS, [BusterRoutes.APP_DATASETS_ID_OVERVIEW]: BusterRoutes.APP_DATASETS, [BusterRoutes.APP_DATASETS_ID_EDITOR]: BusterRoutes.APP_DATASETS, - [BusterRoutes.APP_TERMS_ID]: BusterRoutes.APP_TERMS + [BusterRoutes.APP_TERMS_ID]: BusterRoutes.APP_TERMS, + [BusterRoutes.APP_SETTINGS_USERS_ID]: BusterRoutes.APP_SETTINGS_USERS }; if (route && paramRoutesToParent[route as string]) { return paramRoutesToParent[route as string];