Commit Graph

1908 Commits

Author SHA1 Message Date
Baptiste Devessier
e49acae851
Visualize Workflows (#6697)
## Features

- Fetch a workflow and display it in a tree with the React Flow library
- The nodes are positioned by an algorithm
- The feature is put behind a feature flag. The `/workflow/:id` route is
disabled if the flag is off.
- I started implementing a right drawer. That's a big WIP and it will be
finished in another PR.

## How to test this feature

1. Create a workflow instance in the database through a GraphQL query.
See below for instructions.
2. After enabling the feature flag, you should be able to see the
workflow you created in the workflows list. To visualize the workflow,
go to the `/workflow/:id` page where the id is the id of the workflow.
See the video for a quick way to do so.

```gql
// First
mutation createWorkflow($data: WorkflowCreateInput!) {
  createWorkflow(data: $data) {
    id
  }
}

// Result
{
  "data": {
    "name": "test"
  }
}

// Second
mutation createWorkflowVersion($data: WorkflowVersionCreateInput!) {
  createWorkflowVersion (data: $data) {
    id
  }
}

// Result
{
  "data": {
    "name": "v1",
    "trigger": {
  "name": "trigger",
"displayName": "New or Updated Row",
"type": "DATABASE_EVENT",
"settings": {
"eventName": "company.created",
"triggerName": "Company Created"
},
  "nextAction": {
    "name": "step_1",
    "displayName": "Code",
    "type": "CODE",
    "valid": true,
    "settings": {
      "serverlessFunctionId": "function_id",
      "errorHandlingOptions": {
        "retryOnFailure": {
          "value": false
        },
        "continueOnFailure": {
          "value": false
        }
      }
    }
  }
},
"workflowId": "workflow_id"
  }
}
```


https://github.com/user-attachments/assets/42bbd98c-5e13-447c-9307-461a18ac2195
2024-08-23 17:50:13 +02:00
martmull
873a4c1bd1
Fix serverless save when name empty (#6720)
- fix serverless function error on save when name empty
- remove useless unique constraint on serverless function names
2024-08-23 17:34:31 +02:00
nitin
5d8162dc09
Added hotkeyScopes to serverless functions in settings (#6710)
Fixes #6656 
Is this the right way to implement keyboard listeners?
Please let me know, I'll make the changes accordingly.
:)


https://github.com/user-attachments/assets/af71d340-ead9-4659-81e6-a440522a194f

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-23 16:54:21 +02:00
martmull
f9af25b57e
Fix sentry issue (#6719)
https://twenty-v7.sentry.io/issues/5677123076/?environment=prod&project=4507072499810304&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=7d&stream_index=12

Removes billing section when is_free_access_enabled
2024-08-23 16:01:40 +02:00
Marie
ee6180a76f
[Fix] Prevent fields name conflicts with composite subfields names (#6713)
At field creation we are checking the availability of the name by
comparing it to the other fields' names' on the object; but for
composite fields the fields' names' as indicated in the repository do
not exactly match the column names' on the tables (e.g "createdBy" field
is actually represented by columns createdByName, createdBySource etc.).

In this PR we prevent the conflict with the standard composite fields'
names.
There is still room for errors with the custom composite fields: for
example a custom composite field "address" of type address on a custom
object "listing" will introduce the columns addressAddressStreet1,
addressAddressStreet2 etc. while we won't prevent the user from later
creating a custom field named "addressAddressStreet1".
For now I decided not to tackle this as this seem extremely edgy + would
impact performance on creation of all fields while never actually useful
(I think).
2024-08-23 13:24:10 +02:00
Marie
981f311ed0
Fix addition of new option in select field if there are no existing options (#6718)
Fixes
[sentry](https://twenty-v7.sentry.io/issues/5745628875/?alert_rule_id=15135099&alert_type=issue&notification_uuid=95108411-b431-4abd-bdd6-687c96a7353e&project=4507072563183616&referrer=discord)
2024-08-23 12:13:49 +02:00
martmull
6f9aa1e870
6654 serverless functions add a deploy button disable deploy when autosave (#6715)
- improvements on serverless function behavior (autosave performances,
deploy on execution only)
- add versioning to serverless functions
- add a publish endpoint to create a new version of a serverless
function
  - add deploy and reset to lastVersion button in the settings section:
<img width="736" alt="image"
src="https://github.com/user-attachments/assets/2001f8d2-07a4-4f79-84dd-ec74b6f301d3">
2024-08-23 12:06:03 +02:00
gitstart-app[bot]
7ca091faa5
Add isInactive to FieldMetadata decorator (#6623)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-4145](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-4145).
This ticket was imported from:
[TWNTY-4145](https://github.com/twentyhq/twenty/issues/4145)

 --- 
### Description
This PR introduces the @isInActive() decorator to the standard field
metadata. \
- This gives the ability to allow workspaces to be able to be created
with standard fields as inactive *Helps prevent polluting existing
workspaces
- A new standard field can be added to* eg company-workspace-entity.ts
and the @WorkspaceIsInActive() decorator can be added to create it in
deactivated mode
sync-metadata command: `yarn command:prod workspace:sync-metadata -f`

### Refs
#4145 

### Demo

<https://www.loom.com/share/10c13e2614d749809cfe2d2d847e963e?sid=017bbfcf-53c6-4205-8ffc-8a09c416220a>\

<https://www.loom.com/share/6ab86bd36f344c999cb8dacdb82c7bb0?sid=13ac78a2-de44-4772-bb54-7b57975e7360>\

Fixes: #4145

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-22 18:37:06 +02:00
Raphaël Bosi
1eeeae8564
6686 Add try catch on every cron job, and send exception to exceptionHandler (#6705)
Closes #6686

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-22 18:23:05 +02:00
nitin
1030ff43d8
Created a specific scroll wrapper context per scroll wrapper and made ScrollTop and ScrollLeft componentStates (#6645)
@lucasbordeau @charlesBochet 

Issue #4826 

Could u review this changes.

Let me know what do you think.

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-22 18:21:14 +02:00
Thomas Trompette
0a7700351f
Update workflow version struct (#6716)
We want to avoid the nested structure of active pieces. Steps to execute
will now be separated from the trigger. It will be an array executed
sequentially.

For now a step can only be an action. But at some point it will also be
a branch or a loop
2024-08-22 17:59:16 +02:00
Raphaël Bosi
579c2ebcea
6687 change messaging import cron job to run every minute (#6704)
Closes #6687
2024-08-22 17:51:08 +02:00
gitstart-app[bot]
9898ca3e53
TWNTY-6135 - Improve Data Importer Select Matching (#6338)
### Description:

- we move all logic about the unmatchedOptions to a new component called
UnmatchColumn, because as it will be a full line in the table, it was
better to update where the component will be rendered
- In the latest changes to keep the columns when we change the step to
step 3 and go back to step 2, we added a fallback state
initialComputedColumnsState that saves the columns and only reverts the
updates when we go back to step 1 or close by clicking the X button

### Refs: 

#6135

```
It was necessary to add references and floating styles to the generic component to fix the bug when the last option was open and the dropdown was being hidden in the next row of the spreadsheet table. We fixed the same problem that occurs in the companies table as well
```

we used this approach mentioned on this documentation to be able to use
the hook without calling it on each component, we are calling only once,
on the shared component
<https://floating-ui.com/docs/useFloating#elements>\
before:


![](https://assets-service.gitstart.com/25493/2c994e0f-6548-4a9e-8b22-2c6eccb73b2e.png)

now:


![](https://assets-service.gitstart.com/25493/f56fd516-7e95-4616-b1ed-c9ea5195a8ae.png)###
Demo: <https://jam.dev/c/e0e0b921-7551-4a94-ac1c-8a50c53fdb0c>

Fixes #6135

NOTES: the enter key are not working on main branch too

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-22 17:42:49 +02:00
Charles Bochet
eab202f107
Make workspaceMemberId optional in JWT for workspaces that are not ACTIVE (#6714)
WorkspaceMemberId is mandatory in the jwt token generated for a given
user on a given workspace.
However, when a user signs up, it does not have a workspaceMemberId yet.
2024-08-22 00:28:19 +02:00
Charles Bochet
da4bd73881 Fix logging error in webhook system 2024-08-21 20:12:14 +02:00
Thomas Trompette
be50a6256f
Check workflow version is valid before publishing (#6702)
Fix https://github.com/twentyhq/twenty/issues/6670
2024-08-21 17:56:33 +02:00
Thomas Trompette
663acd56e4
Trigger workflow run manually (#6696)
Fix https://github.com/twentyhq/twenty/issues/6669

- create a commun function `startWorkflowRun` that both create the run
object and the job for executing the workflow
- use it in both the `workflowEventJob` and the `runWorkflowVersion`
endpoint

Bonus:
- use filtering for exceptions instead of a util. It avoids doing a try
catch in all endpoint
2024-08-21 17:41:26 +02:00
nitin
da5dfb7a5b
corrected targetableobject being undefined when clicked on create task in command menu (#6635)
Issue #6630

It seems this bug is caused by `targetableObjects` being assigned an
empty array, which then leads to an error due to it being undefined.
I've made some changes that should address the issue, but I would
appreciate any feedback or suggestions on alternative solutions.

Please let me know if there is a better approach to resolving this.

Thank you!








https://github.com/user-attachments/assets/d6409798-3320-49b3-834f-2b6888847ed8
2024-08-21 16:36:04 +02:00
Charles Bochet
c2cf8b4554 Bump version to 0.23.2 2024-08-21 15:39:55 +02:00
Charles Bochet
79641327f3
Fix webhook issue (#6711)
Fix
[#web](https://github.com/orgs/twentyhq/projects/1/views/3?pane=issue&itemId=75329194)

This PR does 2 things:
- migrate webhooks to TwentyORM
- Fix inversion between objectNameSingular and operation in webhook
eventName. It is stored as {objectNameSingular}.{operation} and we were
querying {operation}.{objectNameSingular}
2024-08-21 15:33:38 +02:00
Charles Bochet
612a875c7b
Remove performance logs (#6709)
We have found the root cause of the issue:
- when using a datasource (including the cached ones), we are fetching
ObjectMetadataCollection from cache (700kB). Datasource usage is
happening any time we are using twentyORM, which is everywhere in the
jobs and in some resolvers (including the GetCurrentUser one). This is
leading to a high load on redis and leading to the performance issues we
are seeing.
- we actually don't need to fetch this objectMetadataCollection while
using a cached datasource, only when we instantiate a new one
2024-08-21 14:17:11 +02:00
Marie
aa4ae53fb4
[Fix] field does not appear directly after creation (#6708) 2024-08-21 12:08:57 +02:00
Charles Bochet
614a81860f
Add logging on currentWorkspaceMember query (#6706)
We are experiencing slow GetCurrentUser endpoint, this is helping us
troubleshoot
2024-08-21 11:48:20 +02:00
gitstart-app[bot]
6caa78008f
If an object is disabled, then the relationships to that object should be disabled (#6690)
This PR was created by [GitStart](https://gitstart.com/) to address the
requirements from this ticket:
[TWNTY-5370](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-5370).
This ticket was imported from:
[TWNTY-5370](https://github.com/twentyhq/twenty/issues/5370)

 --- 


### Description

- We updated the logic in
packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.service.ts
  
  Test cases:
1. Ensure that when an object is disabled, all related relationships are
also disabled.
         a. Example disable the people object
b. Check the company object and verify that the people field has been
disabled too
c. Check the opportunity object and check that the point of contact
field has been disabled too
2. Verify that when a previously disabled object is restored, the
relationships are also restored.
3. Ensure that previously disabled relationships remain disabled when
the object is disabled and later restored.
4. Verify that relationships of a disabled object are not visible in the
UI.
5. Ensure that relationships to a disabled object are marked as inactive
in the data models screen

 ### Refs

#5370

  
### Demo
  

<https://www.loom.com/share/2b0a91f463ca4e02a6963f9a8796a0d9?sid=1e9c4fb8-8fb9-4c6c-b43a-c50f3776e1d3>

Fixes #5370

---------

Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com>
Co-authored-by: Marie Stoppa <marie.stoppa@essec.edu>
2024-08-21 11:19:21 +02:00
Charles Bochet
08e07ac2d5 Update graphql-yoga patch in yarn.lock 2024-08-21 00:39:55 +02:00
Raphaël Bosi
091c0f83be
6619 modify event emitter to emit an array of events (#6625)
Closes #6619

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-20 19:44:29 +02:00
Charles Bochet
17a1760afd
Improve performance twenty orm (#6691)
## Context

As we grow, the messaging scripts are experiencing performance issues
forcing us to temporarily disable them on the cloud.
While investigating the performance, I have noticed that generating the
entity schema (for twentyORM) in the repository is taking ~500ms locally
on my Mac M2 so likely more on pods. Caching the entitySchema then!

I'm also clarifying naming around schemaVersion and cacheVersions ==>
both are renamed workspaceMetadataVersion and migrated to the workspace
table (the workspaceCacheVersion table is dropped).
2024-08-20 19:42:02 +02:00
Lucas Bordeau
3ae89d15de
Fix post merge (#6699)
Fixed settingsPreviewRecordId state naming.
2024-08-20 16:45:00 +02:00
Syed Md Mihan Chistie
be20a690b3
added typechecking for all ts files (#6466)
Fixes: #6436 

Changes made: 

- Added typecheck step before twenty-ui build to check stories TS errors
- Added a tsconfig.dev.json to add stories and tests to typecheking when
in dev mode
- Added tsconfig.dev.json to storybook dev command of twenty-ui to
typecheck stories while developing
- Fixed twenty-ui stories that were broken

- Added a serve command to serve front build
- Fixed unit test from another PR

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-20 11:05:13 +02:00
Charles Bochet
12a657ce29
Patch messaging import crons not running (#6688)
In 0.23.1, we have introduced a regression by migrating to TwentyORM ;
messageChannels were not considered as syncable anymore
2024-08-19 19:19:01 +02:00
Jérémy M
db54469c8a
feat: soft delete (#6576)
Implement soft delete on standards and custom objects.
This is a temporary solution, when we drop `pg_graphql` we should rely
on the `softDelete` functions of TypeORM.

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-16 21:20:02 +02:00
Nabhag Motivaras
20d84755bb
fix: exclude tabler/icons-react from optimizeDeps to avoid crashing performance CI (#6621)
## ISSUE (Warning)

- Fixes #6437 

### Things needed to investigate :

- [x] Can we exclude @tabler-icons from Babel / wyw-in-js / the vite
config of Storybook ?
> Yes we can

- [ ] Is there a reproducible difference between non-Linaria components
loading time and Linaria components loading times ?
> Couldn't find anything related to this, yet. but changes fix the
problem.
2024-08-16 16:18:45 +02:00
NitinPSingh
5404a8ba2d
fixes #6499 alignment issue on workspace switcher (#6589)
fix #6499 

- fix the size of workspace switcher to 32px from 40px

![Screenshot 2024-08-09
140212](https://github.com/user-attachments/assets/425c9089-8969-4d59-82ef-10572cfa7027)

- fix alignment issues

![Screenshot 2024-08-09
142357](https://github.com/user-attachments/assets/2e3e76f2-8a81-48e9-86ff-691c11215583)

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-16 15:31:04 +02:00
Raphaël Bosi
08c7947b3b
Use twentyORM in Timeline messaging (#6595)
- Remove raw queries and replace them by using `twentyORM`
- Refactor into services and utils

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-08-15 10:15:32 +02:00
Thomas Trompette
6927f46e1c
Migrate to workspace services (#6628)
As title
2024-08-14 18:46:36 +02:00
Lucas Bordeau
c63c18aef1
Fix duplicate activities (#6627)
Activity creation was duplicating the new activity on already visited
records of the same type.

The fix was to activate `shouldMatchRootQueryFilter` on createOne for
activity.
2024-08-14 18:44:35 +02:00
Thomas Trompette
9e7714e627
Add workflow run entity (#6622)
- create a workflow run every time a workflow is triggered in
not_started status. This status will be helpful later for once workflows
will be scheduled
- update run status once workflow starts running
- complete status once the workflow finished running
- add a failed status if an error occurs
2024-08-14 18:27:32 +02:00
Lucas Bordeau
121794e3c0
Fixed modal clickoutside (#6624)
Modal clickoutside was modified recently.

It was considering portaled component like dropdown outside, so
comparePixel mode for click outside is needed here.
2024-08-14 17:50:18 +02:00
Nabhag Motivaras
197bca57ba
feat(e2e): twenty-e2e-testing with playwright (#6539)
## ISSUE (e2e) - Introduces e2e for twenty

 - Closes #6360
 
##  Description

- [x] Create Package. 
- [x] Setup environments such as baseUrl.
- [x] ignore CI configuration for now.
- [x] write a simple test to check if table is visible in companies tab.

### Running test with UI

```
yarn run test:e2e:ui
```

https://github.com/user-attachments/assets/a7b7ae35-8898-461e-8c7c-d3e4e9515aeb

### Running all test and seeing report

```
yarn run test:e2e
yarn run test:e2e:report
```



https://github.com/user-attachments/assets/2558a1f9-97cc-4f06-86f0-806f207eac5a

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-14 17:23:32 +02:00
Anand Krishnan M J
59e14fabb4
[Issue-5772] Add sort feature on settings tables (#5787)
## Proposed Changes
-  Introduce  a new custom hook - useTableSort to sort table content
-  Add test cases for the new custom hook
- Integrate useTableSort hook on to the table in settings object and
settings object field pages

## Related Issue

https://github.com/twentyhq/twenty/issues/5772

## Evidence


https://github.com/twentyhq/twenty/assets/87609792/8be456ce-2fa5-44ec-8bbd-70fb6c8fdb30

## Evidence after addressing review comments


https://github.com/twentyhq/twenty/assets/87609792/c267e3da-72f9-4c0e-8c94-a38122d6395e

## Further comments

Apologies for the large PR. Looking forward for the review

---------

Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-14 17:11:17 +02:00
Thomas Trompette
0f75e14ab2
Create default view for workflows + fix task and note targets (#6620)
As title
2024-08-14 12:04:41 +02:00
Raphaël Bosi
d1c278d6b2
6430 Part 1: remove all raw queries from the messaging and calendar modules (#6572)
Part 1 of #6430
- Remove all repositories which contained raw queries in `messaging`
module
- Replace them using `twentyORMManager`
2024-08-13 19:40:50 +02:00
Raphaël Bosi
40bbee8d9f
5x Fix cache performance issues (#6616)
Calling `getObjectMetadata` from `WorkspaceCacheStorageService` in every
query was causing big performance issues. The `objectMetadataCollection`
is now part of the `WorkspaceInternalContext` so we only instance it
once in the `WorkspaceDatasourceFactory`.
Queries are now much faster, for instance for TimelineCalendar, it went
from ~450ms to 80ms.
2024-08-13 17:54:55 +02:00
BOHEUS
65a961ff3e
Fix for #6597 Created by field can't have null value (#6614)
Fix for #6597
2024-08-13 09:07:50 +02:00
Raunak Singh Jolly
ecdbe26b09
Fixed: Drag and Drop Causes Flashing and Disappearing Cards (#6065)
Issue was "inView" was setting false due to root being scrollWrapper,
instead changed it to viewport.
Fixes: #6001 
[Screencast from 2024-06-27
22-50-59.webm](https://github.com/twentyhq/twenty/assets/59247136/408d5fb5-91ab-4d3a-881d-bbcaf4817a79)

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-12 19:17:32 +02:00
Hansol Yang
b6202fe98c
Issue6335: RecordInlineCell tree refactor with RecordInlineCellContext (#6537)
Fixes [#6335](https://github.com/twentyhq/twenty/issues/6335)

This pull request is for issue
[#6335](https://github.com/twentyhq/twenty/issues/6335): Refactor
RecordInlineCell tree with a Context to avoid props drilling. For the
refactoring, this PR made changes as below:

- Created new script RecordInlineCellContext.tsx: Defining a context to
pass in useContext()
- Updated RecordInlineCell.tsx: Passing the necessary props as context
values, wrapping with RecordInlineCellContext.Provider
- Updated RecordInlineCellContainer.tsx: Passing the props to
RecordInlineContainer as RecordInlineCellContext
- Updated RecordInlineCellDisplayMode.tsx: retrieves values from
useRecordInlineCellContext instead of directly assigning them
- RecordInlineCellValue.tsx: Removed values passed through
<RecordInlineCellDisplayMode> as they are now retrieved through
useRecordInlineCellContext + Removed the null check for
RecordInlineCellContextProps.

Using RecordInlineCellContext, I believe the context goes to the top of
the hierarchy and passed to the required layers without going through
several layers. However, please let me know if I understood the issue
incorrectly or it is not solved properly.

Thank you in advance for your review!

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-08-12 12:18:05 +02:00
Nabhag Motivaras
b16437e6c8
fix: column overlay issue in record table header cells (#6609)
### Issue (BUG)

- Fixes #6604 

### Description

- Now Columns doesn't overlay on header cells, issue was independant of
field type.

#### Before 


https://github.com/user-attachments/assets/0872f07a-83b2-44d8-8f8e-c61c5fac5278

#### After



https://github.com/user-attachments/assets/e2e623f6-6635-4ab6-8ca2-cbd3a296c27d
2024-08-11 20:48:31 +02:00
Félix Malfait
d5350e11a3
Remove some dead code (#6611)
We could remove a lot more than this, this is just a start.

There are various tools to help with this, knip is a good one
2024-08-11 20:43:18 +02:00
Thomas Trompette
39512a779e
Fix storybook tests (#6594)
As title
2024-08-09 19:39:16 +02:00
Anantesh G
13d05d8c74
Fixed restrictive URL sanity check #6570 (#6575)
Fixes #6570 

## Changes
- Replaced the old regex with a new, more inclusive regex pattern.
- Updated the isURL function to use the new pattern.

---------

Co-authored-by: Weiko <corentin@twenty.com>
2024-08-09 16:40:43 +02:00