@proteinjs/db-ui 1.8.4 → 1.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/src/pages/HashGeneratorPage.d.ts.map +1 -1
- package/dist/src/pages/HashGeneratorPage.js +0 -1
- package/dist/src/pages/HashGeneratorPage.js.map +1 -1
- package/dist/src/pages/RecordFormPage.d.ts.map +1 -1
- package/dist/src/pages/RecordFormPage.js +13 -6
- package/dist/src/pages/RecordFormPage.js.map +1 -1
- package/dist/src/pages/RecordTablePage.d.ts.map +1 -1
- package/dist/src/pages/RecordTablePage.js +9 -6
- package/dist/src/pages/RecordTablePage.js.map +1 -1
- package/dist/src/pages/TablesPage.d.ts.map +1 -1
- package/dist/src/pages/TablesPage.js +0 -1
- package/dist/src/pages/TablesPage.js.map +1 -1
- package/dist/src/pages/UuidGeneratorPage.d.ts.map +1 -1
- package/dist/src/pages/UuidGeneratorPage.js +0 -1
- package/dist/src/pages/UuidGeneratorPage.js.map +1 -1
- package/dist/test/recordPageErrorStates.test.d.ts +2 -0
- package/dist/test/recordPageErrorStates.test.d.ts.map +1 -0
- package/dist/test/recordPageErrorStates.test.js +37 -0
- package/dist/test/recordPageErrorStates.test.js.map +1 -0
- package/jest.config.js +8 -0
- package/package.json +3 -2
- package/src/pages/HashGeneratorPage.tsx +0 -1
- package/src/pages/RecordFormPage.tsx +13 -7
- package/src/pages/RecordTablePage.tsx +14 -11
- package/src/pages/TablesPage.tsx +0 -1
- package/src/pages/UuidGeneratorPage.tsx +0 -1
- package/test/recordPageErrorStates.test.tsx +35 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.8.5](https://github.com/proteinjs/db/compare/@proteinjs/db-ui@1.8.4...@proteinjs/db-ui@1.8.5) (2026-08-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* record table/form page error states + drop 100vh page pins ([6c6aca2](https://github.com/proteinjs/db/commit/6c6aca2cca754e8201011694da893dba2bbd6898))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.8.4](https://github.com/proteinjs/db/compare/@proteinjs/db-ui@1.8.3...@proteinjs/db-ui@1.8.4) (2026-08-14)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @proteinjs/db-ui
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashGeneratorPage.d.ts","sourceRoot":"","sources":["../../../src/pages/HashGeneratorPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAwC,MAAM,eAAe,CAAC;AAGrF,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"HashGeneratorPage.d.ts","sourceRoot":"","sources":["../../../src/pages/HashGeneratorPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAwC,MAAM,eAAe,CAAC;AAGrF,eAAO,MAAM,iBAAiB,EAAE,IAoB/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HashGeneratorPage.js","sourceRoot":"","sources":["../../../src/pages/HashGeneratorPage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,oCAAqF;AAGxE,QAAA,iBAAiB,GAAS;IACrC,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE,gBAAgB;IACtB,mGAAmG;IACnG,IAAI,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;IAC3B,oBAAoB,EAAE,UAAC,KAAY;QACjC,OAAO;YACL,
|
|
1
|
+
{"version":3,"file":"HashGeneratorPage.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AAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAA;;wBAAxE,GAAkB,KAAK,GAAG,SAA8C,CAAC;;;;aAC1E;KACF;CACF,CAAC;AAEF,SAAe,cAAc,CAAC,KAAkB;IAAlB,sBAAA,EAAA,UAAkB;;;;;;oBAExC,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;oBAC5B,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBAGhB,qBAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,EAAA;;oBAAxD,UAAU,GAAG,SAA2C;oBAGxD,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;oBACnD,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAA/B,CAA+B,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAE/E,sBAAO,OAAO,EAAC;;;;CAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordFormPage.d.ts","sourceRoot":"","sources":["../../../src/pages/RecordFormPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAsB,MAAM,eAAe,CAAC;AAKnE,eAAO,MAAM,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"RecordFormPage.d.ts","sourceRoot":"","sources":["../../../src/pages/RecordFormPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAsB,MAAM,eAAe,CAAC;AAKnE,eAAO,MAAM,cAAc,EAAE,IAkB5B,CAAC;AAEF,eAAO,MAAM,cAAc,cAAe,MAAM,YAAY,MAAM,WAEjE,CAAC;AAEF,eAAO,MAAM,iBAAiB,cAAe,MAAM,WAElD,CAAC"}
|
|
@@ -66,15 +66,17 @@ var react_1 = __importDefault(require("react"));
|
|
|
66
66
|
var ui_1 = require("@proteinjs/ui");
|
|
67
67
|
var db_1 = require("@proteinjs/db");
|
|
68
68
|
var RecordForm_1 = require("../form/RecordForm");
|
|
69
|
+
var material_1 = require("@mui/material");
|
|
69
70
|
exports.recordFormPage = {
|
|
70
71
|
name: 'Record Form',
|
|
71
72
|
path: 'record/form',
|
|
72
73
|
auth: {
|
|
73
74
|
allUsers: true,
|
|
74
75
|
},
|
|
76
|
+
// No height override: the app's page container owns viewport height (dvh on mobile —
|
|
77
|
+
// a 100vh pin here clipped the bottom behind mobile browser chrome).
|
|
75
78
|
pageContainerSxProps: function (theme) {
|
|
76
79
|
return {
|
|
77
|
-
height: '100vh',
|
|
78
80
|
backgroundColor: theme.palette.background.default,
|
|
79
81
|
};
|
|
80
82
|
},
|
|
@@ -144,8 +146,9 @@ var DynamicRecordForm = function (_a) {
|
|
|
144
146
|
try {
|
|
145
147
|
table = (0, db_1.tableByName)(tableName);
|
|
146
148
|
}
|
|
147
|
-
catch (
|
|
148
|
-
//
|
|
149
|
+
catch (_a) {
|
|
150
|
+
// NOTE: this catch previously bound the exception as `error`, shadowing the outer
|
|
151
|
+
// variable — the message was never returned and the page rendered blank.
|
|
149
152
|
error = "Table not accessible in UI: ".concat(tableName);
|
|
150
153
|
}
|
|
151
154
|
}
|
|
@@ -154,19 +157,23 @@ var DynamicRecordForm = function (_a) {
|
|
|
154
157
|
}
|
|
155
158
|
return { table: table, error: error };
|
|
156
159
|
}
|
|
160
|
+
function Message(_a) {
|
|
161
|
+
var children = _a.children;
|
|
162
|
+
return react_1.default.createElement(material_1.Typography, { sx: { p: 3, color: 'text.secondary' } }, children);
|
|
163
|
+
}
|
|
157
164
|
function Form() {
|
|
158
165
|
var _a = getTable(), table = _a.table, error = _a.error;
|
|
159
166
|
if (!table) {
|
|
160
|
-
return react_1.default.createElement(
|
|
167
|
+
return react_1.default.createElement(Message, null, error);
|
|
161
168
|
}
|
|
162
169
|
if (loadError) {
|
|
163
|
-
return react_1.default.createElement(
|
|
170
|
+
return react_1.default.createElement(Message, null, loadError);
|
|
164
171
|
}
|
|
165
172
|
if (!recordLoaded) {
|
|
166
173
|
return null;
|
|
167
174
|
}
|
|
168
175
|
if (recordId && !record) {
|
|
169
|
-
return react_1.default.createElement(
|
|
176
|
+
return react_1.default.createElement(Message, null, "No ".concat(table.name, " record found: ").concat(recordId));
|
|
170
177
|
}
|
|
171
178
|
return react_1.default.createElement(RecordForm_1.RecordForm, { table: table, record: record });
|
|
172
179
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordFormPage.js","sourceRoot":"","sources":["../../../src/pages/RecordFormPage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,oCAAmE;AACnE,oCAA0D;AAC1D,iDAAgD;
|
|
1
|
+
{"version":3,"file":"RecordFormPage.js","sourceRoot":"","sources":["../../../src/pages/RecordFormPage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,oCAAmE;AACnE,oCAA0D;AAC1D,iDAAgD;AAChD,0CAA2D;AAE9C,QAAA,cAAc,GAAS;IAClC,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE;QACJ,QAAQ,EAAE,IAAI;KACf;IACD,qFAAqF;IACrF,qEAAqE;IACrE,oBAAoB,EAAE,UAAC,KAAY;QACjC,OAAO;YACL,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO;SAClD,CAAC;IACJ,CAAC;IACD,SAAS,EAAE,UAAC,EAAY;YAAP,KAAK,cAAV,EAAY,CAAF;QAAO,OAAA,CAC3B,8BAAC,aAAQ;YACP,8BAAC,iBAAiB,eAA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,aAAM,KAAK,CAAC,IAAI,4BAAkB,QAAQ,CAAE,CAAW,CAAC;SAC1E;QAED,OAAO,8BAAC,uBAAU,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,CAAC;IACtD,CAAC;IAED,OAAO,8BAAC,IAAI,OAAG,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordTablePage.d.ts","sourceRoot":"","sources":["../../../src/pages/RecordTablePage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAsB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAe,KAAK,EAAE,MAAM,eAAe,CAAC;AAInD,eAAO,MAAM,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"RecordTablePage.d.ts","sourceRoot":"","sources":["../../../src/pages/RecordTablePage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAsB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAe,KAAK,EAAE,MAAM,eAAe,CAAC;AAInD,eAAO,MAAM,eAAe,EAAE,IAc7B,CAAC;AAEF,eAAO,MAAM,eAAe,UAAW,MAAM,GAAG,CAAC,WAEhD,CAAC;AAEF,eAAO,MAAM,qBAAqB,cAAe,MAAM,WAEtD,CAAC"}
|
|
@@ -36,17 +36,16 @@ exports.recordTablePage = {
|
|
|
36
36
|
auth: {
|
|
37
37
|
allUsers: true,
|
|
38
38
|
},
|
|
39
|
+
// No height override: the app's page container owns viewport height (dvh on mobile —
|
|
40
|
+
// a 100vh pin here clipped the bottom behind mobile browser chrome).
|
|
39
41
|
pageContainerSxProps: function (theme) {
|
|
40
42
|
return {
|
|
41
|
-
height: '100vh',
|
|
42
43
|
backgroundColor: theme.palette.background.default,
|
|
43
44
|
};
|
|
44
45
|
},
|
|
45
46
|
component: function (_a) {
|
|
46
47
|
var props = __rest(_a, []);
|
|
47
|
-
return
|
|
48
|
-
react_1.default.createElement(material_1.Paper, { sx: { maxHeight: '80vh' } },
|
|
49
|
-
react_1.default.createElement(DynamicRecordTable, __assign({}, props)))));
|
|
48
|
+
return react_1.default.createElement(DynamicRecordTable, __assign({}, props));
|
|
50
49
|
},
|
|
51
50
|
};
|
|
52
51
|
var recordTableLink = function (table) {
|
|
@@ -74,10 +73,14 @@ var DynamicRecordTable = function (_a) {
|
|
|
74
73
|
else {
|
|
75
74
|
errorMessage = "Table not provided via the 'name' url param";
|
|
76
75
|
}
|
|
76
|
+
// The error state renders as a plain message — wrapping it in the table's stretched
|
|
77
|
+
// card produced a full-height empty Paper with the text clipped at its edge.
|
|
77
78
|
if (!table) {
|
|
78
|
-
return react_1.default.createElement(
|
|
79
|
+
return react_1.default.createElement(material_1.Typography, { sx: { p: 3, color: 'text.secondary' } }, errorMessage);
|
|
79
80
|
}
|
|
80
|
-
return react_1.default.createElement(
|
|
81
|
+
return (react_1.default.createElement(material_1.Box, { sx: { display: 'flex', flexGrow: 1, justifyContent: 'center', padding: 4 } },
|
|
82
|
+
react_1.default.createElement(material_1.Paper, { sx: { maxHeight: '80vh' } },
|
|
83
|
+
react_1.default.createElement(RecordTable_1.RecordTable, { table: table }))));
|
|
81
84
|
}
|
|
82
85
|
return react_1.default.createElement(Table, null);
|
|
83
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordTablePage.js","sourceRoot":"","sources":["../../../src/pages/RecordTablePage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAE1B,oCAAmD;AACnD,oDAAmD;AACnD,
|
|
1
|
+
{"version":3,"file":"RecordTablePage.js","sourceRoot":"","sources":["../../../src/pages/RecordTablePage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAE1B,oCAAmD;AACnD,oDAAmD;AACnD,0CAAuE;AAE1D,QAAA,eAAe,GAAS;IACnC,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,cA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QAED,OAAO,CACL,8BAAC,cAAG,IAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE;YAC7E,8BAAC,gBAAK,IAAC,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;gBAC9B,8BAAC,yBAAW,IAAC,KAAK,EAAE,KAAK,GAAI,CACvB,CACJ,CACP,CAAC;IACJ,CAAC;IAED,OAAO,8BAAC,KAAK,OAAG,CAAC;AACnB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TablesPage.d.ts","sourceRoot":"","sources":["../../../src/pages/TablesPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAoE,MAAM,eAAe,CAAC;AAKjH,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"TablesPage.d.ts","sourceRoot":"","sources":["../../../src/pages/TablesPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAoE,MAAM,eAAe,CAAC;AAKjH,eAAO,MAAM,UAAU,EAAE,IAoBxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TablesPage.js","sourceRoot":"","sources":["../../../src/pages/TablesPage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,oCAAiH;AACjH,oCAA+D;AAC/D,qDAA0D;AAC1D,0CAAoD;AAEvC,QAAA,UAAU,GAAS;IAC9B,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd;;;;;OAKG;IACH,IAAI,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;IAC3B,oBAAoB,EAAE,UAAC,KAAY;QACjC,OAAO;YACL,
|
|
1
|
+
{"version":3,"file":"TablesPage.js","sourceRoot":"","sources":["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AAM,CAAA;;4BAK1B,sBAAO,IAAI,EAAC;;;;KACb;IACH,yBAAC;AAAD,CAAC,AAhBD,CAAiC,oBAAe,GAgB/C;AAED,IAAM,MAAM,GAAG;IACb,OAAO,CACL,8BAAC,cAAG,IAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE;QACvC,8BAAC,cAAG,IAAC,SAAS,EAAC,MAAM;YACnB,8BAAC,UAAc,IACb,KAAK,EAAC,QAAQ,EACd,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,EAC7B,WAAW,EAAE,IAAI,kBAAkB,CAAC,IAAA,cAAS,GAAE,CAAC,EAChD,UAAU,EAAE,UAAO,GAAiB;;wBAClC,sBAAO,IAAA,uCAAqB,EAAC,GAAG,CAAC,IAAI,CAAC,EAAC;;qBACxC,GACD,CACE,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UuidGeneratorPage.d.ts","sourceRoot":"","sources":["../../../src/pages/UuidGeneratorPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAwC,MAAM,eAAe,CAAC;AAIrF,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"UuidGeneratorPage.d.ts","sourceRoot":"","sources":["../../../src/pages/UuidGeneratorPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAwC,MAAM,eAAe,CAAC;AAIrF,eAAO,MAAM,iBAAiB,EAAE,IAoB/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UuidGeneratorPage.js","sourceRoot":"","sources":["../../../src/pages/UuidGeneratorPage.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,oCAAqF;AACrF,6BAAoC;AAGvB,QAAA,iBAAi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ACD,OAAO,EAAE,UAAO,MAAkB,EAAE,OAAgC;;gBAClE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAA,SAAM,GAAE,CAAC;;;aACpC;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordPageErrorStates.test.d.ts","sourceRoot":"","sources":["../../test/recordPageErrorStates.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
7
|
+
var server_1 = require("react-dom/server");
|
|
8
|
+
var RecordFormPage_1 = require("../src/pages/RecordFormPage");
|
|
9
|
+
var RecordTablePage_1 = require("../src/pages/RecordTablePage");
|
|
10
|
+
describe('record form page error states', function () {
|
|
11
|
+
it('renders the not-accessible message for an unknown table (regression: a shadowed catch binding swallowed the message and the page rendered blank)', function () {
|
|
12
|
+
var Form = RecordFormPage_1.recordFormPage.component;
|
|
13
|
+
var html = (0, server_1.renderToStaticMarkup)(react_1.default.createElement(Form, { urlParams: { table: 'NotARealTable' } }));
|
|
14
|
+
expect(html).toContain('Table not accessible in UI: NotARealTable');
|
|
15
|
+
});
|
|
16
|
+
it('renders the missing-param message when no table is provided', function () {
|
|
17
|
+
var Form = RecordFormPage_1.recordFormPage.component;
|
|
18
|
+
var html = (0, server_1.renderToStaticMarkup)(react_1.default.createElement(Form, { urlParams: {} }));
|
|
19
|
+
// (apostrophes render HTML-escaped in static markup, so assert around them)
|
|
20
|
+
expect(html).toContain('Table name not provided via the');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
describe('record table page error states', function () {
|
|
24
|
+
it('renders the not-accessible message outside the table card (the stretched Paper clipped it)', function () {
|
|
25
|
+
var Table = RecordTablePage_1.recordTablePage.component;
|
|
26
|
+
var html = (0, server_1.renderToStaticMarkup)(react_1.default.createElement(Table, { urlParams: { name: 'NotARealTable' } }));
|
|
27
|
+
expect(html).toContain('Table not accessible in UI: NotARealTable');
|
|
28
|
+
expect(html).not.toContain('MuiPaper');
|
|
29
|
+
});
|
|
30
|
+
it('renders the missing-param message when no name is provided', function () {
|
|
31
|
+
var Table = RecordTablePage_1.recordTablePage.component;
|
|
32
|
+
var html = (0, server_1.renderToStaticMarkup)(react_1.default.createElement(Table, { urlParams: {} }));
|
|
33
|
+
// (apostrophes render HTML-escaped in static markup, so assert around them)
|
|
34
|
+
expect(html).toContain('Table not provided via the');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=recordPageErrorStates.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordPageErrorStates.test.js","sourceRoot":"","sources":["../../test/recordPageErrorStates.test.tsx"],"names":[],"mappings":";;;;;AAAA,gDAA0B;AAC1B,2CAAwD;AACxD,8DAA6D;AAC7D,gEAA+D;AAE/D,QAAQ,CAAC,+BAA+B,EAAE;IACxC,EAAE,CAAC,kJAAkJ,EAAE;QACrJ,IAAM,IAAI,GAAG,+BAAc,CAAC,SAAS,CAAC;QACtC,IAAM,IAAI,GAAG,IAAA,6BAAoB,EAAC,8BAAC,IAAI,IAAC,SAAS,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,GAAI,CAAC,CAAC;QACnF,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,2CAA2C,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE;QAChE,IAAM,IAAI,GAAG,+BAAc,CAAC,SAAS,CAAC;QACtC,IAAM,IAAI,GAAG,IAAA,6BAAoB,EAAC,8BAAC,IAAI,IAAC,SAAS,EAAE,EAAE,GAAI,CAAC,CAAC;QAC3D,4EAA4E;QAC5E,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,gCAAgC,EAAE;IACzC,EAAE,CAAC,4FAA4F,EAAE;QAC/F,IAAM,KAAK,GAAG,iCAAe,CAAC,SAAS,CAAC;QACxC,IAAM,IAAI,GAAG,IAAA,6BAAoB,EAAC,8BAAC,KAAK,IAAC,SAAS,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,GAAI,CAAC,CAAC;QACnF,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,2CAA2C,CAAC,CAAC;QACpE,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4DAA4D,EAAE;QAC/D,IAAM,KAAK,GAAG,iCAAe,CAAC,SAAS,CAAC;QACxC,IAAM,IAAI,GAAG,IAAA,6BAAoB,EAAC,8BAAC,KAAK,IAAC,SAAS,EAAE,EAAE,GAAI,CAAC,CAAC;QAC5D,4EAA4E;QAC5E,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/jest.config.js
CHANGED
|
@@ -6,4 +6,12 @@ module.exports = {
|
|
|
6
6
|
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
|
|
7
7
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
8
8
|
testEnvironment: 'node',
|
|
9
|
+
moduleNameMapper: {
|
|
10
|
+
// The symlinked @proteinjs/ui carries its own react tree. Pin the singletons to THIS
|
|
11
|
+
// package's copies so jest loads one React (hooks) — the util-ui precedent.
|
|
12
|
+
'^react$': '<rootDir>/node_modules/react',
|
|
13
|
+
'^react/(.*)$': '<rootDir>/node_modules/react/$1',
|
|
14
|
+
'^react-dom$': '<rootDir>/node_modules/react-dom',
|
|
15
|
+
'^react-dom/(.*)$': '<rootDir>/node_modules/react-dom/$1',
|
|
16
|
+
},
|
|
9
17
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteinjs/db-ui",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.5",
|
|
4
4
|
"description": "Db ui components",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@types/jest": "29.5.5",
|
|
41
41
|
"@types/node": "14.0.27",
|
|
42
42
|
"@types/react": "18.2.23",
|
|
43
|
+
"@types/react-dom": "18.2.8",
|
|
43
44
|
"@types/string": "0.0.33",
|
|
44
45
|
"@types/uuid": "8.3.0",
|
|
45
46
|
"@typescript-eslint/eslint-plugin": "7.8.0",
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
},
|
|
54
55
|
"main": "./dist/generated/index.js",
|
|
55
56
|
"types": "./dist/generated/index.d.ts",
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "91f8bc0e7c5873a61bd9ef6e4a1b380c24acc922"
|
|
57
58
|
}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { FormPage, Page, PageComponentProps } from '@proteinjs/ui';
|
|
3
3
|
import { getDbService, tableByName } from '@proteinjs/db';
|
|
4
4
|
import { RecordForm } from '../form/RecordForm';
|
|
5
|
-
import { Theme, SxProps } from '@mui/material';
|
|
5
|
+
import { Theme, SxProps, Typography } from '@mui/material';
|
|
6
6
|
|
|
7
7
|
export const recordFormPage: Page = {
|
|
8
8
|
name: 'Record Form',
|
|
@@ -10,9 +10,10 @@ export const recordFormPage: Page = {
|
|
|
10
10
|
auth: {
|
|
11
11
|
allUsers: true,
|
|
12
12
|
},
|
|
13
|
+
// No height override: the app's page container owns viewport height (dvh on mobile —
|
|
14
|
+
// a 100vh pin here clipped the bottom behind mobile browser chrome).
|
|
13
15
|
pageContainerSxProps: (theme: Theme): SxProps => {
|
|
14
16
|
return {
|
|
15
|
-
height: '100vh',
|
|
16
17
|
backgroundColor: theme.palette.background.default,
|
|
17
18
|
};
|
|
18
19
|
},
|
|
@@ -71,8 +72,9 @@ const DynamicRecordForm = ({ urlParams }: PageComponentProps) => {
|
|
|
71
72
|
if (tableName) {
|
|
72
73
|
try {
|
|
73
74
|
table = tableByName(tableName);
|
|
74
|
-
} catch
|
|
75
|
-
//
|
|
75
|
+
} catch {
|
|
76
|
+
// NOTE: this catch previously bound the exception as `error`, shadowing the outer
|
|
77
|
+
// variable — the message was never returned and the page rendered blank.
|
|
76
78
|
error = `Table not accessible in UI: ${tableName}`;
|
|
77
79
|
}
|
|
78
80
|
} else {
|
|
@@ -82,14 +84,18 @@ const DynamicRecordForm = ({ urlParams }: PageComponentProps) => {
|
|
|
82
84
|
return { table, error };
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
function Message({ children }: { children: React.ReactNode }) {
|
|
88
|
+
return <Typography sx={{ p: 3, color: 'text.secondary' }}>{children}</Typography>;
|
|
89
|
+
}
|
|
90
|
+
|
|
85
91
|
function Form() {
|
|
86
92
|
const { table, error } = getTable();
|
|
87
93
|
if (!table) {
|
|
88
|
-
return <
|
|
94
|
+
return <Message>{error}</Message>;
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
if (loadError) {
|
|
92
|
-
return <
|
|
98
|
+
return <Message>{loadError}</Message>;
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
if (!recordLoaded) {
|
|
@@ -97,7 +103,7 @@ const DynamicRecordForm = ({ urlParams }: PageComponentProps) => {
|
|
|
97
103
|
}
|
|
98
104
|
|
|
99
105
|
if (recordId && !record) {
|
|
100
|
-
return <
|
|
106
|
+
return <Message>{`No ${table.name} record found: ${recordId}`}</Message>;
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
return <RecordForm table={table} record={record} />;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Page, PageComponentProps } from '@proteinjs/ui';
|
|
3
3
|
import { tableByName, Table } from '@proteinjs/db';
|
|
4
4
|
import { RecordTable } from '../table/RecordTable';
|
|
5
|
-
import { Box, Paper, SxProps, Theme } from '@mui/material';
|
|
5
|
+
import { Box, Paper, SxProps, Theme, Typography } from '@mui/material';
|
|
6
6
|
|
|
7
7
|
export const recordTablePage: Page = {
|
|
8
8
|
name: 'Record Table',
|
|
@@ -10,19 +10,14 @@ export const recordTablePage: Page = {
|
|
|
10
10
|
auth: {
|
|
11
11
|
allUsers: true,
|
|
12
12
|
},
|
|
13
|
+
// No height override: the app's page container owns viewport height (dvh on mobile —
|
|
14
|
+
// a 100vh pin here clipped the bottom behind mobile browser chrome).
|
|
13
15
|
pageContainerSxProps: (theme: Theme): SxProps => {
|
|
14
16
|
return {
|
|
15
|
-
height: '100vh',
|
|
16
17
|
backgroundColor: theme.palette.background.default,
|
|
17
18
|
};
|
|
18
19
|
},
|
|
19
|
-
component: ({ ...props }) =>
|
|
20
|
-
<Box sx={{ display: 'flex', flexGrow: 1, justifyContent: 'center', padding: 4 }}>
|
|
21
|
-
<Paper sx={{ maxHeight: '80vh' }}>
|
|
22
|
-
<DynamicRecordTable {...props} />
|
|
23
|
-
</Paper>
|
|
24
|
-
</Box>
|
|
25
|
-
),
|
|
20
|
+
component: ({ ...props }) => <DynamicRecordTable {...props} />,
|
|
26
21
|
};
|
|
27
22
|
|
|
28
23
|
export const recordTableLink = (table: Table<any>) => {
|
|
@@ -48,11 +43,19 @@ const DynamicRecordTable = ({ urlParams }: PageComponentProps) => {
|
|
|
48
43
|
errorMessage = `Table not provided via the 'name' url param`;
|
|
49
44
|
}
|
|
50
45
|
|
|
46
|
+
// The error state renders as a plain message — wrapping it in the table's stretched
|
|
47
|
+
// card produced a full-height empty Paper with the text clipped at its edge.
|
|
51
48
|
if (!table) {
|
|
52
|
-
return <
|
|
49
|
+
return <Typography sx={{ p: 3, color: 'text.secondary' }}>{errorMessage}</Typography>;
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
return
|
|
52
|
+
return (
|
|
53
|
+
<Box sx={{ display: 'flex', flexGrow: 1, justifyContent: 'center', padding: 4 }}>
|
|
54
|
+
<Paper sx={{ maxHeight: '80vh' }}>
|
|
55
|
+
<RecordTable table={table} />
|
|
56
|
+
</Paper>
|
|
57
|
+
</Box>
|
|
58
|
+
);
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
return <Table />;
|
package/src/pages/TablesPage.tsx
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
3
|
+
import { recordFormPage } from '../src/pages/RecordFormPage';
|
|
4
|
+
import { recordTablePage } from '../src/pages/RecordTablePage';
|
|
5
|
+
|
|
6
|
+
describe('record form page error states', () => {
|
|
7
|
+
it('renders the not-accessible message for an unknown table (regression: a shadowed catch binding swallowed the message and the page rendered blank)', () => {
|
|
8
|
+
const Form = recordFormPage.component;
|
|
9
|
+
const html = renderToStaticMarkup(<Form urlParams={{ table: 'NotARealTable' }} />);
|
|
10
|
+
expect(html).toContain('Table not accessible in UI: NotARealTable');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('renders the missing-param message when no table is provided', () => {
|
|
14
|
+
const Form = recordFormPage.component;
|
|
15
|
+
const html = renderToStaticMarkup(<Form urlParams={{}} />);
|
|
16
|
+
// (apostrophes render HTML-escaped in static markup, so assert around them)
|
|
17
|
+
expect(html).toContain('Table name not provided via the');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('record table page error states', () => {
|
|
22
|
+
it('renders the not-accessible message outside the table card (the stretched Paper clipped it)', () => {
|
|
23
|
+
const Table = recordTablePage.component;
|
|
24
|
+
const html = renderToStaticMarkup(<Table urlParams={{ name: 'NotARealTable' }} />);
|
|
25
|
+
expect(html).toContain('Table not accessible in UI: NotARealTable');
|
|
26
|
+
expect(html).not.toContain('MuiPaper');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('renders the missing-param message when no name is provided', () => {
|
|
30
|
+
const Table = recordTablePage.component;
|
|
31
|
+
const html = renderToStaticMarkup(<Table urlParams={{}} />);
|
|
32
|
+
// (apostrophes render HTML-escaped in static markup, so assert around them)
|
|
33
|
+
expect(html).toContain('Table not provided via the');
|
|
34
|
+
});
|
|
35
|
+
});
|