Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7417 workflows i can send emails using the email account #7431

Merged
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions packages/twenty-emails/src/emails/workflow-action.email.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/twenty-emails/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export * from './emails/delete-inactive-workspaces.email';
export * from './emails/password-reset-link.email';
export * from './emails/password-update-notify.email';
export * from './emails/send-invite-link.email';
export * from './emails/workflow-action.email';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const GMAIL_SEND_SCOPE = 'https://www.googleapis.com/auth/gmail.send';
martmull marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export type ConnectedAccount = {
authFailedAt: Date | null;
messageChannels: MessageChannel[];
calendarChannels: CalendarChannel[];
scopes: string[] | null;
__typename: 'ConnectedAccount';
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const useTriggerGoogleApisOAuth = () => {

const triggerGoogleApisOAuth = useCallback(
async (
redirectLocation?: AppPath,
redirectLocation?: AppPath | string,
messageVisibility?: MessageChannelVisibility,
calendarVisibility?: CalendarChannelVisibility,
) => {
Expand Down
31 changes: 27 additions & 4 deletions packages/twenty-front/src/modules/ui/input/components/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { useMemo, useRef, useState } from 'react';
import React, { MouseEvent, useMemo, useRef, useState } from 'react';
import { IconChevronDown, IconComponent } from 'twenty-ui';

import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
Expand All @@ -11,13 +11,20 @@ import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';

import { SelectHotkeyScope } from '../types/SelectHotkeyScope';
import { isDefined } from '~/utils/isDefined';

export type SelectOption<Value extends string | number | null> = {
value: Value;
label: string;
Icon?: IconComponent;
};

type CallToActionButton = {
text: string;
onClick: (event: MouseEvent<HTMLDivElement>) => void;
Icon?: IconComponent;
};

export type SelectProps<Value extends string | number | null> = {
className?: string;
disabled?: boolean;
Expand All @@ -32,6 +39,7 @@ export type SelectProps<Value extends string | number | null> = {
options: SelectOption<Value>[];
value?: Value;
withSearchInput?: boolean;
callToActionButton?: CallToActionButton;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely convinced we should add specific use cases to the raw Select components. The Select component should allow composition: We should be able to add such a button quickly, but the Select component should not know about it.

One example I like is Headless UI components:

CleanShot 2024-10-08 at 15 51 36@2x

Another solution, if we want to add buttons in selects often, is to make it possible to inject buttons through the options property:

options={[{ label: 'XX', value: "" }, { type: "divider" }, { type: "button", label: "Add one +", onClick: () => {}, icon: "" }]}

If we keep adding specific use cases like this to the Select component itself, it will quickly become bloated.

I don't think we should change something to your PR, this is more a discussion to start with the whole team.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I Allowed that to myself as there already is a SearchInput option that can be displayed at the bottom of the select. @charlesBochet @thomtrp wdyt?

};

const StyledContainer = styled.div<{ fullWidth?: boolean }>`
Expand Down Expand Up @@ -89,6 +97,7 @@ export const Select = <Value extends string | number | null>({
options,
value,
withSearchInput,
callToActionButton,
}: SelectProps<Value>) => {
const selectContainerRef = useRef<HTMLDivElement>(null);

Expand All @@ -97,8 +106,8 @@ export const Select = <Value extends string | number | null>({

const selectedOption =
options.find(({ value: key }) => key === value) ||
options[0] ||
emptyOption;
emptyOption ||
options[0];
const filteredOptions = useMemo(
() =>
searchInputValue
Expand All @@ -109,7 +118,9 @@ export const Select = <Value extends string | number | null>({
[options, searchInputValue],
);

const isDisabled = disabledFromProps || options.length <= 1;
const isDisabled =
disabledFromProps ||
(options.length <= 1 && !isDefined(callToActionButton));

const { closeDropdown } = useDropdown(dropdownId);

Expand Down Expand Up @@ -177,6 +188,18 @@ export const Select = <Value extends string | number | null>({
))}
</DropdownMenuItemsContainer>
)}
{!!callToActionButton && !!filteredOptions.length && (
<DropdownMenuSeparator />
)}
{!!callToActionButton && (
<DropdownMenuItemsContainer hasMaxHeight>
<MenuItem
onClick={callToActionButton.onClick}
LeftIcon={callToActionButton.Icon}
text={callToActionButton.text}
/>
</DropdownMenuItemsContainer>
)}
</>
}
dropdownHotkeyScope={{ scope: SelectHotkeyScope.Select }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { userEvent, within } from '@storybook/test';
import { ComponentDecorator } from 'twenty-ui';

import { Select, SelectProps } from '../Select';
import { IconPlus } from 'packages/twenty-ui';

type RenderProps = SelectProps<string | number | null>;

Expand Down Expand Up @@ -56,3 +57,13 @@ export const Disabled: Story = {
export const WithSearch: Story = {
args: { withSearchInput: true },
};

export const CallToActionButton: Story = {
args: {
callToActionButton: {
onClick: () => {},
Icon: IconPlus,
text: 'Add action',
},
},
};
Loading
Loading