+4
-1
@@ -8,7 +8,10 @@ import { type WatchQueryFetchPolicy } from '@apollo/client';
|
||||
import { useMemo } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { type ObjectRecordFilterInput, useSearchQuery } from '~/generated/graphql';
|
||||
import {
|
||||
type ObjectRecordFilterInput,
|
||||
useSearchQuery,
|
||||
} from '~/generated/graphql';
|
||||
import { logError } from '~/utils/logError';
|
||||
|
||||
export type UseSearchRecordsParams = ObjectMetadataItemIdentifier & {
|
||||
|
||||
+7
-1
@@ -20,7 +20,13 @@ import { isStandaloneVariableString } from '@/workflow/utils/isStandaloneVariabl
|
||||
import { css } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { type ChangeEvent, type KeyboardEvent, useId, useRef, useState } from 'react';
|
||||
import {
|
||||
type ChangeEvent,
|
||||
type KeyboardEvent,
|
||||
useId,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { Key } from 'ts-key-enum';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { TEXT_INPUT_STYLE } from 'twenty-ui/theme';
|
||||
|
||||
+6
-6
@@ -3,12 +3,12 @@ import { MIN_DATE } from '@/ui/input/components/internal/date/constants/MinDate'
|
||||
import { parseDateToString } from '@/ui/input/components/internal/date/utils/parseDateToString';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import {
|
||||
expect,
|
||||
fn,
|
||||
userEvent,
|
||||
waitFor,
|
||||
waitForElementToBeRemoved,
|
||||
within,
|
||||
expect,
|
||||
fn,
|
||||
userEvent,
|
||||
waitFor,
|
||||
waitForElementToBeRemoved,
|
||||
within,
|
||||
} from '@storybook/test';
|
||||
import { DateTime } from 'luxon';
|
||||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
|
||||
|
||||
+6
-5
@@ -4,11 +4,12 @@ import { MIN_DATE } from '@/ui/input/components/internal/date/constants/MinDate'
|
||||
import { parseDateToString } from '@/ui/input/components/internal/date/utils/parseDateToString';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import {
|
||||
expect, fn,
|
||||
userEvent,
|
||||
waitFor,
|
||||
waitForElementToBeRemoved,
|
||||
within
|
||||
expect,
|
||||
fn,
|
||||
userEvent,
|
||||
waitFor,
|
||||
waitForElementToBeRemoved,
|
||||
within,
|
||||
} from '@storybook/test';
|
||||
import { DateTime } from 'luxon';
|
||||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { expect , fn, userEvent, within } from '@storybook/test';
|
||||
import { expect, fn, userEvent, within } from '@storybook/test';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
|
||||
import { WorkflowStepDecorator } from '~/testing/decorators/WorkflowStepDecorator';
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { expect , fn, userEvent, within } from '@storybook/test';
|
||||
import { expect, fn, userEvent, within } from '@storybook/test';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
|
||||
import { WorkflowStepDecorator } from '~/testing/decorators/WorkflowStepDecorator';
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { expect , within } from '@storybook/test';
|
||||
import { expect, within } from '@storybook/test';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import { FormNumberFieldInput } from '../FormNumberFieldInput';
|
||||
|
||||
|
||||
-12
@@ -88,11 +88,8 @@ export const SaveValidJson: Story = {
|
||||
return editor;
|
||||
});
|
||||
|
||||
|
||||
if (!editor) {
|
||||
|
||||
throw new Error('Editor element not found');
|
||||
|
||||
}
|
||||
|
||||
await userEvent.type(editor, '{{ "a": {{ "b" : "d" } }');
|
||||
@@ -164,11 +161,8 @@ export const DoesNotIgnoreInvalidJson: Story = {
|
||||
return editor;
|
||||
});
|
||||
|
||||
|
||||
if (!editor) {
|
||||
|
||||
throw new Error('Editor element not found');
|
||||
|
||||
}
|
||||
|
||||
await userEvent.type(editor, 'lol');
|
||||
@@ -336,11 +330,8 @@ export const DoesNotBreakWhenUserInsertsNewlineInJsonString: Story = {
|
||||
return editor;
|
||||
});
|
||||
|
||||
|
||||
if (!editor) {
|
||||
|
||||
throw new Error('Editor element not found');
|
||||
|
||||
}
|
||||
|
||||
await userEvent.type(editor, '"a{Enter}b"');
|
||||
@@ -363,11 +354,8 @@ export const AcceptsJsonEncodedNewline: Story = {
|
||||
return editor;
|
||||
});
|
||||
|
||||
|
||||
if (!editor) {
|
||||
|
||||
throw new Error('Editor element not found');
|
||||
|
||||
}
|
||||
|
||||
await userEvent.type(editor, '"a\\nb"');
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { expect , fn, userEvent, within } from '@storybook/test';
|
||||
import { expect, fn, userEvent, within } from '@storybook/test';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
|
||||
import { WorkflowStepDecorator } from '~/testing/decorators/WorkflowStepDecorator';
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ export const Disabled: Story = {
|
||||
expect(variablePicker).not.toBeInTheDocument();
|
||||
|
||||
// Clicking should not trigger onChange
|
||||
if(isDefined(dropdown)) {
|
||||
if (isDefined(dropdown)) {
|
||||
await userEvent.click(dropdown);
|
||||
}
|
||||
expect(args.onChange).not.toHaveBeenCalled();
|
||||
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import {
|
||||
expect,
|
||||
fn,
|
||||
userEvent,
|
||||
waitFor,
|
||||
waitForElementToBeRemoved,
|
||||
within,
|
||||
expect,
|
||||
fn,
|
||||
userEvent,
|
||||
waitFor,
|
||||
waitForElementToBeRemoved,
|
||||
within,
|
||||
} from '@storybook/test';
|
||||
import { getUserDevice } from 'twenty-ui/utilities';
|
||||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { expect , fn, userEvent, waitFor, within } from '@storybook/test';
|
||||
import { expect, fn, userEvent, waitFor, within } from '@storybook/test';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
|
||||
import { WorkflowStepDecorator } from '~/testing/decorators/WorkflowStepDecorator';
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { VariableChip } from '@/object-record/record-field/form-types/components/VariableChip';
|
||||
import { expect , within } from '@storybook/test';
|
||||
import { expect, within } from '@storybook/test';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import { I18nFrontDecorator } from '~/testing/decorators/I18nFrontDecorator';
|
||||
import { WorkflowStepDecorator } from '~/testing/decorators/WorkflowStepDecorator';
|
||||
|
||||
+6
-1
@@ -1,6 +1,11 @@
|
||||
import { css } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { forwardRef, type InputHTMLAttributes, type ReactNode, useRef } from 'react';
|
||||
import {
|
||||
forwardRef,
|
||||
type InputHTMLAttributes,
|
||||
type ReactNode,
|
||||
useRef,
|
||||
} from 'react';
|
||||
|
||||
import { useRegisterInputEvents } from '@/object-record/record-field/meta-types/input/hooks/useRegisterInputEvents';
|
||||
import { TEXT_INPUT_STYLE } from 'twenty-ui/theme';
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { expect , fn, userEvent, waitFor, within } from '@storybook/test';
|
||||
import { expect, fn, userEvent, waitFor, within } from '@storybook/test';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { expect , fn, userEvent, waitFor, within } from '@storybook/test';
|
||||
import { expect, fn, userEvent, waitFor, within } from '@storybook/test';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import { useEffect } from 'react';
|
||||
import { getCanvasElementForDropdownTesting } from 'twenty-ui/testing';
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { expect , fn, userEvent, waitFor, within } from '@storybook/test';
|
||||
import { expect, fn, userEvent, waitFor, within } from '@storybook/test';
|
||||
import { type Meta, type StoryObj } from '@storybook/react';
|
||||
import { useEffect } from 'react';
|
||||
import { getCanvasElementForDropdownTesting } from 'twenty-ui/testing';
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldAddressMetadata, type FieldMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldAddressMetadata,
|
||||
type FieldMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldAddress = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldBooleanMetadata, type FieldMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldBooleanMetadata,
|
||||
type FieldMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldBoolean = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldCurrencyMetadata, type FieldMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldCurrencyMetadata,
|
||||
type FieldMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldCurrency = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldDateTimeMetadata, type FieldMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldDateTimeMetadata,
|
||||
type FieldMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldDateTime = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldFullNameMetadata, type FieldMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldFullNameMetadata,
|
||||
type FieldMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldFullName = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldMetadata, type FieldPositionMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldMetadata,
|
||||
type FieldPositionMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldPosition = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldMetadata, type FieldRawJsonMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldMetadata,
|
||||
type FieldRawJsonMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldRawJson = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldMetadata, type FieldRelationMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldMetadata,
|
||||
type FieldRelationMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldRelation = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||
|
||||
+4
-1
@@ -2,7 +2,10 @@ import { isFieldRelation } from '@/object-record/record-field/types/guards/isFie
|
||||
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldMetadata, type FieldRelationMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldMetadata,
|
||||
type FieldRelationMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldRelationFromManyObjects = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type' | 'metadata'>,
|
||||
|
||||
+4
-1
@@ -2,7 +2,10 @@ import { isFieldRelation } from '@/object-record/record-field/types/guards/isFie
|
||||
|
||||
import { RelationType } from '~/generated-metadata/graphql';
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldMetadata, type FieldRelationMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldMetadata,
|
||||
type FieldRelationMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldRelationToOneObject = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type' | 'metadata'>,
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldMetadata, type FieldRichTextMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldMetadata,
|
||||
type FieldRichTextMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldRichText = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
import { type FieldMetadata, type FieldRichTextV2Metadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldMetadata,
|
||||
type FieldRichTextV2Metadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
export const isFieldRichTextV2 = (
|
||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
import { type FieldMetadata, type FieldTsVectorMetadata } from '../FieldMetadata';
|
||||
import {
|
||||
type FieldMetadata,
|
||||
type FieldTsVectorMetadata,
|
||||
} from '../FieldMetadata';
|
||||
|
||||
import { type FieldDefinition } from '../FieldDefinition';
|
||||
|
||||
|
||||
-1
@@ -6,7 +6,6 @@
|
||||
// let low = 0;
|
||||
// let high = array.length;
|
||||
|
||||
|
||||
// while (low < high) {
|
||||
// const mid = Math.floor((low + high) / 2);
|
||||
|
||||
|
||||
@@ -5,10 +5,12 @@ import { FieldMetadataType, RelationType } from '~/generated-metadata/graphql';
|
||||
|
||||
export type GenerateEmptyFieldValueArgs = {
|
||||
fieldMetadataItem: Pick<FieldMetadataItem, 'type' | 'relation'>;
|
||||
shouldComputeFunctionDefaultValue?: boolean;
|
||||
};
|
||||
// TODO strictly type each fieldValue following their FieldMetadataType
|
||||
export const generateEmptyFieldValue = ({
|
||||
fieldMetadataItem,
|
||||
shouldComputeFunctionDefaultValue = false,
|
||||
}: GenerateEmptyFieldValueArgs) => {
|
||||
switch (fieldMetadataItem.type) {
|
||||
case FieldMetadataType.TEXT: {
|
||||
@@ -39,9 +41,15 @@ export const generateEmptyFieldValue = ({
|
||||
};
|
||||
}
|
||||
case FieldMetadataType.DATE_TIME: {
|
||||
if (shouldComputeFunctionDefaultValue) {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
case FieldMetadataType.DATE: {
|
||||
if (shouldComputeFunctionDefaultValue) {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
case FieldMetadataType.NUMBER:
|
||||
|
||||
Reference in New Issue
Block a user