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 keyToRoute = (datasetId: string, key: DatasetApps) => {
|
||||||
const record: Record<DatasetApps, string> = {
|
const record: Record<DatasetApps, string> = {
|
||||||
[DatasetApps.PERMISSIONS]: createBusterRoute({
|
[DatasetApps.PERMISSIONS]: createBusterRoute({
|
||||||
route: BusterRoutes.APP_DATASETS_ID_PERMISSIONS,
|
route: BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW,
|
||||||
datasetId
|
datasetId
|
||||||
}),
|
}),
|
||||||
[DatasetApps.OVERVIEW]: createBusterRoute({
|
[DatasetApps.OVERVIEW]: createBusterRoute({
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useRef } from 'react';
|
||||||
import { AppSegmented } from '@/components';
|
import { AppSegmented } from '@/components';
|
||||||
import { PermissionApps } from './config';
|
import { PermissionApps } from './config';
|
||||||
import { useMemoizedFn, useMount, useSet } from 'ahooks';
|
import { useMemoizedFn, useSet } from 'ahooks';
|
||||||
import { SegmentedValue } from 'antd/es/segmented';
|
import { SegmentedValue } from 'antd/es/segmented';
|
||||||
import { Divider } from 'antd';
|
import { Divider } from 'antd';
|
||||||
import {
|
import {
|
||||||
|
|
|
@ -2,19 +2,11 @@
|
||||||
|
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { PermissionAppSegments } from './PermissionAppSegments';
|
import { PermissionAppSegments } from './PermissionAppSegments';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
|
||||||
import { useParams } from 'next/navigation';
|
import { useParams } from 'next/navigation';
|
||||||
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
|
import { useAppLayoutContextSelector } from '@/context/BusterAppLayout';
|
||||||
import { PermissionApps } from './config';
|
import { PermissionApps } from './config';
|
||||||
import { BusterRoutes } from '@/routes';
|
import { BusterRoutes } from '@/routes';
|
||||||
|
|
||||||
const memoizedAnimation = {
|
|
||||||
initial: { opacity: 0 },
|
|
||||||
animate: { opacity: 1 },
|
|
||||||
exit: { opacity: 0 },
|
|
||||||
transition: { duration: 0.125 }
|
|
||||||
};
|
|
||||||
|
|
||||||
const routeToApp: Record<string, PermissionApps> = {
|
const routeToApp: Record<string, PermissionApps> = {
|
||||||
[BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: PermissionApps.OVERVIEW,
|
[BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: PermissionApps.OVERVIEW,
|
||||||
[BusterRoutes.APP_DATASETS_ID_PERMISSIONS_PERMISSION_GROUPS]: PermissionApps.PERMISSION_GROUPS,
|
[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);
|
const [selectedApp, setSelectedApp] = useState<PermissionApps>(PermissionApps.OVERVIEW);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelectedApp(routeToApp[currentRoute]);
|
setSelectedApp(routeToApp[currentRoute] || PermissionApps.OVERVIEW);
|
||||||
}, [currentRoute]);
|
}, [currentRoute]);
|
||||||
|
|
||||||
|
console.log(currentRoute, routeToApp[currentRoute]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PermissionAppSegments selectedApp={selectedApp} datasetId={datasetId as string} />
|
<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';
|
import { BusterRoutes, createBusterRoute } from '@/routes';
|
||||||
|
|
||||||
export default async function Page({ params: { datasetId } }: { params: { datasetId: string } }) {
|
export default async function Page({ params: { datasetId } }: { params: { datasetId: string } }) {
|
||||||
return redirect(
|
return permanentRedirect(
|
||||||
createBusterRoute({ route: BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW, datasetId })
|
createBusterRoute({
|
||||||
|
route: BusterRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW,
|
||||||
|
datasetId
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import {
|
||||||
BusterListRowItem,
|
BusterListRowItem,
|
||||||
InfiniteListContainer
|
InfiniteListContainer
|
||||||
} from '@/components/list';
|
} from '@/components/list';
|
||||||
import { PermissionLineageBreadcrumb } from '@/app/app/_components/PermissionComponents';
|
|
||||||
import { DatasetPermissionOverviewUser } from '@/api/buster-rest';
|
import { DatasetPermissionOverviewUser } from '@/api/buster-rest';
|
||||||
import { Text } from '@/components/text';
|
import { Text } from '@/components/text';
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ const UserInfo: React.FC<{ user: OrganizationUser }> = ({ user }) => {
|
||||||
<div className="flex items-center space-x-4">
|
<div className="flex items-center space-x-4">
|
||||||
<BusterUserAvatar size={48} name={user.name} />
|
<BusterUserAvatar size={48} name={user.name} />
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<Title level={3}>{user.name}</Title>
|
<Title level={4}>{user.name}</Title>
|
||||||
<Text size="sm" type="secondary">
|
<Text size="sm" type="secondary">
|
||||||
{user.email}
|
{user.email}
|
||||||
</Text>
|
</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 React from 'react';
|
||||||
|
import { UsersBackButton } from './UsersBackButton';
|
||||||
|
|
||||||
export default function Layout({ children }: { children: React.ReactNode }) {
|
export default function Layout({ children }: { children: React.ReactNode }) {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col space-y-5 px-12 py-12">
|
<div className="flex flex-col space-y-5 px-12 py-12">
|
||||||
<BackButton
|
<UsersBackButton />
|
||||||
text="Users"
|
|
||||||
linkUrl={createBusterRoute({ route: BusterRoutes.APP_SETTINGS_USERS })}
|
|
||||||
/>
|
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import { BusterRoutesWithArgsRoute, createBusterRoute } from '@/routes/busterRoutes';
|
import { BusterRoutesWithArgsRoute, createBusterRoute } from '@/routes/busterRoutes';
|
||||||
import { pathNameToRoute } from '@/routes/helpers';
|
import { pathNameToRoute } from '@/routes/helpers';
|
||||||
import { useMemoizedFn } from 'ahooks';
|
import { useMemoizedFn, usePrevious } from 'ahooks';
|
||||||
import { useRouter, usePathname, useSelectedLayoutSegment, useParams } from 'next/navigation';
|
import { useRouter, usePathname, useSelectedLayoutSegment, useParams } from 'next/navigation';
|
||||||
import React, { PropsWithChildren } from 'react';
|
import React, { PropsWithChildren } from 'react';
|
||||||
import {
|
import {
|
||||||
|
@ -17,6 +17,8 @@ export const useAppLayout = () => {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const currentSegment = useSelectedLayoutSegment();
|
const currentSegment = useSelectedLayoutSegment();
|
||||||
const currentRoute = pathNameToRoute(pathname, params);
|
const currentRoute = pathNameToRoute(pathname, params);
|
||||||
|
const previousRoute = usePrevious(currentRoute);
|
||||||
|
const previousPath = usePrevious(pathname);
|
||||||
const [openThreadsModal, setOpenThreadsModal] = React.useState(false);
|
const [openThreadsModal, setOpenThreadsModal] = React.useState(false);
|
||||||
const [openInviteModal, setOpenInviteModal] = React.useState(false);
|
const [openInviteModal, setOpenInviteModal] = React.useState(false);
|
||||||
const [openSupportModal, setOpenSupportModal] = React.useState(false);
|
const [openSupportModal, setOpenSupportModal] = React.useState(false);
|
||||||
|
@ -51,7 +53,9 @@ export const useAppLayout = () => {
|
||||||
openInviteModal,
|
openInviteModal,
|
||||||
onChangePage,
|
onChangePage,
|
||||||
pathname,
|
pathname,
|
||||||
|
previousPath,
|
||||||
openSupportModal,
|
openSupportModal,
|
||||||
|
previousRoute,
|
||||||
onToggleSupportModal
|
onToggleSupportModal
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { useDebounceFn, useMemoizedFn } from 'ahooks';
|
import { useDebounceFn, useMemoizedFn } from 'ahooks';
|
||||||
import { useEffect, useState, useTransition } from 'react';
|
import { useEffect, useState, useTransition } from 'react';
|
||||||
|
import isEqual from 'lodash/isEqual';
|
||||||
|
|
||||||
interface UseDebounceSearchProps<T> {
|
interface UseDebounceSearchProps<T> {
|
||||||
items: T[];
|
items: T[];
|
||||||
|
@ -45,7 +46,9 @@ export const useDebounceSearch = <T>({
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!isEqual(items, filteredItems)) {
|
||||||
setFilteredItems(items);
|
setFilteredItems(items);
|
||||||
|
}
|
||||||
}, [items]);
|
}, [items]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -13,7 +13,6 @@ export enum BusterAppRoutes {
|
||||||
APP_DATASETS = '/app/datasets',
|
APP_DATASETS = '/app/datasets',
|
||||||
APP_DATASETS_ID = '/app/datasets/:datasetId',
|
APP_DATASETS_ID = '/app/datasets/:datasetId',
|
||||||
APP_DATASETS_ID_OVERVIEW = '/app/datasets/:datasetId/overview',
|
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_OVERVIEW = '/app/datasets/:datasetId/permissions/overview',
|
||||||
APP_DATASETS_ID_PERMISSIONS_PERMISSION_GROUPS = '/app/datasets/:datasetId/permissions/permission-groups',
|
APP_DATASETS_ID_PERMISSIONS_PERMISSION_GROUPS = '/app/datasets/:datasetId/permissions/permission-groups',
|
||||||
APP_DATASETS_ID_PERMISSIONS_USERS = '/app/datasets/:datasetId/permissions/users',
|
APP_DATASETS_ID_PERMISSIONS_USERS = '/app/datasets/:datasetId/permissions/users',
|
||||||
|
@ -103,10 +102,6 @@ export type BusterAppRoutesWithArgs = {
|
||||||
route: BusterAppRoutes.APP_DATASETS_ID_OVERVIEW;
|
route: BusterAppRoutes.APP_DATASETS_ID_OVERVIEW;
|
||||||
datasetId: string;
|
datasetId: string;
|
||||||
};
|
};
|
||||||
[BusterAppRoutes.APP_DATASETS_ID_PERMISSIONS]: {
|
|
||||||
route: BusterAppRoutes.APP_DATASETS_ID_PERMISSIONS;
|
|
||||||
datasetId: string;
|
|
||||||
};
|
|
||||||
[BusterAppRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: {
|
[BusterAppRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW]: {
|
||||||
route: BusterAppRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW;
|
route: BusterAppRoutes.APP_DATASETS_ID_PERMISSIONS_OVERVIEW;
|
||||||
datasetId: string;
|
datasetId: string;
|
||||||
|
|
|
@ -11,10 +11,11 @@ export const pathNameToRoute = (pathName: string, params: any): BusterRoutes =>
|
||||||
[BusterRoutes.APP_DASHBOARD_ID]: BusterRoutes.APP_DASHBOARDS,
|
[BusterRoutes.APP_DASHBOARD_ID]: BusterRoutes.APP_DASHBOARDS,
|
||||||
[BusterRoutes.APP_COLLECTIONS_ID]: BusterRoutes.APP_COLLECTIONS,
|
[BusterRoutes.APP_COLLECTIONS_ID]: BusterRoutes.APP_COLLECTIONS,
|
||||||
[BusterRoutes.APP_DATASETS_ID]: BusterRoutes.APP_DATASETS,
|
[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_OVERVIEW]: BusterRoutes.APP_DATASETS,
|
||||||
[BusterRoutes.APP_DATASETS_ID_EDITOR]: 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]) {
|
if (route && paramRoutesToParent[route as string]) {
|
||||||
return paramRoutesToParent[route as string];
|
return paramRoutesToParent[route as string];
|
||||||
|
|
Loading…
Reference in New Issue