clean searchResolvers in server (#11114)
Introduces break in change - remove search... resolvers - rename globalSearch to search - rename searchRecord.objectSingularName > objectNameSingular closes https://github.com/twentyhq/core-team-issues/issues/643
This commit is contained in:
@ -707,16 +707,6 @@ export type GetServerlessFunctionSourceCodeInput = {
|
||||
version?: Scalars['String']['input'];
|
||||
};
|
||||
|
||||
export type GlobalSearchRecord = {
|
||||
__typename?: 'GlobalSearchRecord';
|
||||
imageUrl?: Maybe<Scalars['String']['output']>;
|
||||
label: Scalars['String']['output'];
|
||||
objectSingularName: Scalars['String']['output'];
|
||||
recordId: Scalars['String']['output'];
|
||||
tsRank: Scalars['Float']['output'];
|
||||
tsRankCD: Scalars['Float']['output'];
|
||||
};
|
||||
|
||||
export enum HealthIndicatorId {
|
||||
app = 'app',
|
||||
connectedAccount = 'connectedAccount',
|
||||
@ -934,6 +924,7 @@ export type Mutation = {
|
||||
updateOneField: Field;
|
||||
updateOneObject: Object;
|
||||
updateOneRemoteServer: RemoteServer;
|
||||
updateOneRole: Role;
|
||||
updateOneServerlessFunction: ServerlessFunction;
|
||||
updatePasswordViaResetToken: InvalidatePassword;
|
||||
updateWorkflowVersionStep: WorkflowAction;
|
||||
@ -1481,13 +1472,13 @@ export type Query = {
|
||||
getTimelineCalendarEventsFromPersonId: TimelineCalendarEventsWithTotal;
|
||||
getTimelineThreadsFromCompanyId: TimelineThreadsWithTotal;
|
||||
getTimelineThreadsFromPersonId: TimelineThreadsWithTotal;
|
||||
globalSearch: Array<GlobalSearchRecord>;
|
||||
index: Index;
|
||||
indexMetadatas: IndexConnection;
|
||||
object: Object;
|
||||
objects: ObjectConnection;
|
||||
plans: Array<BillingPlanOutput>;
|
||||
relationMetadata: RelationMetadataConnection;
|
||||
search: Array<SearchRecord>;
|
||||
validatePasswordResetToken: ValidatePasswordResetToken;
|
||||
};
|
||||
|
||||
@ -1593,15 +1584,6 @@ export type QueryGetTimelineThreadsFromPersonIdArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type QueryGlobalSearchArgs = {
|
||||
excludedObjectNameSingulars?: InputMaybe<Array<Scalars['String']['input']>>;
|
||||
filter?: InputMaybe<ObjectRecordFilterInput>;
|
||||
includedObjectNameSingulars?: InputMaybe<Array<Scalars['String']['input']>>;
|
||||
limit: Scalars['Int']['input'];
|
||||
searchInput: Scalars['String']['input'];
|
||||
};
|
||||
|
||||
|
||||
export type QueryIndexArgs = {
|
||||
id: Scalars['UUID']['input'];
|
||||
};
|
||||
@ -1629,6 +1611,15 @@ export type QueryRelationMetadataArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type QuerySearchArgs = {
|
||||
excludedObjectNameSingulars?: InputMaybe<Array<Scalars['String']['input']>>;
|
||||
filter?: InputMaybe<ObjectRecordFilterInput>;
|
||||
includedObjectNameSingulars?: InputMaybe<Array<Scalars['String']['input']>>;
|
||||
limit: Scalars['Int']['input'];
|
||||
searchInput: Scalars['String']['input'];
|
||||
};
|
||||
|
||||
|
||||
export type QueryValidatePasswordResetTokenArgs = {
|
||||
passwordResetToken: Scalars['String']['input'];
|
||||
};
|
||||
@ -1827,6 +1818,16 @@ export enum SsoIdentityProviderStatus {
|
||||
Inactive = 'Inactive'
|
||||
}
|
||||
|
||||
export type SearchRecord = {
|
||||
__typename?: 'SearchRecord';
|
||||
imageUrl?: Maybe<Scalars['String']['output']>;
|
||||
label: Scalars['String']['output'];
|
||||
objectNameSingular: Scalars['String']['output'];
|
||||
recordId: Scalars['String']['output'];
|
||||
tsRank: Scalars['Float']['output'];
|
||||
tsRankCD: Scalars['Float']['output'];
|
||||
};
|
||||
|
||||
export type SendInvitationsOutput = {
|
||||
__typename?: 'SendInvitationsOutput';
|
||||
errors: Array<Scalars['String']['output']>;
|
||||
|
||||
@ -643,16 +643,6 @@ export type GetServerlessFunctionSourceCodeInput = {
|
||||
version?: Scalars['String'];
|
||||
};
|
||||
|
||||
export type GlobalSearchRecord = {
|
||||
__typename?: 'GlobalSearchRecord';
|
||||
imageUrl?: Maybe<Scalars['String']>;
|
||||
label: Scalars['String'];
|
||||
objectSingularName: Scalars['String'];
|
||||
recordId: Scalars['String'];
|
||||
tsRank: Scalars['Float'];
|
||||
tsRankCD: Scalars['Float'];
|
||||
};
|
||||
|
||||
export enum HealthIndicatorId {
|
||||
app = 'app',
|
||||
connectedAccount = 'connectedAccount',
|
||||
@ -1368,12 +1358,12 @@ export type Query = {
|
||||
getTimelineCalendarEventsFromPersonId: TimelineCalendarEventsWithTotal;
|
||||
getTimelineThreadsFromCompanyId: TimelineThreadsWithTotal;
|
||||
getTimelineThreadsFromPersonId: TimelineThreadsWithTotal;
|
||||
globalSearch: Array<GlobalSearchRecord>;
|
||||
index: Index;
|
||||
indexMetadatas: IndexConnection;
|
||||
object: Object;
|
||||
objects: ObjectConnection;
|
||||
plans: Array<BillingPlanOutput>;
|
||||
search: Array<SearchRecord>;
|
||||
validatePasswordResetToken: ValidatePasswordResetToken;
|
||||
};
|
||||
|
||||
@ -1453,7 +1443,7 @@ export type QueryGetTimelineThreadsFromPersonIdArgs = {
|
||||
};
|
||||
|
||||
|
||||
export type QueryGlobalSearchArgs = {
|
||||
export type QuerySearchArgs = {
|
||||
excludedObjectNameSingulars?: InputMaybe<Array<Scalars['String']>>;
|
||||
filter?: InputMaybe<ObjectRecordFilterInput>;
|
||||
includedObjectNameSingulars?: InputMaybe<Array<Scalars['String']>>;
|
||||
@ -1646,6 +1636,16 @@ export enum SsoIdentityProviderStatus {
|
||||
Inactive = 'Inactive'
|
||||
}
|
||||
|
||||
export type SearchRecord = {
|
||||
__typename?: 'SearchRecord';
|
||||
imageUrl?: Maybe<Scalars['String']>;
|
||||
label: Scalars['String'];
|
||||
objectNameSingular: Scalars['String'];
|
||||
recordId: Scalars['String'];
|
||||
tsRank: Scalars['Float'];
|
||||
tsRankCD: Scalars['Float'];
|
||||
};
|
||||
|
||||
export type SendInvitationsOutput = {
|
||||
__typename?: 'SendInvitationsOutput';
|
||||
errors: Array<Scalars['String']>;
|
||||
@ -2456,7 +2456,7 @@ export type GetClientConfigQueryVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
export type GetClientConfigQuery = { __typename?: 'Query', clientConfig: { __typename?: 'ClientConfig', signInPrefilled: boolean, isMultiWorkspaceEnabled: boolean, isEmailVerificationRequired: boolean, defaultSubdomain?: string | null, frontDomain: string, debugMode: boolean, analyticsEnabled: boolean, isAttachmentPreviewEnabled: boolean, chromeExtensionId?: string | null, canManageFeatureFlags: boolean, isMicrosoftMessagingEnabled: boolean, isMicrosoftCalendarEnabled: boolean, isGoogleMessagingEnabled: boolean, isGoogleCalendarEnabled: boolean, billing: { __typename?: 'Billing', isBillingEnabled: boolean, billingUrl?: string | null, trialPeriods: Array<{ __typename?: 'BillingTrialPeriodDTO', duration: number, isCreditCardRequired: boolean }> }, authProviders: { __typename?: 'AuthProviders', google: boolean, password: boolean, microsoft: boolean, sso: Array<{ __typename?: 'SSOIdentityProvider', id: string, name: string, type: IdentityProviderType, status: SsoIdentityProviderStatus, issuer: string }> }, support: { __typename?: 'Support', supportDriver: string, supportFrontChatId?: string | null }, sentry: { __typename?: 'Sentry', dsn?: string | null, environment?: string | null, release?: string | null }, captcha: { __typename?: 'Captcha', provider?: CaptchaDriverType | null, siteKey?: string | null }, api: { __typename?: 'ApiConfig', mutationMaximumAffectedRecords: number }, publicFeatureFlags: Array<{ __typename?: 'PublicFeatureFlag', key: FeatureFlagKey, metadata: { __typename?: 'PublicFeatureFlagMetadata', label: string, description: string, imagePath: string } }> } };
|
||||
|
||||
export type GlobalSearchQueryVariables = Exact<{
|
||||
export type SearchQueryVariables = Exact<{
|
||||
searchInput: Scalars['String'];
|
||||
limit: Scalars['Int'];
|
||||
excludedObjectNameSingulars?: InputMaybe<Array<Scalars['String']> | Scalars['String']>;
|
||||
@ -2465,7 +2465,7 @@ export type GlobalSearchQueryVariables = Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type GlobalSearchQuery = { __typename?: 'Query', globalSearch: Array<{ __typename?: 'GlobalSearchRecord', recordId: string, objectSingularName: string, label: string, imageUrl?: string | null, tsRankCD: number, tsRank: number }> };
|
||||
export type SearchQuery = { __typename?: 'Query', search: Array<{ __typename?: 'SearchRecord', recordId: string, objectNameSingular: string, label: string, imageUrl?: string | null, tsRankCD: number, tsRank: number }> };
|
||||
|
||||
export type SkipSyncEmailOnboardingStepMutationVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
@ -4145,9 +4145,9 @@ export function useGetClientConfigLazyQuery(baseOptions?: Apollo.LazyQueryHookOp
|
||||
export type GetClientConfigQueryHookResult = ReturnType<typeof useGetClientConfigQuery>;
|
||||
export type GetClientConfigLazyQueryHookResult = ReturnType<typeof useGetClientConfigLazyQuery>;
|
||||
export type GetClientConfigQueryResult = Apollo.QueryResult<GetClientConfigQuery, GetClientConfigQueryVariables>;
|
||||
export const GlobalSearchDocument = gql`
|
||||
query GlobalSearch($searchInput: String!, $limit: Int!, $excludedObjectNameSingulars: [String!], $includedObjectNameSingulars: [String!], $filter: ObjectRecordFilterInput) {
|
||||
globalSearch(
|
||||
export const SearchDocument = gql`
|
||||
query Search($searchInput: String!, $limit: Int!, $excludedObjectNameSingulars: [String!], $includedObjectNameSingulars: [String!], $filter: ObjectRecordFilterInput) {
|
||||
search(
|
||||
searchInput: $searchInput
|
||||
limit: $limit
|
||||
excludedObjectNameSingulars: $excludedObjectNameSingulars
|
||||
@ -4155,7 +4155,7 @@ export const GlobalSearchDocument = gql`
|
||||
filter: $filter
|
||||
) {
|
||||
recordId
|
||||
objectSingularName
|
||||
objectNameSingular
|
||||
label
|
||||
imageUrl
|
||||
tsRankCD
|
||||
@ -4165,16 +4165,16 @@ export const GlobalSearchDocument = gql`
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useGlobalSearchQuery__
|
||||
* __useSearchQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useGlobalSearchQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useGlobalSearchQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
||||
* To run a query within a React component, call `useSearchQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useSearchQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
||||
* you can use to render your UI.
|
||||
*
|
||||
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
||||
*
|
||||
* @example
|
||||
* const { data, loading, error } = useGlobalSearchQuery({
|
||||
* const { data, loading, error } = useSearchQuery({
|
||||
* variables: {
|
||||
* searchInput: // value for 'searchInput'
|
||||
* limit: // value for 'limit'
|
||||
@ -4184,17 +4184,17 @@ export const GlobalSearchDocument = gql`
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useGlobalSearchQuery(baseOptions: Apollo.QueryHookOptions<GlobalSearchQuery, GlobalSearchQueryVariables>) {
|
||||
export function useSearchQuery(baseOptions: Apollo.QueryHookOptions<SearchQuery, SearchQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<GlobalSearchQuery, GlobalSearchQueryVariables>(GlobalSearchDocument, options);
|
||||
return Apollo.useQuery<SearchQuery, SearchQueryVariables>(SearchDocument, options);
|
||||
}
|
||||
export function useGlobalSearchLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<GlobalSearchQuery, GlobalSearchQueryVariables>) {
|
||||
export function useSearchLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<SearchQuery, SearchQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<GlobalSearchQuery, GlobalSearchQueryVariables>(GlobalSearchDocument, options);
|
||||
return Apollo.useLazyQuery<SearchQuery, SearchQueryVariables>(SearchDocument, options);
|
||||
}
|
||||
export type GlobalSearchQueryHookResult = ReturnType<typeof useGlobalSearchQuery>;
|
||||
export type GlobalSearchLazyQueryHookResult = ReturnType<typeof useGlobalSearchLazyQuery>;
|
||||
export type GlobalSearchQueryResult = Apollo.QueryResult<GlobalSearchQuery, GlobalSearchQueryVariables>;
|
||||
export type SearchQueryHookResult = ReturnType<typeof useSearchQuery>;
|
||||
export type SearchLazyQueryHookResult = ReturnType<typeof useSearchLazyQuery>;
|
||||
export type SearchQueryResult = Apollo.QueryResult<SearchQuery, SearchQueryVariables>;
|
||||
export const SkipSyncEmailOnboardingStepDocument = gql`
|
||||
mutation SkipSyncEmailOnboardingStep {
|
||||
skipSyncEmailOnboardingStep {
|
||||
|
||||
@ -164,10 +164,10 @@ export const NoResultsSearchFallback: Story = {
|
||||
parameters: {
|
||||
msw: {
|
||||
handlers: [
|
||||
graphql.query('GlobalSearch', () => {
|
||||
graphql.query('Search', () => {
|
||||
return HttpResponse.json({
|
||||
data: {
|
||||
globalSearch: [],
|
||||
search: [],
|
||||
},
|
||||
});
|
||||
}),
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import gql from 'graphql-tag';
|
||||
|
||||
export const globalSearch = gql`
|
||||
query GlobalSearch(
|
||||
export const search = gql`
|
||||
query Search(
|
||||
$searchInput: String!
|
||||
$limit: Int!
|
||||
$excludedObjectNameSingulars: [String!]
|
||||
$includedObjectNameSingulars: [String!]
|
||||
$filter: ObjectRecordFilterInput
|
||||
) {
|
||||
globalSearch(
|
||||
search(
|
||||
searchInput: $searchInput
|
||||
limit: $limit
|
||||
excludedObjectNameSingulars: $excludedObjectNameSingulars
|
||||
@ -16,7 +16,7 @@ export const globalSearch = gql`
|
||||
filter: $filter
|
||||
) {
|
||||
recordId
|
||||
objectSingularName
|
||||
objectNameSingular
|
||||
label
|
||||
imageUrl
|
||||
tsRankCD
|
||||
@ -5,17 +5,17 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { useMemo } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { capitalize } from 'twenty-shared/utils';
|
||||
import { Avatar } from 'twenty-ui';
|
||||
import { useDebounce } from 'use-debounce';
|
||||
import { useGlobalSearchQuery } from '~/generated/graphql';
|
||||
import { capitalize } from 'twenty-shared/utils';
|
||||
import { useSearchQuery } from '~/generated/graphql';
|
||||
|
||||
export const useCommandMenuSearchRecords = () => {
|
||||
const commandMenuSearch = useRecoilValue(commandMenuSearchState);
|
||||
|
||||
const [deferredCommandMenuSearch] = useDebounce(commandMenuSearch, 300);
|
||||
|
||||
const { data: globalSearchData, loading } = useGlobalSearchQuery({
|
||||
const { data: searchData, loading } = useSearchQuery({
|
||||
variables: {
|
||||
searchInput: deferredCommandMenuSearch ?? '',
|
||||
limit: MAX_SEARCH_RESULTS,
|
||||
@ -26,17 +26,17 @@ export const useCommandMenuSearchRecords = () => {
|
||||
const { openRecordInCommandMenu } = useOpenRecordInCommandMenu();
|
||||
|
||||
const commands = useMemo(() => {
|
||||
return (globalSearchData?.globalSearch ?? []).map((searchRecord) => {
|
||||
return (searchData?.search ?? []).map((searchRecord) => {
|
||||
const command = {
|
||||
id: searchRecord.recordId,
|
||||
label: searchRecord.label,
|
||||
description: capitalize(searchRecord.objectSingularName),
|
||||
to: `object/${searchRecord.objectSingularName}/${searchRecord.recordId}`,
|
||||
description: capitalize(searchRecord.objectNameSingular),
|
||||
to: `object/${searchRecord.objectNameSingular}/${searchRecord.recordId}`,
|
||||
shouldCloseCommandMenuOnClick: true,
|
||||
Icon: () => (
|
||||
<Avatar
|
||||
type={
|
||||
searchRecord.objectSingularName === 'company'
|
||||
searchRecord.objectNameSingular === 'company'
|
||||
? 'squared'
|
||||
: 'rounded'
|
||||
}
|
||||
@ -48,14 +48,14 @@ export const useCommandMenuSearchRecords = () => {
|
||||
};
|
||||
if (
|
||||
[CoreObjectNameSingular.Task, CoreObjectNameSingular.Note].includes(
|
||||
searchRecord.objectSingularName as CoreObjectNameSingular,
|
||||
searchRecord.objectNameSingular as CoreObjectNameSingular,
|
||||
)
|
||||
) {
|
||||
return {
|
||||
...command,
|
||||
to: '',
|
||||
onCommandClick: () => {
|
||||
searchRecord.objectSingularName === 'task'
|
||||
searchRecord.objectNameSingular === 'task'
|
||||
? openRecordInCommandMenu({
|
||||
recordId: searchRecord.recordId,
|
||||
objectNameSingular: CoreObjectNameSingular.Task,
|
||||
@ -69,7 +69,7 @@ export const useCommandMenuSearchRecords = () => {
|
||||
}
|
||||
return command;
|
||||
});
|
||||
}, [globalSearchData, openRecordInCommandMenu]);
|
||||
}, [searchData, openRecordInCommandMenu]);
|
||||
|
||||
return {
|
||||
loading,
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
import { getAvatarType } from '@/object-metadata/utils/getAvatarType';
|
||||
import { getBasePathToShowPage } from '@/object-metadata/utils/getBasePathToShowPage';
|
||||
import { SingleRecordPickerRecord } from '@/object-record/record-picker/single-record-picker/types/SingleRecordPickerRecord';
|
||||
import { GlobalSearchRecord } from '~/generated/graphql';
|
||||
import { SearchRecord } from '~/generated/graphql';
|
||||
|
||||
export const formatGlobalSearchRecordAsSingleRecordPickerRecord = (
|
||||
searchRecord: GlobalSearchRecord,
|
||||
export const formatSearchRecordAsSingleRecordPickerRecord = (
|
||||
searchRecord: SearchRecord,
|
||||
): SingleRecordPickerRecord => {
|
||||
return {
|
||||
id: searchRecord.recordId,
|
||||
name: searchRecord.label,
|
||||
avatarUrl: searchRecord.imageUrl ?? undefined,
|
||||
avatarType: getAvatarType(searchRecord.objectSingularName),
|
||||
avatarType: getAvatarType(searchRecord.objectNameSingular),
|
||||
linkToShowPage:
|
||||
getBasePathToShowPage({
|
||||
objectNameSingular: searchRecord.objectSingularName,
|
||||
objectNameSingular: searchRecord.objectNameSingular,
|
||||
}) + searchRecord.recordId,
|
||||
record: {
|
||||
id: searchRecord.recordId,
|
||||
__typename: searchRecord.objectSingularName,
|
||||
__typename: searchRecord.objectNameSingular,
|
||||
},
|
||||
};
|
||||
};
|
||||
@ -7,12 +7,9 @@ import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { WatchQueryFetchPolicy } from '@apollo/client';
|
||||
import { useMemo } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import {
|
||||
ObjectRecordFilterInput,
|
||||
useGlobalSearchQuery,
|
||||
} from '~/generated/graphql';
|
||||
import { logError } from '~/utils/logError';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { ObjectRecordFilterInput, useSearchQuery } from '~/generated/graphql';
|
||||
import { logError } from '~/utils/logError';
|
||||
|
||||
export type UseSearchRecordsParams = ObjectMetadataItemIdentifier & {
|
||||
limit?: number;
|
||||
@ -38,7 +35,7 @@ export const useObjectRecordSearchRecords = ({
|
||||
|
||||
const { enqueueSnackBar } = useSnackBar();
|
||||
|
||||
const { data, loading, error, previousData } = useGlobalSearchQuery({
|
||||
const { data, loading, error, previousData } = useSearchQuery({
|
||||
skip:
|
||||
skip ||
|
||||
!objectMetadataItem ||
|
||||
@ -53,11 +50,11 @@ export const useObjectRecordSearchRecords = ({
|
||||
fetchPolicy: fetchPolicy,
|
||||
onError: (error) => {
|
||||
logError(
|
||||
`useGlobalSearchRecords for "${objectMetadataItem.namePlural}" error : ` +
|
||||
`useSearchRecords for "${objectMetadataItem.namePlural}" error : ` +
|
||||
error,
|
||||
);
|
||||
enqueueSnackBar(
|
||||
`Error during useGlobalSearchRecords for "${objectMetadataItem.namePlural}", ${error.message}`,
|
||||
`Error during useSearchRecords for "${objectMetadataItem.namePlural}", ${error.message}`,
|
||||
{
|
||||
variant: SnackBarVariant.Error,
|
||||
},
|
||||
@ -68,7 +65,7 @@ export const useObjectRecordSearchRecords = ({
|
||||
const effectiveData = loading ? previousData : data;
|
||||
|
||||
const searchRecords = useMemo(
|
||||
() => effectiveData?.globalSearch || [],
|
||||
() => effectiveData?.search || [],
|
||||
[effectiveData],
|
||||
);
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import { SelectableItem } from '@/ui/layout/selectable-list/components/Selectabl
|
||||
import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
|
||||
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
||||
import { useRecoilComponentFamilyValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyValueV2';
|
||||
import { GlobalSearchRecord } from '~/generated-metadata/graphql';
|
||||
import { SearchRecord } from '~/generated-metadata/graphql';
|
||||
|
||||
export const StyledSelectableItem = styled(SelectableItem)`
|
||||
height: 100%;
|
||||
@ -20,7 +20,7 @@ export const StyledSelectableItem = styled(SelectableItem)`
|
||||
`;
|
||||
|
||||
type MultipleRecordPickerMenuItemContentProps = {
|
||||
searchRecord: GlobalSearchRecord;
|
||||
searchRecord: SearchRecord;
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
onChange: (morphItem: RecordPickerPickableMorphItem) => void;
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { MAX_SEARCH_RESULTS } from '@/command-menu/constants/MaxSearchResults';
|
||||
import { globalSearch } from '@/command-menu/graphql/queries/globalSearch';
|
||||
import { search } from '@/command-menu/graphql/queries/search';
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { usePerformCombinedFindManyRecords } from '@/object-record/multiple-objects/hooks/usePerformCombinedFindManyRecords';
|
||||
import { multipleRecordPickerPickableMorphItemsComponentState } from '@/object-record/record-picker/multiple-record-picker/states/multipleRecordPickerPickableMorphItemsComponentState';
|
||||
@ -10,8 +10,8 @@ import { RecordPickerPickableMorphItem } from '@/object-record/record-picker/typ
|
||||
import { ApolloClient, useApolloClient } from '@apollo/client';
|
||||
import { isNonEmptyArray } from '@sniptt/guards';
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
import { GlobalSearchRecord } from '~/generated-metadata/graphql';
|
||||
import { capitalize, isDefined } from 'twenty-shared/utils';
|
||||
import { SearchRecord } from '~/generated-metadata/graphql';
|
||||
|
||||
export const useMultipleRecordPickerPerformSearch = () => {
|
||||
const client = useApolloClient();
|
||||
@ -117,23 +117,23 @@ export const useMultipleRecordPickerPerformSearch = () => {
|
||||
const morphItems = [
|
||||
...updatedPickedMorphItems,
|
||||
...searchRecordsFilteredOnPickedRecordsWithoutDuplicates.map(
|
||||
({ recordId, objectSingularName }) => ({
|
||||
({ recordId, objectNameSingular }) => ({
|
||||
isMatchingSearchFilter: true,
|
||||
isSelected: true,
|
||||
objectMetadataId: searchableObjectMetadataItems.find(
|
||||
(objectMetadata) =>
|
||||
objectMetadata.nameSingular === objectSingularName,
|
||||
objectMetadata.nameSingular === objectNameSingular,
|
||||
)?.id,
|
||||
recordId,
|
||||
}),
|
||||
),
|
||||
...searchRecordsExcludingPickedRecordsWithoutDuplicates.map(
|
||||
({ recordId, objectSingularName }) => ({
|
||||
({ recordId, objectNameSingular }) => ({
|
||||
isMatchingSearchFilter: true,
|
||||
isSelected: false,
|
||||
objectMetadataId: searchableObjectMetadataItems.find(
|
||||
(objectMetadata) =>
|
||||
objectMetadata.nameSingular === objectSingularName,
|
||||
objectMetadata.nameSingular === objectNameSingular,
|
||||
)?.id,
|
||||
recordId,
|
||||
}),
|
||||
@ -168,8 +168,8 @@ export const useMultipleRecordPickerPerformSearch = () => {
|
||||
.map(({ nameSingular }) => {
|
||||
const recordIdsForMetadataItem = searchRecords
|
||||
.filter(
|
||||
({ objectSingularName }) =>
|
||||
objectSingularName === nameSingular,
|
||||
({ objectNameSingular }) =>
|
||||
objectNameSingular === nameSingular,
|
||||
)
|
||||
.map(({ recordId }) => recordId);
|
||||
|
||||
@ -251,14 +251,14 @@ const performSearchQueries = async ({
|
||||
searchFilter: string;
|
||||
searchableObjectMetadataItems: ObjectMetadataItem[];
|
||||
pickedRecordIds: string[];
|
||||
}): Promise<[GlobalSearchRecord[], GlobalSearchRecord[]]> => {
|
||||
}): Promise<[SearchRecord[], SearchRecord[]]> => {
|
||||
if (searchableObjectMetadataItems.length === 0) {
|
||||
return [[], []];
|
||||
}
|
||||
|
||||
const searchRecords = async (filter: any) => {
|
||||
const { data } = await client.query({
|
||||
query: globalSearch,
|
||||
query: search,
|
||||
variables: {
|
||||
searchInput: searchFilter,
|
||||
includedObjectNameSingulars: searchableObjectMetadataItems.map(
|
||||
@ -268,7 +268,7 @@ const performSearchQueries = async ({
|
||||
limit: MAX_SEARCH_RESULTS,
|
||||
},
|
||||
});
|
||||
return data.globalSearch;
|
||||
return data.search;
|
||||
};
|
||||
|
||||
const searchRecordsExcludingPickedRecords = await searchRecords(
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { MultipleRecordPickerComponentInstanceContext } from '@/object-record/record-picker/multiple-record-picker/states/contexts/MultipleRecordPickerComponentInstanceContext';
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { createComponentFamilyStateV2 } from '@/ui/utilities/state/component-state/utils/createComponentFamilyStateV2';
|
||||
import { GlobalSearchRecord } from '~/generated-metadata/graphql';
|
||||
import { SearchRecord } from '~/generated-metadata/graphql';
|
||||
|
||||
export const searchRecordStoreComponentFamilyState =
|
||||
createComponentFamilyStateV2<
|
||||
(GlobalSearchRecord & { record?: ObjectRecord }) | undefined,
|
||||
(SearchRecord & { record?: ObjectRecord }) | undefined,
|
||||
string
|
||||
>({
|
||||
key: 'searchRecordStoreComponentFamilyState',
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { formatGlobalSearchRecordAsSingleRecordPickerRecord } from '@/object-metadata/utils/formatGlobalSearchRecordAsSingleRecordPickerRecord';
|
||||
import { formatSearchRecordAsSingleRecordPickerRecord } from '@/object-metadata/utils/formatSearchRecordAsSingleRecordPickerRecord';
|
||||
import { DEFAULT_SEARCH_REQUEST_LIMIT } from '@/object-record/constants/DefaultSearchRequestLimit';
|
||||
import { useObjectRecordSearchRecords } from '@/object-record/hooks/useObjectRecordSearchRecords';
|
||||
import { SingleRecordPickerRecord } from '@/object-record/record-picker/single-record-picker/types/SingleRecordPickerRecord';
|
||||
@ -57,13 +57,13 @@ export const useFilteredSearchRecordQuery = ({
|
||||
|
||||
return {
|
||||
selectedRecords: selectedRecords
|
||||
.map(formatGlobalSearchRecordAsSingleRecordPickerRecord)
|
||||
.map(formatSearchRecordAsSingleRecordPickerRecord)
|
||||
.filter(isDefined),
|
||||
filteredSelectedRecords: filteredSelectedRecords
|
||||
.map(formatGlobalSearchRecordAsSingleRecordPickerRecord)
|
||||
.map(formatSearchRecordAsSingleRecordPickerRecord)
|
||||
.filter(isDefined),
|
||||
recordsToSelect: recordsToSelect
|
||||
.map(formatGlobalSearchRecordAsSingleRecordPickerRecord)
|
||||
.map(formatSearchRecordAsSingleRecordPickerRecord)
|
||||
.filter(isDefined),
|
||||
loading:
|
||||
recordsToSelectLoading ||
|
||||
|
||||
@ -22,8 +22,8 @@ import {
|
||||
TooltipDelay,
|
||||
} from 'twenty-ui';
|
||||
import {
|
||||
GlobalSearchRecord,
|
||||
Role,
|
||||
SearchRecord,
|
||||
WorkspaceMember,
|
||||
} from '~/generated-metadata/graphql';
|
||||
import {
|
||||
@ -134,7 +134,7 @@ export const RoleAssignment = ({ role }: RoleAssignmentProps) => {
|
||||
};
|
||||
|
||||
const handleSelectWorkspaceMember = (
|
||||
workspaceMemberSearchRecord: GlobalSearchRecord,
|
||||
workspaceMemberSearchRecord: SearchRecord,
|
||||
) => {
|
||||
const existingRole = workspaceMemberRoleMap.get(
|
||||
workspaceMemberSearchRecord.recordId,
|
||||
|
||||
@ -6,11 +6,11 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop
|
||||
import { DropdownMenuSearchInput } from '@/ui/layout/dropdown/components/DropdownMenuSearchInput';
|
||||
import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator';
|
||||
import { ChangeEvent, useState } from 'react';
|
||||
import { GlobalSearchRecord } from '~/generated-metadata/graphql';
|
||||
import { SearchRecord } from '~/generated-metadata/graphql';
|
||||
|
||||
type RoleAssignmentWorkspaceMemberPickerDropdownProps = {
|
||||
excludedWorkspaceMemberIds: string[];
|
||||
onSelect: (workspaceMemberSearchRecord: GlobalSearchRecord) => void;
|
||||
onSelect: (workspaceMemberSearchRecord: SearchRecord) => void;
|
||||
};
|
||||
|
||||
export const RoleAssignmentWorkspaceMemberPickerDropdown = ({
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { MenuItem, MenuItemAvatar } from 'twenty-ui';
|
||||
import { GlobalSearchRecord } from '~/generated-metadata/graphql';
|
||||
import { SearchRecord } from '~/generated-metadata/graphql';
|
||||
|
||||
type RoleAssignmentWorkspaceMemberPickerDropdownContentProps = {
|
||||
loading: boolean;
|
||||
searchFilter: string;
|
||||
filteredWorkspaceMembers: GlobalSearchRecord[];
|
||||
onSelect: (workspaceMemberSearchRecord: GlobalSearchRecord) => void;
|
||||
filteredWorkspaceMembers: SearchRecord[];
|
||||
onSelect: (workspaceMemberSearchRecord: SearchRecord) => void;
|
||||
};
|
||||
|
||||
export const RoleAssignmentWorkspaceMemberPickerDropdownContent = ({
|
||||
|
||||
@ -182,41 +182,41 @@ export const graphqlMocks = {
|
||||
},
|
||||
});
|
||||
}),
|
||||
graphql.query('GlobalSearch', () => {
|
||||
graphql.query('Search', () => {
|
||||
return HttpResponse.json({
|
||||
data: {
|
||||
globalSearch: [
|
||||
search: [
|
||||
{
|
||||
__typename: 'GlobalSearchRecordDTO',
|
||||
__typename: 'SearchRecordDTO',
|
||||
recordId: '20202020-2d40-4e49-8df4-9c6a049191de',
|
||||
objectSingularName: 'person',
|
||||
objectNameSingular: 'person',
|
||||
label: 'Louis Duss',
|
||||
imageUrl: '',
|
||||
tsRankCD: 0.2,
|
||||
tsRank: 0.12158542,
|
||||
},
|
||||
{
|
||||
__typename: 'GlobalSearchRecordDTO',
|
||||
__typename: 'SearchRecordDTO',
|
||||
recordId: '20202020-3ec3-4fe3-8997-b76aa0bfa408',
|
||||
objectSingularName: 'company',
|
||||
objectNameSingular: 'company',
|
||||
label: 'Linkedin',
|
||||
imageUrl: 'https://twenty-icons.com/linkedin.com',
|
||||
tsRankCD: 0.2,
|
||||
tsRank: 0.12158542,
|
||||
},
|
||||
{
|
||||
__typename: 'GlobalSearchRecordDTO',
|
||||
__typename: 'SearchRecordDTO',
|
||||
recordId: '20202020-3f74-492d-a101-2a70f50a1645',
|
||||
objectSingularName: 'company',
|
||||
objectNameSingular: 'company',
|
||||
label: 'Libeo',
|
||||
imageUrl: 'https://twenty-icons.com/libeo.io',
|
||||
tsRankCD: 0.2,
|
||||
tsRank: 0.12158542,
|
||||
},
|
||||
{
|
||||
__typename: 'GlobalSearchRecordDTO',
|
||||
__typename: 'SearchRecordDTO',
|
||||
recordId: '20202020-ac73-4797-824e-87a1f5aea9e0',
|
||||
objectSingularName: 'person',
|
||||
objectNameSingular: 'person',
|
||||
label: 'Sylvie Palmer',
|
||||
imageUrl: '',
|
||||
tsRankCD: 0.1,
|
||||
@ -226,45 +226,6 @@ export const graphqlMocks = {
|
||||
},
|
||||
});
|
||||
}),
|
||||
graphql.query('CombinedSearchRecords', () => {
|
||||
return HttpResponse.json({
|
||||
data: {
|
||||
searchOpportunities: {
|
||||
edges: [],
|
||||
pageInfo: {
|
||||
hasNextPage: false,
|
||||
hasPreviousPage: false,
|
||||
startCursor: null,
|
||||
endCursor: null,
|
||||
},
|
||||
},
|
||||
searchCompanies: {
|
||||
edges: companiesMock.slice(0, 3).map((company) => ({
|
||||
node: company,
|
||||
cursor: null,
|
||||
})),
|
||||
pageInfo: {
|
||||
hasNextPage: false,
|
||||
hasPreviousPage: false,
|
||||
startCursor: null,
|
||||
endCursor: null,
|
||||
},
|
||||
},
|
||||
searchPeople: {
|
||||
edges: peopleMock.slice(0, 3).map((person) => ({
|
||||
node: person,
|
||||
cursor: null,
|
||||
})),
|
||||
pageInfo: {
|
||||
hasNextPage: false,
|
||||
hasPreviousPage: false,
|
||||
startCursor: null,
|
||||
endCursor: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}),
|
||||
graphql.query('FindManyViews', ({ variables }) => {
|
||||
const objectMetadataId = variables.filter?.objectMetadataId?.eq;
|
||||
const viewType = variables.filter?.type?.eq;
|
||||
|
||||
Reference in New Issue
Block a user