diff --git a/.gitignore b/.gitignore index 33af5f9ea..fb6da523f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ dist/ node_modules/ realm-object-server/ .idea - +.vscode .DS_Store data/ diff --git a/src/ui/RealmBrowser/Content/Content.tsx b/src/ui/RealmBrowser/Content/Content.tsx index 231d5610b..2c7a0c110 100644 --- a/src/ui/RealmBrowser/Content/Content.tsx +++ b/src/ui/RealmBrowser/Content/Content.tsx @@ -58,6 +58,7 @@ import { TopBar } from './TopBar'; interface IBaseContentProps { contentRef: (element: HTMLElement | null) => void; dataVersion?: number; + allowCreate: boolean; editMode: EditMode; error?: Error; filteredSortedResults: Realm.Collection; @@ -146,6 +147,7 @@ export const Content = ({ query={query} queryError={queryError} readOnly={props.readOnly} + allowCreate={props.allowCreate} />
diff --git a/src/ui/RealmBrowser/Content/CreateObjectDialog/CreateObjectDialog.tsx b/src/ui/RealmBrowser/Content/CreateObjectDialog/CreateObjectDialog.tsx index c29827b2c..c6265a54e 100644 --- a/src/ui/RealmBrowser/Content/CreateObjectDialog/CreateObjectDialog.tsx +++ b/src/ui/RealmBrowser/Content/CreateObjectDialog/CreateObjectDialog.tsx @@ -42,6 +42,7 @@ export interface IOpenCreateObjectDialogProps getClassFocus: (className: string) => IClassFocus; isOpen: true; schema: Realm.ObjectSchema; + isEmbeddedType: (className: string) => boolean; } export type ICreateObjectDialogProps = @@ -76,6 +77,7 @@ export const CreateObjectDialog = ({ } propertyName={propertyName} value={values[propertyName]} + isEmbeddedType={props.isEmbeddedType} /> )) : null} diff --git a/src/ui/RealmBrowser/Content/CreateObjectDialog/PropertyRow.tsx b/src/ui/RealmBrowser/Content/CreateObjectDialog/PropertyRow.tsx index d6e203d57..e52a57a88 100644 --- a/src/ui/RealmBrowser/Content/CreateObjectDialog/PropertyRow.tsx +++ b/src/ui/RealmBrowser/Content/CreateObjectDialog/PropertyRow.tsx @@ -32,6 +32,7 @@ interface IPropertyRowProps { property: Realm.ObjectSchemaProperty; propertyName: string; value: any; + isEmbeddedType: (className: string) => boolean; } export const PropertyRow = ({ @@ -42,6 +43,7 @@ export const PropertyRow = ({ property, propertyName, value, + isEmbeddedType, }: IPropertyRowProps) => ( ); diff --git a/src/ui/RealmBrowser/Content/CreateObjectDialog/index.tsx b/src/ui/RealmBrowser/Content/CreateObjectDialog/index.tsx index 01d9d04e3..e199804f3 100644 --- a/src/ui/RealmBrowser/Content/CreateObjectDialog/index.tsx +++ b/src/ui/RealmBrowser/Content/CreateObjectDialog/index.tsx @@ -46,6 +46,7 @@ interface IOpenCreateObjectDialogContainerProps { onCancel: () => void; onCreate: CreateObjectHandler; schema: Realm.ObjectSchema; + isEmbeddedType: (className: string) => boolean; } export interface ICreateObjectDialogContainerState { @@ -161,6 +162,7 @@ class CreateObjectDialogContainer extends React.PureComponent< onCreate: this.onCreate, onValueChange: this.onValueChange, values: this.state.values, + isEmbeddedType: this.isEmbeddedType, }; if (this.props.isOpen) { return { @@ -196,6 +198,9 @@ class CreateObjectDialogContainer extends React.PureComponent< } }; + protected isEmbeddedType = (className: string) => + this.props.isOpen && this.props.isEmbeddedType(className); + protected onValueChange = (propertyName: string, value: any) => { this.setState({ values: { diff --git a/src/ui/RealmBrowser/Content/CreateObjectDialog/types/DefaultControl.tsx b/src/ui/RealmBrowser/Content/CreateObjectDialog/types/DefaultControl.tsx index 505733567..bdb9cf540 100644 --- a/src/ui/RealmBrowser/Content/CreateObjectDialog/types/DefaultControl.tsx +++ b/src/ui/RealmBrowser/Content/CreateObjectDialog/types/DefaultControl.tsx @@ -22,8 +22,11 @@ import Realm from 'realm'; export interface IDefaultControlProps { property: Realm.ObjectSchemaProperty; + message?: string; } -export const DefaultControl = ({ property }: IDefaultControlProps) => ( - Cannot select "{property.type}" yet +export const DefaultControl = ({ property, message }: IDefaultControlProps) => ( + + {message ?? `Cannot select "${property.type}" yet`} + ); diff --git a/src/ui/RealmBrowser/Content/CreateObjectDialog/types/ListControl.tsx b/src/ui/RealmBrowser/Content/CreateObjectDialog/types/ListControl.tsx index 24c8c707f..3a8fad0fe 100644 --- a/src/ui/RealmBrowser/Content/CreateObjectDialog/types/ListControl.tsx +++ b/src/ui/RealmBrowser/Content/CreateObjectDialog/types/ListControl.tsx @@ -28,7 +28,12 @@ import { ITypeControlProps, TypeControl } from './TypeControl'; interface IItemProps extends Pick< ITypeControlProps, - 'generateInitialValue' | 'getClassFocus' | 'onChange' | 'value' | 'property' + | 'generateInitialValue' + | 'getClassFocus' + | 'onChange' + | 'value' + | 'property' + | 'isEmbeddedType' > { onDelete: () => void; } @@ -40,6 +45,7 @@ const Item = ({ onChange, onDelete, value, + isEmbeddedType, }: IItemProps) => (