Add system view fallback (#18536)

## Context
The goal is to add a "See records" button in all objects that would
redirect to that view (this will be done in a later PR). See screenshot
below.
<img width="665" height="312" alt="Screenshot 2026-03-10 at 15 54 36"
src="https://github.com/user-attachments/assets/6e23a75b-cff0-4d93-bce8-b5481b05c6f6"
/>

## Implementation
- If a view does not exist on an object, there is a **temporary**
fallback where the frontend creates the missing view as a custom view
when going over the object index page
- System objects are now surfaced but we don't want their records to be
editable, they will be readonly (mostly, all fields will be non-editable
except for their custom fields).
- We can't create a new record of a system object, some actions are also
hidden.
- The backend now rejects if you are trying to delete the last view of
an object
This commit is contained in:
Weiko
2026-03-11 13:48:02 +01:00
committed by GitHub
parent 99f885306e
commit 00c3cd1051
31 changed files with 343 additions and 37 deletions
@@ -41,6 +41,7 @@ export const useIsRecordFieldReadOnly = ({
return isRecordFieldReadOnly({
isRecordReadOnly,
isSystemObject: objectMetadataItem.isSystem,
objectPermissions,
fieldMetadataItem,
});
@@ -23,6 +23,7 @@ describe('isRecordFieldReadOnly', () => {
fieldMetadataItem: {
id: 'field-123',
isUIReadOnly: false,
isCustom: false,
},
});
@@ -39,6 +40,7 @@ describe('isRecordFieldReadOnly', () => {
fieldMetadataItem: {
id: 'field-123',
isUIReadOnly: false,
isCustom: false,
},
});
@@ -57,6 +59,7 @@ describe('isRecordFieldReadOnly', () => {
fieldMetadataItem: {
id: 'field-123',
isUIReadOnly: false,
isCustom: false,
},
});
@@ -69,6 +72,7 @@ describe('isRecordFieldReadOnly', () => {
fieldMetadataItem: {
id: 'field-123',
isUIReadOnly: true,
isCustom: false,
},
});
@@ -81,6 +85,48 @@ describe('isRecordFieldReadOnly', () => {
fieldMetadataItem: {
id: 'field-123',
isUIReadOnly: false,
isCustom: false,
},
});
expect(result).toBe(false);
});
it('should return true when field is non-custom on a system object', () => {
const result = isRecordFieldReadOnly({
...mockParams,
isSystemObject: true,
fieldMetadataItem: {
id: 'field-123',
isUIReadOnly: false,
isCustom: false,
},
});
expect(result).toBe(true);
});
it('should return false when field is custom on a system object', () => {
const result = isRecordFieldReadOnly({
...mockParams,
isSystemObject: true,
fieldMetadataItem: {
id: 'field-123',
isUIReadOnly: false,
isCustom: true,
},
});
expect(result).toBe(false);
});
it('should return false when isSystemObject is not provided', () => {
const result = isRecordFieldReadOnly({
...mockParams,
fieldMetadataItem: {
id: 'field-123',
isUIReadOnly: false,
isCustom: false,
},
});
@@ -4,13 +4,18 @@ import { type ObjectPermission } from '~/generated-metadata/graphql';
type IsRecordFieldReadOnlyParams = {
isRecordReadOnly: boolean;
fieldMetadataItem: Pick<FieldMetadataItem, 'id' | 'isUIReadOnly'>;
isSystemObject?: boolean;
fieldMetadataItem: Pick<
FieldMetadataItem,
'id' | 'isUIReadOnly' | 'isCustom'
>;
objectPermissions: ObjectPermission;
};
export const isRecordFieldReadOnly = ({
objectPermissions,
isRecordReadOnly,
isSystemObject,
fieldMetadataItem,
}: IsRecordFieldReadOnlyParams) => {
const fieldReadOnlyByPermissions = isFieldMetadataReadOnlyByPermissions({
@@ -20,6 +25,7 @@ export const isRecordFieldReadOnly = ({
return (
isRecordReadOnly ||
(isSystemObject === true && fieldMetadataItem.isCustom !== true) ||
fieldMetadataItem.isUIReadOnly ||
fieldReadOnlyByPermissions
);