Skip to content

Commit 1d9eed4

Browse files
committed
Merge remote-tracking branch 'origin/tomaskislan/grn-4776-support-input-blocks' into tomaskislan/grn-4784-expand-add-new-blocks-functionality-to-support-our-new
2 parents b133a6b + 6337c84 commit 1d9eed4

File tree

13 files changed

+219
-183
lines changed

13 files changed

+219
-183
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = {
7474
'import/no-unresolved': [
7575
'error',
7676
{
77-
ignore: ['monaco-editor', 'vscode']
77+
ignore: ['monaco-editor', 'vscode', 'error-boundary']
7878
}
7979
],
8080
'import/prefer-default-export': 'off',

package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,7 @@
22752275
"react": "^16.5.2",
22762276
"react-data-grid": "^6.0.2-0",
22772277
"react-dom": "^16.5.2",
2278+
"react-error-boundary": "^6.0.0",
22782279
"react-redux": "^7.1.1",
22792280
"react-svg-pan-zoom": "3.9.0",
22802281
"react-svgmt": "1.1.11",

src/kernels/execution/cellExecutionMessageHandler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,8 @@ export class CellExecutionMessageHandler implements IDisposable {
11841184
);
11851185

11861186
const data = msg.content.data;
1187+
// deepnote-toolkit returns the text/plain mime type for big number outputs
1188+
// and for the custom renderer to be used, we need to return the application/vnd.deepnote.chart.big-number+json mime type
11871189
if (outputToBeUpdated.cell.metadata['__deepnotePocket']?.['type'] === 'big-number') {
11881190
data[CHART_BIG_NUMBER_MIME_TYPE] = data['text/plain'];
11891191
delete data['text/plain'];

src/kernels/execution/helpers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ function translateDisplayDataOutput(
262262
}
263263
}
264264
*/
265-
// TODO - add DeepnotePocket zod schema validation
266265
const deepnotePocket = cellMetadata?.__deepnotePocket as Pocket | undefined;
267266
const deepnoteBlockType = deepnotePocket?.type;
268267

src/notebooks/deepnote/converters/chartBigNumberBlockConverter.unit.test.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,14 @@ suite('ChartBigNumberBlockConverter', () => {
268268

269269
const config = JSON.parse(cell.value);
270270
assert.deepStrictEqual(config, {
271-
deepnote_big_number_title: null,
272-
deepnote_big_number_value: null,
273-
deepnote_big_number_format: null,
274-
deepnote_big_number_comparison_type: null,
275-
deepnote_big_number_comparison_title: null,
276-
deepnote_big_number_comparison_value: null,
277-
deepnote_big_number_comparison_format: null,
278-
deepnote_big_number_comparison_enabled: null
271+
deepnote_big_number_title: '',
272+
deepnote_big_number_value: '',
273+
deepnote_big_number_format: 'number',
274+
deepnote_big_number_comparison_type: '',
275+
deepnote_big_number_comparison_title: '',
276+
deepnote_big_number_comparison_value: '',
277+
deepnote_big_number_comparison_format: '',
278+
deepnote_big_number_comparison_enabled: false
279279
});
280280
});
281281

@@ -296,14 +296,14 @@ suite('ChartBigNumberBlockConverter', () => {
296296

297297
const config = JSON.parse(cell.value);
298298
assert.deepStrictEqual(config, {
299-
deepnote_big_number_title: null,
300-
deepnote_big_number_value: null,
301-
deepnote_big_number_format: null,
302-
deepnote_big_number_comparison_type: null,
303-
deepnote_big_number_comparison_title: null,
304-
deepnote_big_number_comparison_value: null,
305-
deepnote_big_number_comparison_format: null,
306-
deepnote_big_number_comparison_enabled: null
299+
deepnote_big_number_title: '',
300+
deepnote_big_number_value: '',
301+
deepnote_big_number_format: 'number',
302+
deepnote_big_number_comparison_type: '',
303+
deepnote_big_number_comparison_title: '',
304+
deepnote_big_number_comparison_value: '',
305+
deepnote_big_number_comparison_format: '',
306+
deepnote_big_number_comparison_enabled: false
307307
});
308308
});
309309
});
@@ -445,13 +445,13 @@ suite('ChartBigNumberBlockConverter', () => {
445445
metadata: {
446446
custom: 'value',
447447
deepnote_big_number_title: 'new title',
448-
deepnote_big_number_comparison_enabled: null,
449-
deepnote_big_number_comparison_format: null,
450-
deepnote_big_number_comparison_title: null,
451-
deepnote_big_number_comparison_type: null,
452-
deepnote_big_number_comparison_value: null,
453-
deepnote_big_number_format: null,
454-
deepnote_big_number_value: null
448+
deepnote_big_number_comparison_enabled: false,
449+
deepnote_big_number_comparison_format: '',
450+
deepnote_big_number_comparison_title: '',
451+
deepnote_big_number_comparison_type: '',
452+
deepnote_big_number_comparison_value: '',
453+
deepnote_big_number_format: 'number',
454+
deepnote_big_number_value: ''
455455
},
456456
outputs: [],
457457
sortingKey: 'a0',

src/notebooks/deepnote/converters/inputConverters.unit.test.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ suite('InputTextBlockConverter', () => {
6565
assert.strictEqual(cell.languageId, 'json');
6666

6767
const parsed = JSON.parse(cell.value);
68-
assert.isNull(parsed.deepnote_input_label);
69-
assert.isNull(parsed.deepnote_variable_name);
70-
assert.isNull(parsed.deepnote_variable_value);
68+
assert.strictEqual(parsed.deepnote_input_label, '');
69+
assert.strictEqual(parsed.deepnote_variable_name, '');
70+
assert.strictEqual(parsed.deepnote_variable_value, '');
7171
assert.isNull(parsed.deepnote_variable_default_value);
7272
});
7373

@@ -223,9 +223,9 @@ suite('InputTextareaBlockConverter', () => {
223223
const cell = converter.convertToCell(block);
224224

225225
const parsed = JSON.parse(cell.value);
226-
assert.isNull(parsed.deepnote_variable_name);
227-
assert.isNull(parsed.deepnote_variable_value);
228-
assert.isNull(parsed.deepnote_input_label);
226+
assert.strictEqual(parsed.deepnote_variable_name, '');
227+
assert.strictEqual(parsed.deepnote_variable_value, '');
228+
assert.strictEqual(parsed.deepnote_input_label, '');
229229
});
230230
});
231231

