2
0

feat(dashboard): ️ Hide create buttons for guests

This commit is contained in:
Baptiste Arnaud
2022-06-18 09:06:46 +02:00
parent 5ef89f7501
commit 4e6217597c

View File

@ -1,4 +1,4 @@
import { DashboardFolder } from 'db' import { DashboardFolder, WorkspaceRole } from 'db'
import { import {
Flex, Flex,
Heading, Heading,
@ -34,7 +34,7 @@ const dragDistanceTolerance = 20
export const FolderContent = ({ folder }: Props) => { export const FolderContent = ({ folder }: Props) => {
const { user } = useUser() const { user } = useUser()
const { workspace } = useWorkspace() const { workspace, currentRole } = useWorkspace()
const [isCreatingFolder, setIsCreatingFolder] = useState(false) const [isCreatingFolder, setIsCreatingFolder] = useState(false)
const { const {
setDraggedTypebot, setDraggedTypebot,
@ -170,17 +170,21 @@ export const FolderContent = ({ folder }: Props) => {
<Stack> <Stack>
<HStack> <HStack>
{folder && <BackButton id={folder.parentFolderId} />} {folder && <BackButton id={folder.parentFolderId} />}
<CreateFolderButton {currentRole !== WorkspaceRole.GUEST && (
onClick={handleCreateFolder} <CreateFolderButton
isLoading={isCreatingFolder || isFolderLoading} onClick={handleCreateFolder}
/> isLoading={isCreatingFolder || isFolderLoading}
/>
)}
</HStack> </HStack>
<Wrap spacing={4}> <Wrap spacing={4}>
<CreateBotButton {currentRole !== WorkspaceRole.GUEST && (
folderId={folder?.id} <CreateBotButton
isLoading={isTypebotLoading} folderId={folder?.id}
isFirstBot={typebots?.length === 0 && folder === null} isLoading={isTypebotLoading}
/> isFirstBot={typebots?.length === 0 && folder === null}
/>
)}
{isFolderLoading && <ButtonSkeleton />} {isFolderLoading && <ButtonSkeleton />}
{folders && {folders &&
folders.map((folder) => ( folders.map((folder) => (