Skip to content

Commit

Permalink
feat(editor): ♿️ Show Google Sheets detail
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Apr 11, 2022
1 parent 1820686 commit 4a2c662
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 53 deletions.
2 changes: 0 additions & 2 deletions apps/builder/components/shared/CredentialsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export const CredentialsDropdown = ({
})
const { credentials, mutate } = useCredentials({
userId: user?.id,
onError: (error) =>
toast({ title: error.name, description: error.message }),
})
const [isDeleting, setIsDeleting] = useState<string>()

Expand Down
64 changes: 32 additions & 32 deletions apps/builder/components/shared/DropdownList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Button,
chakra,
Menu,
MenuButton,
MenuButtonProps,
Expand Down Expand Up @@ -29,38 +30,37 @@ export const DropdownList = <T,>({
onItemSelect(operator)
}
return (
<>
<Menu isLazy placement="bottom-end" matchWidth>
<MenuButton
as={Button}
rightIcon={<ChevronLeftIcon transform={'rotate(-90deg)'} />}
colorScheme="gray"
isTruncated
justifyContent="space-between"
textAlign="left"
{...props}
>
<Menu isLazy placement="bottom-end" matchWidth>
<MenuButton
as={Button}
rightIcon={<ChevronLeftIcon transform={'rotate(-90deg)'} />}
colorScheme="gray"
justifyContent="space-between"
textAlign="left"
{...props}
>
<chakra.span isTruncated display="block">
{currentItem ?? placeholder}
</MenuButton>
<Portal>
<MenuList maxW="500px" zIndex={1500}>
<Stack maxH={'35vh'} overflowY="scroll" spacing="0">
{items.map((item) => (
<MenuItem
key={item as unknown as string}
maxW="500px"
overflow="hidden"
whiteSpace="nowrap"
textOverflow="ellipsis"
onClick={handleMenuItemClick(item)}
>
{item}
</MenuItem>
))}
</Stack>
</MenuList>
</Portal>
</Menu>
</>
</chakra.span>
</MenuButton>
<Portal>
<MenuList maxW="500px" zIndex={1500}>
<Stack maxH={'35vh'} overflowY="scroll" spacing="0">
{items.map((item) => (
<MenuItem
key={item as unknown as string}
maxW="500px"
overflow="hidden"
whiteSpace="nowrap"
textOverflow="ellipsis"
onClick={handleMenuItemClick(item)}
>
{item}
</MenuItem>
))}
</Stack>
</MenuList>
</Portal>
</Menu>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const CellWithValueStack = ({
onItemChange({ ...item, value })
}
return (
<Stack p="4" rounded="md" flex="1" borderWidth="1px">
<Stack p="4" rounded="md" flex="1" borderWidth="1px" w="full">
<DropdownList<string>
currentItem={item.column}
onItemSelect={handleColumnSelect}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const GoogleSheetsSettingsBody = ({
/>
</>
)}
{sheet && 'action' in options && (
{'action' in options && (
<ActionOptions
options={options}
sheet={sheet}
Expand All @@ -145,7 +145,7 @@ const ActionOptions = ({
| GoogleSheetsGetOptions
| GoogleSheetsInsertRowOptions
| GoogleSheetsUpdateRowOptions
sheet: Sheet
sheet?: Sheet
onOptionsChange: (options: GoogleSheetsOptions) => void
}) => {
const handleInsertColumnsChange = (cellsToInsert: Cell[]) =>
Expand All @@ -162,14 +162,14 @@ const ActionOptions = ({

const UpdatingCellItem = useMemo(
() => (props: TableListItemProps<Cell>) =>
<CellWithValueStack {...props} columns={sheet.columns} />,
[sheet.columns]
<CellWithValueStack {...props} columns={sheet?.columns ?? []} />,
[sheet?.columns]
)

const ExtractingCellItem = useMemo(
() => (props: TableListItemProps<ExtractingCell>) =>
<CellWithVariableIdStack {...props} columns={sheet.columns} />,
[sheet.columns]
<CellWithVariableIdStack {...props} columns={sheet?.columns ?? []} />,
[sheet?.columns]
)

switch (options.action) {
Expand All @@ -187,7 +187,7 @@ const ActionOptions = ({
<Stack>
<Text>Row to select</Text>
<CellWithValueStack
columns={sheet.columns}
columns={sheet?.columns ?? []}
item={options.referenceCell ?? { id: 'reference' }}
onItemChange={handleReferenceCellChange}
/>
Expand All @@ -205,7 +205,7 @@ const ActionOptions = ({
<Stack>
<Text>Row to select</Text>
<CellWithValueStack
columns={sheet.columns}
columns={sheet?.columns ?? []}
item={options.referenceCell ?? { id: 'reference' }}
onItemChange={handleReferenceCellChange}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Input, Tooltip, useToast } from '@chakra-ui/react'
import { Input, Tooltip } from '@chakra-ui/react'
import { SearchableDropdown } from 'components/shared/SearchableDropdown'
import { useMemo } from 'react'
import { useSpreadsheets } from 'services/integrations'
Expand All @@ -14,15 +14,8 @@ export const SpreadsheetsDropdown = ({
spreadsheetId,
onSelectSpreadsheetId,
}: Props) => {
const toast = useToast({
position: 'top-right',
status: 'error',
})
const { spreadsheets, isLoading } = useSpreadsheets({
credentialsId,
onError: (e) =>
!toast.isActive('spreadsheets') &&
toast({ id: 'spreadsheets', title: e.name, description: e.message }),
})
const currentSpreadsheet = useMemo(
() => spreadsheets?.find((s) => s.id === spreadsheetId),
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/services/user/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export const useCredentials = ({
onError,
}: {
userId?: string
onError: (error: Error) => void
onError?: (error: Error) => void
}) => {
const { data, error, mutate } = useSWR<{ credentials: Credentials[] }, Error>(
userId ? `/api/users/${userId}/credentials` : null,
fetcher
)
if (error) onError(error)
if (error && onError) onError(error)
return {
credentials: data?.credentials ?? [],
isLoading: !error && !data,
Expand Down

4 comments on commit 4a2c662

@vercel
Copy link

@vercel vercel bot commented on 4a2c662 Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 4a2c662 Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 4a2c662 Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 4a2c662 Apr 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.