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

MVP combined #1323

Merged
merged 11 commits into from
Sep 23, 2020
Next Next commit
'object id' & 'decimal' renamed to 'objectId' & 'decimal128'
steffenagger committed Aug 26, 2020
commit b4791fb33c08e30147484aa57633d58d459b81ed
8 changes: 4 additions & 4 deletions src/ui/RealmBrowser/AddClassModal/AddClassModal.tsx
Original file line number Diff line number Diff line change
@@ -115,12 +115,12 @@ export const AddClassModal = ({
addon
type="radio"
name="primaryKeyType"
value="object id"
checked={primaryKeyType === 'object id'}
value="objectId"
checked={primaryKeyType === 'objectId'}
onChange={onPKTypeChange}
disabled={!primaryKey}
/>{' '}
object id
objectId
</Label>
</InputGroupText>
<InputGroupText>
@@ -162,7 +162,7 @@ export const AddClassModal = ({
<CardText>
<small>
{
'If this Realm is intended to be synced with MongoDB, ensure to keep the primary key name "_id", with the type "object id".'
'If this Realm is intended to be synced with MongoDB, ensure to keep the primary key name "_id", with the type "objectId".'
}
</small>
</CardText>
2 changes: 1 addition & 1 deletion src/ui/RealmBrowser/AddClassModal/index.tsx
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ const initialState: IAddClassModalState = {
nameIsValid: true,
primaryKey: false,
primaryKeyName: '',
primaryKeyType: 'object id',
primaryKeyType: 'objectId',
};

class AddClassModalContainer extends React.Component<
6 changes: 3 additions & 3 deletions src/ui/RealmBrowser/Content/CreateObjectDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ class CreateObjectDialogContainer extends React.PureComponent<
) {
if (propertyName === primaryKey) {
// Special handling for primary keys. Opting out of optional handling & return a random value.
if (property.type === 'object id') {
if (property.type === 'objectId') {
return new ObjectId();
} else if (propertyName === 'uuid' && property.type === 'string') {
return uuid();
@@ -101,15 +101,15 @@ class CreateObjectDialogContainer extends React.PureComponent<
return [];
} else if (property.optional) {
return null;
} else if (property.type === 'object id') {
} else if (property.type === 'objectId') {
return new ObjectId();
} else if (
property.type === 'int' ||
property.type === 'float' ||
property.type === 'double'
) {
return 0;
} else if (property.type === 'decimal') {
} else if (property.type === 'decimal128') {
return Decimal128.fromString('0');
} else if (property.type === 'string') {
return '';
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ export const TypeControl = ({
value,
isEmbeddedType,
}: ITypeControlProps) => {
if (property.type === 'object id') {
if (property.type === 'objectId') {
return (
<ObjectIdControl
children={children}
@@ -95,7 +95,7 @@ export const TypeControl = ({
onChange={onChange}
/>
);
} else if (property.type === 'decimal') {
} else if (property.type === 'decimal128') {
return (
<Decimal128Control
children={children}
4 changes: 2 additions & 2 deletions src/ui/RealmBrowser/Content/Table/Cell.tsx
Original file line number Diff line number Diff line change
@@ -56,11 +56,11 @@ const getCellContent = ({
}
// Alternatively - based on type
switch (property.type) {
case 'object id':
case 'objectId':
case 'int':
case 'float':
case 'double':
case 'decimal':
case 'decimal128':
case 'bool':
case 'string':
case 'date': {
2 changes: 1 addition & 1 deletion src/ui/RealmBrowser/index.tsx
Original file line number Diff line number Diff line change
@@ -727,7 +727,7 @@ class RealmBrowserContainer
}
// Derive the properties from the objectSchema
return Object.keys(objectSchema.properties).map(propertyName => {
const property = objectSchema.properties[propertyName];
const property = objectSchema.properties[propertyName] as Realm.ObjectSchemaProperty;
if (typeof property === 'object') {
const isEmbedded =
!!property.objectType && this.isEmbeddedType(property.objectType);
4 changes: 2 additions & 2 deletions src/ui/RealmBrowser/parsers.ts
Original file line number Diff line number Diff line change
@@ -116,13 +116,13 @@ export const parseDate = (
export const parse = (value: string, property: Realm.ObjectSchemaProperty) => {
// For every type
switch (property.type) {
case 'object id':
case 'objectId':
return parseObjectId(value, property);
case 'int':
case 'float':
case 'double':
return parseNumber(value, property);
case 'decimal':
case 'decimal128':
return parseDecimal128(value, property);
case 'bool':
return parseBoolean(value, property);
4 changes: 2 additions & 2 deletions src/ui/RealmBrowser/primitives.ts
Original file line number Diff line number Diff line change
@@ -17,12 +17,12 @@
////////////////////////////////////////////////////////////////////////////

export const TYPES: string[] = [
'object id',
'objectId',
'bool',
'int',
'float',
'double',
'decimal',
'decimal128',
'string',
'data',
'date',