mirror of https://github.com/buster-so/buster.git
pass through dataset overview
This commit is contained in:
parent
bca5055ca9
commit
6ba6fd87dd
|
@ -48,7 +48,7 @@ DatasetsHeaderOptions.displayName = 'DatasetsHeaderOptions';
|
|||
const keyToRoute = (datasetId: string, key: DatasetApps) => {
|
||||
const record: Record<DatasetApps, string> = {
|
||||
[DatasetApps.PERMISSIONS]: createBusterRoute({
|
||||
route: BusterRoutes.APP_DATASETS_ID_PERMISSIONS,
|
||||
route: BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW,
|
||||
datasetId
|
||||
}),
|
||||
[DatasetApps.OVERVIEW]: createBusterRoute({
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<string, PermissionApps> = {
|
||||
[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>(PermissionApps.OVERVIEW);
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedApp(routeToApp[currentRoute]);
|
||||
setSelectedApp(routeToApp[currentRoute] || PermissionApps.OVERVIEW);
|
||||
}, [currentRoute]);
|
||||
|
||||
console.log(currentRoute, routeToApp[currentRoute]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<PermissionAppSegments selectedApp={selectedApp} datasetId={datasetId as string} />
|
||||
|
|
|
@ -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
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ const UserInfo: React.FC<{ user: OrganizationUser }> = ({ user }) => {
|
|||
<div className="flex items-center space-x-4">
|
||||
<BusterUserAvatar size={48} name={user.name} />
|
||||
<div className="flex flex-col">
|
||||
<Title level={3}>{user.name}</Title>
|
||||
<Title level={4}>{user.name}</Title>
|
||||
<Text size="sm" type="secondary">
|
||||
{user.email}
|
||||
</Text>
|
||||
|
|
|
@ -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 <BackButton text={text} linkUrl={route} />;
|
||||
};
|
|
@ -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 (
|
||||
<div className="flex flex-col space-y-5 px-12 py-12">
|
||||
<BackButton
|
||||
text="Users"
|
||||
linkUrl={createBusterRoute({ route: BusterRoutes.APP_SETTINGS_USERS })}
|
||||
/>
|
||||
<UsersBackButton />
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -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
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { useDebounceFn, useMemoizedFn } from 'ahooks';
|
||||
import { useEffect, useState, useTransition } from 'react';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
|
||||
interface UseDebounceSearchProps<T> {
|
||||
items: T[];
|
||||
|
@ -45,7 +46,9 @@ export const useDebounceSearch = <T>({
|
|||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEqual(items, filteredItems)) {
|
||||
setFilteredItems(items);
|
||||
}
|
||||
}, [items]);
|
||||
|
||||
return {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue