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

Add suggested values for variable dropdown #9437

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion packages/twenty-e2e-testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twenty-e2e-testing",
"version": "0.40.0-canary",
"version": "0.35.4",
"description": "",
"author": "",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-emails/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twenty-emails",
"version": "0.40.0-canary",
"version": "0.35.4",
"description": "",
"author": "",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-front/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twenty-front",
"version": "0.40.0-canary",
"version": "0.35.4",
"private": true,
"type": "module",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ServerlessFunctionExecutionStatus } from '~/generated-metadata/graphql';
import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
import { ServerlessFunctionExecutionStatus } from '~/generated-metadata/graphql';

export type ServerlessFunctionTestData = {
input: { [field: string]: any };
Expand All @@ -13,8 +13,7 @@ export type ServerlessFunctionTestData = {
height: number;
};

export const DEFAULT_OUTPUT_VALUE =
'Enter an input above then press "run Function"';
export const DEFAULT_OUTPUT_VALUE = 'Enter an input above then press "Test"';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated since button is named Test

export const serverlessFunctionTestDataFamilyState = createFamilyState<
ServerlessFunctionTestData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,18 @@ export const WorkflowVariablesDropdownFieldItems = ({
/>
<DropdownMenuSeparator />
<DropdownMenuItemsContainer>
{filteredOptions.map(([key, value]) => (
{filteredOptions.map(([key, subStep]) => (
<MenuItemSelect
key={key}
selected={false}
hovered={false}
onClick={() => handleSelectField(key)}
text={value.label || key}
hasSubMenu={!value.isLeaf}
LeftIcon={value.icon ? getIcon(value.icon) : undefined}
text={subStep.label || key}
hasSubMenu={!subStep.isLeaf}
LeftIcon={subStep.icon ? getIcon(subStep.icon) : undefined}
contextualText={
subStep.isLeaf ? subStep?.value?.toString() : undefined
}
/>
))}
</DropdownMenuItemsContainer>
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twenty-server",
"version": "0.40.0-canary",
"version": "0.35.4",
"description": "",
"author": "",
"private": true,
Expand Down
59 changes: 52 additions & 7 deletions packages/twenty-server/src/engine/utils/generate-fake-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ type FakeValueTypes =
| Date
| FakeValueTypes[]
| FieldMetadataType
| { [key: string]: FakeValueTypes };
| { [key: string]: FakeValueTypes }
| null;

export const generateFakeValue = (valueType: string): FakeValueTypes => {
type TypeClassification = 'Primitive' | 'FieldMetadataType';

const generatePrimitiveValue = (valueType: string): FakeValueTypes => {
if (valueType === 'string') {
return 'generated-string-value';
return 'My text';
} else if (valueType === 'number') {
return 1;
return 20;
} else if (valueType === 'boolean') {
return true;
} else if (valueType === 'Date') {
Expand All @@ -38,9 +41,51 @@ export const generateFakeValue = (valueType: string): FakeValueTypes => {
});

return objData;
} else if (valueType === FieldMetadataType.TEXT) {
return 'My text';
} else {
return 'generated-string-value';
return null;
}
};

const generateFieldMetadataTypeValue = (
valueType: string,
): FakeValueTypes | null => {
// composite types do not need to be generated
switch (valueType) {
case FieldMetadataType.TEXT:
return 'My text';
case FieldMetadataType.NUMBER:
return 20;
case FieldMetadataType.BOOLEAN:
return true;
case FieldMetadataType.DATE:
return '01/23/2025';
case FieldMetadataType.DATE_TIME:
return '01/23/2025 15:16';
thomtrp marked this conversation as resolved.
Show resolved Hide resolved
case FieldMetadataType.ADDRESS:
return '123 Main St, Anytown, CA 12345';
case FieldMetadataType.FULL_NAME:
return 'Tim Cook';
case FieldMetadataType.RAW_JSON:
return null;
case FieldMetadataType.RICH_TEXT:
return 'My rich text';
case FieldMetadataType.UUID:
return '123e4567-e89b-12d3-a456-426614174000';
default:
return null;
}
};

export const generateFakeValue = (
valueType: string,
classification: TypeClassification = 'Primitive',
): FakeValueTypes => {
switch (classification) {
case 'Primitive':
return generatePrimitiveValue(valueType);
case 'FieldMetadataType':
return generateFieldMetadataTypeValue(valueType);
default:
return null;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const generateObjectRecordFields = (
type: field.type,
icon: field.icon,
label: field.label,
value: generateFakeValue(field.type),
value: generateFakeValue(field.type, 'FieldMetadataType'),
};
} else {
acc[field.name] = {
Expand All @@ -37,7 +37,7 @@ const generateObjectRecordFields = (
isLeaf: true,
type: property.type,
label: camelToTitleCase(property.name),
value: generateFakeValue(property.type),
value: generateFakeValue(property.type, 'FieldMetadataType'),
};

return acc;
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twenty-ui",
"version": "0.40.0-canary",
"version": "0.35.4",
"type": "module",
"main": "./src/index.ts",
"exports": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type MenuItemSelectProps = {
disabled?: boolean;
hovered?: boolean;
hasSubMenu?: boolean;
contextualText?: string;
};

export const MenuItemSelect = ({
Expand All @@ -59,6 +60,7 @@ export const MenuItemSelect = ({
disabled,
hovered,
hasSubMenu = false,
contextualText,
}: MenuItemSelectProps) => {
const theme = useTheme();

Expand All @@ -73,8 +75,13 @@ export const MenuItemSelect = ({
aria-selected={selected}
aria-disabled={disabled}
>
<MenuItemLeftContent LeftIcon={LeftIcon} text={text} />
<MenuItemLeftContent
LeftIcon={LeftIcon}
text={text}
contextualText={contextualText}
/>
{selected && needIconCheck && <IconCheck size={theme.icon.size.md} />}

{hasSubMenu && (
<IconChevronRight
size={theme.icon.size.sm}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import {
StyledMenuItemLeftContent,
} from './StyledMenuItemBase';

const StyledMainText = styled.div`
flex-shrink: 0;
`;

const StyledContextualText = styled.div`
color: ${({ theme }) => theme.color.gray35};
font-family: inherit;
Expand All @@ -29,6 +33,7 @@ const StyledContextualText = styled.div`
white-space: nowrap;

padding-left: ${({ theme }) => theme.spacing(1)};
flex-shrink: 1;
`;

type MenuItemLeftContentProps = {
Expand Down Expand Up @@ -67,7 +72,13 @@ export const MenuItemLeftContent = ({
<LeftIcon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
)}
<StyledMenuItemLabel hasLeftIcon={!!LeftIcon}>
{isString(text) ? <OverflowingTextWithTooltip text={text} /> : text}
{isString(text) ? (
<StyledMainText>
<OverflowingTextWithTooltip text={text} />
</StyledMainText>
) : (
text
)}
{isString(contextualText) ? (
<StyledContextualText>{`· ${contextualText}`}</StyledContextualText>
) : (
Expand Down
2 changes: 1 addition & 1 deletion packages/twenty-website/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twenty-website",
"version": "0.40.0-canary",
"version": "0.35.4",
"private": true,
"scripts": {
"nx": "NX_DEFAULT_PROJECT=twenty-website node ../../node_modules/nx/bin/nx.js",
Expand Down
Loading