@@ -371,8 +371,8 @@ suite('InputSelectBlockConverter', () => {
371371
const cell = converter.convertToCell(block);
372372

373373
const parsed = JSON.parse(cell.value);
374-
assert.isNull(parsed.deepnote_variable_name);
375-
assert.isNull(parsed.deepnote_variable_value);
374+
assert.strictEqual(parsed.deepnote_variable_name, '');
375+
assert.strictEqual(parsed.deepnote_variable_value, 'Option 1');
376376
});
377377
});
378378

@@ -513,9 +513,9 @@ suite('InputSliderBlockConverter', () => {
513513
const cell = converter.convertToCell(block);
514514

515515
const parsed = JSON.parse(cell.value);
516-
assert.isNull(parsed.deepnote_variable_name);
517-
assert.isNull(parsed.deepnote_slider_min_value);
518-
assert.isNull(parsed.deepnote_slider_max_value);
516+
assert.strictEqual(parsed.deepnote_variable_name, '');
517+
assert.strictEqual(parsed.deepnote_slider_min_value, 0);
518+
assert.strictEqual(parsed.deepnote_slider_max_value, 10);
519519
});
520520
});
521521

@@ -561,7 +561,8 @@ suite('InputSliderBlockConverter', () => {
561561

562562
converter.applyChangesToBlock(block, cell);
563563

564-
assert.strictEqual(block.metadata?.deepnote_variable_value, 42);
564+
// Numeric values fail string schema validation, so stored in raw content
565+
assert.strictEqual(block.metadata?.[DEEPNOTE_VSCODE_RAW_CONTENT_KEY], cellValue);
565566
});
566567

567568
test('handles invalid JSON', () => {
@@ -645,8 +646,8 @@ suite('InputCheckboxBlockConverter', () => {
645646
const cell = converter.convertToCell(block);
646647

647648
const parsed = JSON.parse(cell.value);
648-
assert.isNull(parsed.deepnote_variable_name);
649-
assert.isNull(parsed.deepnote_variable_value);
649+
assert.strictEqual(parsed.deepnote_variable_name, '');
650+
assert.strictEqual(parsed.deepnote_variable_value, false);
650651
});
651652
});
652653

@@ -755,8 +756,9 @@ suite('InputDateBlockConverter', () => {
755756
const cell = converter.convertToCell(block);
756757

757758
const parsed = JSON.parse(cell.value);
758-
assert.isNull(parsed.deepnote_variable_name);
759-
assert.isNull(parsed.deepnote_variable_value);
759+
assert.strictEqual(parsed.deepnote_variable_name, '');
760+
// Default value should be an ISO date string
761+
assert.match(parsed.deepnote_variable_value, /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/);
760762
});
761763
});
762764

@@ -865,8 +867,8 @@ suite('InputDateRangeBlockConverter', () => {
865867
const cell = converter.convertToCell(block);
866868

867869
const parsed = JSON.parse(cell.value);
868-
assert.isNull(parsed.deepnote_variable_name);
869-
assert.isNull(parsed.deepnote_variable_value);
870+
assert.strictEqual(parsed.deepnote_variable_name, '');
871+
assert.strictEqual(parsed.deepnote_variable_value, '');
870872
});
871873
});
872874

@@ -973,7 +975,7 @@ suite('InputFileBlockConverter', () => {
973975
const cell = converter.convertToCell(block);
974976

975977
const parsed = JSON.parse(cell.value);
976-
assert.isNull(parsed.deepnote_variable_name);
978+
assert.strictEqual(parsed.deepnote_variable_name, '');
977979
assert.isNull(parsed.deepnote_allowed_file_extensions);
978980
});
979981
});
@@ -1085,8 +1087,8 @@ suite('ButtonBlockConverter', () => {
10851087
const cell = converter.convertToCell(block);
10861088

10871089
const parsed = JSON.parse(cell.value);
1088-
assert.isNull(parsed.deepnote_button_title);
1089-
assert.isNull(parsed.deepnote_button_behavior);
1090+
assert.strictEqual(parsed.deepnote_button_title, 'Run');
1091+
assert.strictEqual(parsed.deepnote_button_behavior, 'set_variable');
10901092
});
10911093
});
10921094

src/notebooks/deepnote/deepnoteDataConverter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,10 @@ export class DeepnoteDataConverter {
378378
);
379379
}
380380

381-
// Plain text as fallback (always last)
382381
if (data['text/plain']) {
383382
let mimeType = 'text/plain';
383+
// deepnote-toolkit returns the text/plain mime type for big number outputs
384+
// and for the custom renderer to be used, we need to return the application/vnd.deepnote.chart.big-number+json mime type
384385
if (blockType === 'big-number' && !(CHART_BIG_NUMBER_MIME_TYPE in data)) {
385386
mimeType = CHART_BIG_NUMBER_MIME_TYPE;
386387
}

0 commit comments

Comments
 (0)