Add translations on core views (#13895)
closes https://github.com/twentyhq/twenty/issues/11999
This commit is contained in:
+17
-14
@@ -1,3 +1,4 @@
|
||||
import { isString } from '@sniptt/guards';
|
||||
import { type ViewFilterOperand as SharedViewFilterOperand } from 'twenty-shared/types';
|
||||
import { type DataSource, type QueryRunner } from 'typeorm';
|
||||
import { v4 } from 'uuid';
|
||||
@@ -14,7 +15,7 @@ import { companiesAllView } from 'src/engine/workspace-manager/standard-objects-
|
||||
import { customAllView } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/custom-all.view';
|
||||
import { notesAllView } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/notes-all.view';
|
||||
import { opportunitiesAllView } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/opportunities-all.view';
|
||||
import { opportunitiesByStageView } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/opportunity-by-stage.view';
|
||||
import { opportunitiesTableByStageView } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/opportunity-table-by-stage.view';
|
||||
import { peopleAllView } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/people-all.view';
|
||||
import { tasksAllView } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/tasks-all.view';
|
||||
import { tasksAssignedToMeView } from 'src/engine/workspace-manager/standard-objects-prefill-data/views/tasks-assigned-to-me';
|
||||
@@ -34,21 +35,21 @@ export const prefillCoreViews = async (
|
||||
);
|
||||
|
||||
const customViews = customObjectMetadataItems.map((item) =>
|
||||
customAllView(item),
|
||||
customAllView(item, true),
|
||||
);
|
||||
|
||||
const views = [
|
||||
companiesAllView(objectMetadataItems),
|
||||
peopleAllView(objectMetadataItems),
|
||||
opportunitiesAllView(objectMetadataItems),
|
||||
opportunitiesByStageView(objectMetadataItems),
|
||||
notesAllView(objectMetadataItems),
|
||||
tasksAllView(objectMetadataItems),
|
||||
tasksAssignedToMeView(objectMetadataItems),
|
||||
tasksByStatusView(objectMetadataItems),
|
||||
workflowsAllView(objectMetadataItems),
|
||||
workflowVersionsAllView(objectMetadataItems),
|
||||
workflowRunsAllView(objectMetadataItems),
|
||||
companiesAllView(objectMetadataItems, true),
|
||||
peopleAllView(objectMetadataItems, true),
|
||||
opportunitiesAllView(objectMetadataItems, true),
|
||||
opportunitiesTableByStageView(objectMetadataItems, true),
|
||||
notesAllView(objectMetadataItems, true),
|
||||
tasksAllView(objectMetadataItems, true),
|
||||
tasksAssignedToMeView(objectMetadataItems, true),
|
||||
tasksByStatusView(objectMetadataItems, true),
|
||||
workflowsAllView(objectMetadataItems, true),
|
||||
workflowVersionsAllView(objectMetadataItems, true),
|
||||
workflowRunsAllView(objectMetadataItems, true),
|
||||
...customViews,
|
||||
];
|
||||
|
||||
@@ -93,18 +94,20 @@ const createCoreViews = async (
|
||||
key,
|
||||
position,
|
||||
icon,
|
||||
isCustom,
|
||||
openRecordIn,
|
||||
kanbanAggregateOperation,
|
||||
kanbanAggregateOperationFieldMetadataId,
|
||||
}) => ({
|
||||
id,
|
||||
name,
|
||||
name: isString(name) ? name : name.message || '',
|
||||
objectMetadataId,
|
||||
type: type === 'kanban' ? ViewType.KANBAN : ViewType.TABLE,
|
||||
key: key || undefined,
|
||||
position,
|
||||
icon,
|
||||
isCompact: false,
|
||||
isCustom: isCustom ?? false,
|
||||
openRecordIn:
|
||||
openRecordIn === 'SIDE_PANEL'
|
||||
? ViewOpenRecordIn.SIDE_PANEL
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ const createWorkspaceViews = async (
|
||||
kanbanAggregateOperationFieldMetadataId,
|
||||
}) => ({
|
||||
id,
|
||||
name,
|
||||
name: name as string,
|
||||
objectMetadataId,
|
||||
type,
|
||||
key,
|
||||
|
||||
+4
-1
@@ -1,14 +1,17 @@
|
||||
import { type MessageDescriptor } from '@lingui/core';
|
||||
|
||||
import { type AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { type ViewOpenRecordInType } from 'src/modules/view/standard-objects/view.workspace-entity';
|
||||
|
||||
export interface ViewDefinition {
|
||||
id?: string;
|
||||
name: string;
|
||||
name: string | MessageDescriptor;
|
||||
objectMetadataId: string;
|
||||
type: string;
|
||||
key: string | null;
|
||||
position: number;
|
||||
icon?: string;
|
||||
isCustom?: boolean;
|
||||
openRecordIn?: ViewOpenRecordInType;
|
||||
kanbanFieldMetadataId?: string;
|
||||
kanbanAggregateOperation?: AggregateOperations;
|
||||
|
||||
+4
-1
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import {
|
||||
@@ -8,6 +10,7 @@ import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync
|
||||
|
||||
export const companiesAllView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const companyObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.company,
|
||||
@@ -18,7 +21,7 @@ export const companiesAllView = (
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'All Companies',
|
||||
name: useCoreNaming ? msg`All {objectLabelPlural}` : 'All Companies',
|
||||
objectMetadataId: companyObjectMetadata.id ?? '',
|
||||
type: 'table',
|
||||
key: 'INDEX',
|
||||
|
||||
+10
-2
@@ -1,6 +1,11 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
|
||||
export const customAllView = (objectMetadataItem: ObjectMetadataEntity) => {
|
||||
export const customAllView = (
|
||||
objectMetadataItem: ObjectMetadataEntity,
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const nameField = objectMetadataItem.fields.find(
|
||||
(field) => field.name === 'name',
|
||||
);
|
||||
@@ -16,12 +21,15 @@ export const customAllView = (objectMetadataItem: ObjectMetadataEntity) => {
|
||||
}
|
||||
|
||||
return {
|
||||
name: `All ${objectMetadataItem.namePlural}`,
|
||||
name: useCoreNaming
|
||||
? msg`All {objectLabelPlural}`
|
||||
: `All ${objectMetadataItem.labelPlural}`,
|
||||
objectMetadataId: objectMetadataItem.id,
|
||||
type: 'table',
|
||||
key: 'INDEX',
|
||||
position: 0,
|
||||
icon: 'IconList',
|
||||
isCustom: false,
|
||||
kanbanFieldMetadataId: '',
|
||||
filters: [],
|
||||
fields: [
|
||||
|
||||
+7
-2
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
@@ -5,7 +7,10 @@ import {
|
||||
} from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
|
||||
|
||||
export const notesAllView = (objectMetadataItems: ObjectMetadataEntity[]) => {
|
||||
export const notesAllView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const noteObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.note,
|
||||
);
|
||||
@@ -15,7 +20,7 @@ export const notesAllView = (objectMetadataItems: ObjectMetadataEntity[]) => {
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'All Notes',
|
||||
name: useCoreNaming ? msg`All {objectLabelPlural}` : 'All Notes',
|
||||
objectMetadataId: noteObjectMetadata.id,
|
||||
type: 'table',
|
||||
key: 'INDEX',
|
||||
|
||||
+4
-1
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { OPPORTUNITY_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
@@ -5,6 +7,7 @@ import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync
|
||||
|
||||
export const opportunitiesAllView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const opportunityObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.opportunity,
|
||||
@@ -15,7 +18,7 @@ export const opportunitiesAllView = (
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'All Opportunities',
|
||||
name: useCoreNaming ? msg`All {objectLabelPlural}` : 'All Opportunities',
|
||||
objectMetadataId: opportunityObjectMetadata.id,
|
||||
type: 'table',
|
||||
key: 'INDEX',
|
||||
|
||||
+4
-1
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { OPPORTUNITY_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
@@ -5,6 +7,7 @@ import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync
|
||||
|
||||
export const opportunitiesByStageView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const opportunityObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.opportunity,
|
||||
@@ -15,7 +18,7 @@ export const opportunitiesByStageView = (
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'By Stage',
|
||||
name: useCoreNaming ? msg`By Stage` : 'By Stage',
|
||||
objectMetadataId: opportunityObjectMetadata.id,
|
||||
type: 'kanban',
|
||||
key: null,
|
||||
|
||||
+4
-1
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { OPPORTUNITY_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
@@ -5,6 +7,7 @@ import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync
|
||||
|
||||
export const opportunitiesTableByStageView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const opportunityObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.opportunity,
|
||||
@@ -15,7 +18,7 @@ export const opportunitiesTableByStageView = (
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'By Stage',
|
||||
name: useCoreNaming ? msg`By Stage` : 'By Stage',
|
||||
objectMetadataId: opportunityObjectMetadata.id,
|
||||
type: 'table',
|
||||
key: null,
|
||||
|
||||
+7
-2
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { AggregateOperations } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import {
|
||||
@@ -6,7 +8,10 @@ import {
|
||||
} from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
|
||||
|
||||
export const peopleAllView = (objectMetadataItems: ObjectMetadataEntity[]) => {
|
||||
export const peopleAllView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const personObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.person,
|
||||
);
|
||||
@@ -16,7 +21,7 @@ export const peopleAllView = (objectMetadataItems: ObjectMetadataEntity[]) => {
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'All People',
|
||||
name: useCoreNaming ? msg`All {objectLabelPlural}` : 'All People',
|
||||
objectMetadataId: personObjectMetadata.id,
|
||||
type: 'table',
|
||||
key: 'INDEX',
|
||||
|
||||
+7
-2
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
@@ -5,7 +7,10 @@ import {
|
||||
} from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
|
||||
|
||||
export const tasksAllView = (objectMetadataItems: ObjectMetadataEntity[]) => {
|
||||
export const tasksAllView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const taskObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.task,
|
||||
);
|
||||
@@ -15,7 +20,7 @@ export const tasksAllView = (objectMetadataItems: ObjectMetadataEntity[]) => {
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'All Tasks',
|
||||
name: useCoreNaming ? msg`All {objectLabelPlural}` : 'All Tasks',
|
||||
objectMetadataId: taskObjectMetadata.id,
|
||||
type: 'table',
|
||||
key: 'INDEX',
|
||||
|
||||
+4
-1
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
@@ -7,6 +9,7 @@ import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync
|
||||
|
||||
export const tasksAssignedToMeView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const taskObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.task,
|
||||
@@ -17,7 +20,7 @@ export const tasksAssignedToMeView = (
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'Assigned to Me',
|
||||
name: useCoreNaming ? msg`Assigned to Me` : 'Assigned to Me',
|
||||
objectMetadataId: taskObjectMetadata.id,
|
||||
type: 'table',
|
||||
key: null,
|
||||
|
||||
+4
-1
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
@@ -7,6 +9,7 @@ import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync
|
||||
|
||||
export const tasksByStatusView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const taskObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.task,
|
||||
@@ -17,7 +20,7 @@ export const tasksByStatusView = (
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'By Status',
|
||||
name: useCoreNaming ? msg`By Status` : 'By Status',
|
||||
objectMetadataId: taskObjectMetadata.id,
|
||||
type: 'kanban',
|
||||
key: null,
|
||||
|
||||
+4
-1
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { WORKFLOW_RUN_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
|
||||
@@ -5,6 +7,7 @@ import { ViewOpenRecordInType } from 'src/modules/view/standard-objects/view.wor
|
||||
|
||||
export const workflowRunsAllView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const workflowRunObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.workflowRun,
|
||||
@@ -15,7 +18,7 @@ export const workflowRunsAllView = (
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'All Workflow Runs',
|
||||
name: useCoreNaming ? msg`All {objectLabelPlural}` : 'All Workflow Runs',
|
||||
objectMetadataId: workflowRunObjectMetadata.id,
|
||||
type: 'table',
|
||||
key: 'INDEX',
|
||||
|
||||
+6
-1
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
@@ -8,6 +10,7 @@ import { ViewOpenRecordInType } from 'src/modules/view/standard-objects/view.wor
|
||||
|
||||
export const workflowVersionsAllView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const workflowVersionObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.workflowVersion,
|
||||
@@ -18,7 +21,9 @@ export const workflowVersionsAllView = (
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'All Workflow Versions',
|
||||
name: useCoreNaming
|
||||
? msg`All {objectLabelPlural}`
|
||||
: 'All Workflow Versions',
|
||||
objectMetadataId: workflowVersionObjectMetadata.id,
|
||||
type: 'table',
|
||||
key: 'INDEX',
|
||||
|
||||
+4
-1
@@ -1,3 +1,5 @@
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import {
|
||||
BASE_OBJECT_STANDARD_FIELD_IDS,
|
||||
@@ -8,6 +10,7 @@ import { ViewOpenRecordInType } from 'src/modules/view/standard-objects/view.wor
|
||||
|
||||
export const workflowsAllView = (
|
||||
objectMetadataItems: ObjectMetadataEntity[],
|
||||
useCoreNaming = false,
|
||||
) => {
|
||||
const workflowObjectMetadata = objectMetadataItems.find(
|
||||
(object) => object.standardId === STANDARD_OBJECT_IDS.workflow,
|
||||
@@ -18,7 +21,7 @@ export const workflowsAllView = (
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'All Workflows',
|
||||
name: useCoreNaming ? msg`All {objectLabelPlural}` : 'All Workflows',
|
||||
objectMetadataId: workflowObjectMetadata.id,
|
||||
type: 'table',
|
||||
key: 'INDEX',
|
||||
|
||||
Reference in New Issue
Block a user