Skip to content

Commit 1539e59

Browse files
committed
#513-small-fixes-suggested-in-PR
1 parent dab9414 commit 1539e59

4 files changed

Lines changed: 45 additions & 42 deletions

File tree

src/pods/import-collection/import-panel.business.ts

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,5 @@
11
import { GenerateGUID } from '@/core/model';
2-
3-
export type FieldType =
4-
| 'any'
5-
| 'array'
6-
| 'binData'
7-
| 'bool'
8-
| 'date'
9-
| 'dbPointer'
10-
| 'decimal'
11-
| 'double'
12-
| 'enum'
13-
| 'int'
14-
| 'javascript'
15-
| 'long'
16-
| 'maxKey'
17-
| 'minKey'
18-
| 'null'
19-
| 'object'
20-
| 'objectId'
21-
| 'regex'
22-
| 'string'
23-
| 'symbol'
24-
| 'timestamp'
25-
| 'undefined';
26-
27-
export interface FieldVm {
28-
id: string;
29-
PK: boolean;
30-
FK: boolean;
31-
name: string;
32-
type: FieldType;
33-
children?: FieldVm[];
34-
isCollapsed?: boolean;
35-
isArray?: boolean;
36-
isNN?: boolean;
37-
}
2+
import { FieldType, FieldVm } from './import-panel.model';
383

394
function inferMongoType(value: object | string | number | boolean | null | undefined): FieldType {
405
if (value === null) return 'null';
@@ -113,15 +78,15 @@ export const validateJsonSchema = (jsonString: string): string | null => {
11378
const parsed = JSON.parse(jsonString);
11479

11580
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
116-
return 'El JSON debe ser un objeto válido';
81+
return 'Current version only accepts a single document object';
11782
}
11883

11984
if (Array.isArray(parsed) && parsed.length === 1 && typeof parsed[0] === 'object' && Object.keys(parsed[0]).length === 0) {
120-
return 'El JSON no puede ser [{}]';
85+
return 'The JSON is not valid';
12186
}
12287

12388
return null;
12489
} catch {
125-
return 'El JSON no es válido';
90+
return 'The JSON is not valid';
12691
}
12792
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
export type FieldType =
2+
| 'any'
3+
| 'array'
4+
| 'binData'
5+
| 'bool'
6+
| 'date'
7+
| 'dbPointer'
8+
| 'decimal'
9+
| 'double'
10+
| 'enum'
11+
| 'int'
12+
| 'javascript'
13+
| 'long'
14+
| 'maxKey'
15+
| 'minKey'
16+
| 'null'
17+
| 'object'
18+
| 'objectId'
19+
| 'regex'
20+
| 'string'
21+
| 'symbol'
22+
| 'timestamp'
23+
| 'undefined';
24+
25+
export interface FieldVm {
26+
id: string;
27+
PK: boolean;
28+
FK: boolean;
29+
name: string;
30+
type: FieldType;
31+
children?: FieldVm[];
32+
isCollapsed?: boolean;
33+
isArray?: boolean;
34+
isNN?: boolean;
35+
}

src/pods/import-collection/import-panel.pod.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535

3636
.json-textarea textarea {
3737
flex: 1;
38-
max-width: 700px;
3938
padding: 8px;
4039
height: 40px;
4140
}

src/pods/import-collection/import-panel.pod.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const ImportPanel: React.FC<ImportPanelProps> = props => {
5959
};
6060
onSave(mapEditTableVmToTableVm(newTable));
6161
} catch (error) {
62-
setJsonError('El JSON no es válido');
62+
setJsonError('The JSON is not valid');
6363
}
6464
};
6565

@@ -91,9 +91,13 @@ export const ImportPanel: React.FC<ImportPanelProps> = props => {
9191
/>
9292
</label>
9393
</div>
94+
<label>
95+
Copy here a document (you can copy it from a collection using a tool
96+
like Mongo Compass)
97+
</label>
9498
<div className={classes.jsonTextarea}>
9599
<label>
96-
JSON Schema:
100+
JSON Document:
97101
<textarea
98102
value={jsonContent}
99103
onChange={handleJsonContentChange}

0 commit comments

Comments
 (0)