Skip to content

Commit caa6bc8

Browse files
authored
fix: Cannot import CSV with LOCAL_TIME (#1434)
- Fix adding error console history items - They weren't appearing as anything because the command was `''` instead of `undefined` - Map LOCAL_TIME to STRING on CSV import - `LOCAL_TIME` isn't supported on the server in DHC, and isn't really "safe" anyways since we should have other info in there as well (e.g. date or time zone) - When exporting, should be exporting the 'unformatted' value, which gives you the full timestamp - By mapping to String, user can then do an `.update_view` to map it to a timestamp if they wish - Fixes #1432
1 parent e3db6bf commit caa6bc8

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

packages/console/src/Console.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,6 @@ export class Console extends PureComponent<ConsoleProps, ConsoleState> {
765765
addConsoleHistoryMessage(message?: string, error?: string): void {
766766
const { consoleHistory } = this.state;
767767
const historyItem = {
768-
command: '',
769768
startTime: Date.now(),
770769
endTime: Date.now(),
771770
result: { message, error },

packages/console/src/console-history/ConsoleHistoryItem.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ class ConsoleHistoryItem extends PureComponent<
5555
render(): ReactElement {
5656
const { disabled, item, language } = this.props;
5757
const { disabledObjects, result } = item;
58+
const hasCommand = item.command != null && item.command !== '';
5859

5960
let commandElement = null;
60-
if (item.command != null && item.command !== '') {
61+
if (hasCommand) {
6162
commandElement = (
6263
<div className="console-history-item-command">
6364
<div className="console-history-gutter">&gt;</div>
@@ -101,7 +102,7 @@ class ConsoleHistoryItem extends PureComponent<
101102
}
102103

103104
// If the error has an associated command, we'll actually get a separate ERROR item printed out, so only print an error if there isn't an associated command
104-
if (error != null && item.command == null) {
105+
if (error != null && !hasCommand) {
105106
let errorMessage = `${(error as { message: string }).message ?? error}`;
106107
if (!errorMessage) {
107108
errorMessage = error as string;

packages/console/src/csv/CsvTypeParser.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Papa, { Parser, ParseResult, ParseLocalConfig } from 'papaparse';
55
/* eslint-disable no-restricted-globals */
66
import NewTableColumnTypes from './NewTableColumnTypes';
77

8-
// Initially column types start al unknown
8+
// Initially column types start as unknown
99
const UNKNOWN = 'unknown';
1010

1111
const MAX_INT = 2147483647;
@@ -288,7 +288,12 @@ class CsvTypeParser {
288288
if (results == null || !results.meta.aborted) {
289289
onFileCompleted(
290290
types.map(type =>
291-
type === UNKNOWN ? NewTableColumnTypes.STRING : type
291+
// If the type is still unknown or a local time, just map it to a string.
292+
// Local times are not supported by the backend in DHC, and probably should have more context to parse safely anyway (such as a date or a time zone).
293+
// In these cases, we just map it to a string, and the user can use an `.update_view` later if they want to parse it into a different type.
294+
type === UNKNOWN || type === NewTableColumnTypes.LOCAL_TIME
295+
? NewTableColumnTypes.STRING
296+
: type
292297
)
293298
);
294299
}

0 commit comments

Comments
 (0)