Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remote object read-only + remove relations #4921

Merged
merged 4 commits into from
Apr 11, 2024

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Apr 11, 2024

  • Set readOnly boolean in table row context. Preventing updates and deletion
  • Show page is null for remote objects. No need for complicated design since this is temporary?
  • Relation creations are now behind a feature flag for remote objects
  • Refetch objects and views after syncing objects

@thomtrp thomtrp force-pushed the tt-deactivate-relations-for-remote branch from a86664b to 62dc378 Compare April 11, 2024 13:51
Copy link

github-actions bot commented Apr 11, 2024

TODOs/FIXMEs:

  • // TODO: we should return the tables with the columns and store in cache instead of refetching: packages/twenty-front/src/modules/databases/hooks/useSyncRemoteTable.ts

Generated by 🚫 dangerJS against d48b693

@thomtrp thomtrp force-pushed the tt-deactivate-relations-for-remote branch from bd80931 to 15fd09f Compare April 11, 2024 14:29
[download, progress],
);

const baseActions = objectMetadataItem.isRemote
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's enough, we cannot add a favorite on remote object either. (it's below in the code).
I would update base action to only contain export

then I would append deletion and favorittes for nonRemotes

onTab={handleTab}
/>
isReadOnly ? (
<FieldDisplay />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a hack. I would pass isReadOnly to the recordTableContainer and prevent edit mode activation

const isFieldInputOnly = useIsFieldInputOnly();

const { openTableCell } = useOpenRecordTableCell();

const handleClick = () => {
setSoftFocusOnCurrentCell();

if (!isFieldInputOnly) {
if (!isFieldInputOnly && !isReadOnly) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would not check it here but within the openTableCell itself

@@ -95,7 +98,7 @@ export const RecordTableCellSoftFocusMode = ({
);

const handleClick = () => {
if (!isFieldInputOnly) {
if (!isFieldInputOnly && !isReadOnly) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you don't have to add it several times

@@ -855,4 +868,14 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt

return { favoriteObjectMetadata };
}

private async isRelationEnabledForRemoteObjects(workspaceId: string) {
const featureFlag = await this.featureFlagRepository.findOneBy({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprise we don't have a generic helper in the backend isFeatureFlagEnabled(KEY) this logic of existence + boolean = true seems standard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't. But I can do a refacto. I tried to make it a guard not so long ago but it was not working well. An util would be easy

objectMetadataInput.workspaceId,
createdObjectMetadata,
);
if (isCustom || isRelationEnabledForRemoteObjects) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks suspicious: create object is necessarily either custom or remote. so I would actually create a function call: createObjectRelations. First line would be: if (! isRelationEnabledForRemoteObjects) { return }

@@ -74,19 +74,6 @@ export const buildWorkspaceMigrationsForRemoteObject = async (
} satisfies WorkspaceMigrationColumnCreate,
],
},
{
name: computeObjectTargetTable(activityTargetObjectMetadata),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the featureflag is partially followed? we always remove from migrations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope this part is only cleaning duplicated code

@thomtrp thomtrp force-pushed the tt-deactivate-relations-for-remote branch from 9bf8f68 to d48b693 Compare April 11, 2024 15:38
@thomtrp thomtrp merged commit f332213 into main Apr 11, 2024
5 of 9 checks passed
@thomtrp thomtrp deleted the tt-deactivate-relations-for-remote branch April 11, 2024 15:58
arnavsaxena17 pushed a commit to arnavsaxena17/twenty that referenced this pull request Oct 6, 2024
- Set `readOnly` boolean in table row context. Preventing updates and
deletion
- Show page is null for remote objects. No need for complicated design
since this is temporary?
- Relation creations are now behind a feature flag for remote objects
- Refetch objects and views after syncing objects

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants