mirror of
https://github.com/twentyhq/twenty.git
synced 2024-08-17 01:40:44 +03:00
This pull request introduces a new `FieldMetadataType` called `ACTOR`.
The primary objective of this new type is to add an extra column to the
following objects: `person`, `company`, `opportunity`, `note`, `task`,
and all custom objects.
This composite type contains three properties:
- `source`
```typescript
export enum FieldActorSource {
EMAIL = 'EMAIL',
CALENDAR = 'CALENDAR',
API = 'API',
IMPORT = 'IMPORT',
MANUAL = 'MANUAL',
}
```
- `workspaceMemberId`
- This property can be `undefined` in some cases and refers to the
member who created the record.
- `name`
- Serves as a fallback if the `workspaceMember` is deleted and is used
for other source types like `API`.
### Functionality
The pre-hook system has been updated to allow real-time argument
updates. When a record is created, a pre-hook can now compute and update
the arguments accordingly. This enhancement enables the `createdBy`
field to be populated with the correct values based on the
`authContext`.
The `authContext` now includes:
- An optional User entity
- An optional ApiKey entity
- The workspace entity
This provides access to the necessary data for the `createdBy` field.
In the GraphQL API, only the `source` can be specified in the
`createdBy` input. This allows the front-end to specify the source when
creating records from a CSV file.
### Front-End Handling
On the front-end, `orderBy` and `filter` are only applied to the name
property of the `ACTOR` composite type. Currently, we are unable to
apply these operations to the workspace member relation. This means that
if a workspace member changes their first name or last name, there may
be a mismatch because the name will differ from the new one. The name
displayed on the screen is based on the workspace member entity when
available.
### Missing Components
Currently, this PR does not include a `createdBy` value for the `MAIL`
and `CALENDAR` sources. These records are created in a job, and at
present, we only have access to the workspaceId within the job. To
address this, we should use a function similar to
`loadServiceWithContext`, which was recently removed from `TwentyORM`.
This function would allow us to pass the `authContext` to the jobs
without disrupting existing jobs.
Another PR will be created to handle these cases.
### Related Issues
Fixes issue #5155.
### Additional Notes
This PR doesn't include the migrations of the current records and views.
Everything works properly when the database is reset but this part is
still missing for now. We'll add that in another PR.
- There is a minor issue: front-end tests are broken since this commit:
[80c0fc7ff1
).
---------
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
68 lines
1.9 KiB
TypeScript
68 lines
1.9 KiB
TypeScript
/// <reference types='vitest' />
|
|
import react from '@vitejs/plugin-react-swc';
|
|
import wyw from '@wyw-in-js/vite';
|
|
import * as path from 'path';
|
|
import { defineConfig } from 'vite';
|
|
import checker from 'vite-plugin-checker';
|
|
import dts from 'vite-plugin-dts';
|
|
import svgr from 'vite-plugin-svgr';
|
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
|
|
// eslint-disable-next-line @nx/enforce-module-boundaries, import/no-relative-packages
|
|
import packageJson from '../../package.json';
|
|
|
|
export default defineConfig({
|
|
root: __dirname,
|
|
cacheDir: '../../node_modules/.vite/packages/twenty-ui',
|
|
|
|
plugins: [
|
|
react({ jsxImportSource: '@emotion/react' }),
|
|
tsconfigPaths(),
|
|
svgr(),
|
|
dts({
|
|
entryRoot: 'src',
|
|
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
|
|
}),
|
|
checker({
|
|
typescript: {
|
|
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
|
|
},
|
|
}),
|
|
wyw({
|
|
include: [
|
|
'**/OverflowingTextWithTooltip.tsx',
|
|
'**/Chip.tsx',
|
|
'**/Tag.tsx',
|
|
'**/Avatar.tsx',
|
|
'**/AvatarChip.tsx',
|
|
],
|
|
babelOptions: {
|
|
presets: ['@babel/preset-typescript', '@babel/preset-react'],
|
|
},
|
|
}),
|
|
],
|
|
|
|
// Configuration for building your library.
|
|
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
build: {
|
|
outDir: './dist',
|
|
reportCompressedSize: true,
|
|
commonjsOptions: {
|
|
transformMixedEsModules: true,
|
|
},
|
|
lib: {
|
|
// Could also be a dictionary or array of multiple entry points.
|
|
entry: 'src/index.ts',
|
|
name: 'twenty-ui',
|
|
fileName: 'index',
|
|
// Change this to the formats you want to support.
|
|
// Don't forget to update your package.json as well.
|
|
formats: ['es', 'cjs'],
|
|
},
|
|
rollupOptions: {
|
|
// External packages that should not be bundled into your library.
|
|
external: Object.keys(packageJson.dependencies || {}),
|
|
},
|
|
},
|
|
});
|