plane/web/components/view/views/root.tsx

52 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-02-02 08:22:38 +00:00
import { FC } from "react";
2024-02-05 14:39:17 +00:00
import { observer } from "mobx-react-lite";
// hooks
import { useView } from "hooks/store";
// components
import { ViewItem, ViewCreateEdit } from "../";
2024-02-02 08:22:38 +00:00
// types
import { TViewOperations } from "../types";
import { TViewTypes } from "@plane/types";
type TViewRoot = {
workspaceSlug: string;
projectId: string | undefined;
viewId: string | undefined;
viewType: TViewTypes;
viewOperations: TViewOperations;
};
2024-02-05 14:39:17 +00:00
export const ViewRoot: FC<TViewRoot> = observer((props) => {
const { workspaceSlug, projectId, viewId, viewType, viewOperations } = props;
// hooks
const viewStore = useView(workspaceSlug, projectId, viewType);
2024-02-02 08:22:38 +00:00
return (
2024-02-05 14:39:17 +00:00
<div className="border-b border-custom-border-100 relative flex px-5 gap-2">
{viewStore?.viewIds && viewStore?.viewIds.length > 0 && (
<div key={`views_list_${viewId}`} className="relative flex items-center w-full overflow-x-auto">
{viewStore?.viewIds.map((_viewId) => (
<ViewItem
workspaceSlug={workspaceSlug}
projectId={projectId}
viewId={viewId}
viewType={viewType}
viewItemId={_viewId}
/>
))}
2024-02-02 08:22:38 +00:00
</div>
2024-02-05 14:39:17 +00:00
)}
<div className="flex-shrink-0 my-auto pb-1">
<ViewCreateEdit
workspaceSlug={workspaceSlug}
projectId={projectId}
viewId={undefined}
viewType={viewType}
viewOperations={viewOperations}
/>
2024-02-02 08:22:38 +00:00
</div>
</div>
);
2024-02-05 14:39:17 +00:00
});