Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Then, import and use the component from the package:
import { Chart } from '@deephaven/chart';

// In your render function
<Chart model={model} />
<Chart dh={dh} model={model} />
```
4 changes: 4 additions & 0 deletions packages/chart/src/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
dhWarningFilled,
IconDefinition,
} from '@deephaven/icons';
import type { dh as DhType } from '@deephaven/jsapi-types';
import {
Formatter,
FormatterUtils,
Expand Down Expand Up @@ -35,6 +36,7 @@ type FormatterSettings = ColumnFormatSettings &
};

interface ChartProps {
dh: DhType;
model: ChartModel;
settings: FormatterSettings;
isActive: boolean;
Expand Down Expand Up @@ -505,7 +507,9 @@ export class Chart extends Component<ChartProps, ChartState> {
}

updateFormatter(): void {
const { dh } = this.props;
const formatter = new Formatter(
dh,
this.columnFormats,
this.dateTimeFormatterOptions,
this.decimalFormatOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/chart/src/ChartUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ChartTheme from './ChartTheme';
const chartUtils = new ChartUtils(dh);

function makeFormatter() {
return new Formatter();
return new Formatter(dh);
}

it('groups the axes by type properly', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/code-studio/src/main/AppMainContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ export class AppMainContainer extends Component<
<FilterPlugin />
<PandasPlugin hydrate={this.hydratePandas} />
<MarkdownPlugin />
<LinkerPlugin />
<LinkerPlugin dh={dh} />
Comment thread
vbabich marked this conversation as resolved.
Outdated
{dashboardPlugins}
</Dashboard>
<CSSTransition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { WorkspaceSettings } from '@deephaven/redux';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { Formatter } from '@deephaven/jsapi-utils';

import dh from '@deephaven/jsapi-shim';
import {
ColumnSpecificSectionContent,
ColumnSpecificSectionContentProps,
Expand Down Expand Up @@ -35,6 +35,7 @@ function renderContent({
}: Partial<ColumnSpecificSectionContentProps> = {}) {
return render(
<ColumnSpecificSectionContent
dh={dh}
formatter={formatter}
defaultDateTimeFormat={defaultDateTimeFormat}
showTimeZone={showTimeZone}
Expand Down
15 changes: 13 additions & 2 deletions packages/code-studio/src/settings/ColumnSpecificSectionContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
TableColumnFormat,
FormattingRule,
} from '@deephaven/jsapi-utils';
import { dh as DhType } from '@deephaven/jsapi-types';
import {
getDefaultDateTimeFormat,
getDefaultDecimalFormatOptions,
Expand All @@ -42,12 +43,14 @@ import {
isValidFormat,
removeFormatRuleExtraProps,
isFormatRuleValidForSave,
ValidFormatterItem,
} from './SettingsUtils';
import type { FormatterItem, FormatOption } from './SettingsUtils';
import ColumnTypeOptions from './ColumnTypeOptions';
import DateTimeOptions from './DateTimeOptions';

export interface ColumnSpecificSectionContentProps {
dh: DhType;
Comment thread
vbabich marked this conversation as resolved.
formatter: FormatterItem[];
defaultDateTimeFormat: string;
showTimeZone: boolean;
Expand Down Expand Up @@ -190,8 +193,10 @@ export class ColumnSpecificSectionContent extends PureComponent<
legacyGlobalFormat?: string
) => {
const { timestampAtMenuOpen } = this.state;
const { dh } = this.props;
return (
<DateTimeOptions
dh={dh}
timestamp={timestampAtMenuOpen}
timeZone={timeZone}
showTimeZone={showTimeZone}
Expand Down Expand Up @@ -288,10 +293,13 @@ export class ColumnSpecificSectionContent extends PureComponent<
defaultIntegerFormatOptions,
truncateNumbersWithPound,
} = this.state;
const { dh } = this.props;

const formatter =
formatSettings
.filter(isFormatRuleValidForSave)
.filter((format): format is ValidFormatterItem =>
isFormatRuleValidForSave(dh, format)
)
.map(removeFormatRuleExtraProps) ?? [];

const { settings, saveSettings } = this.props;
Expand All @@ -306,6 +314,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
};
if (
isValidFormat(
dh,
TableUtils.dataType.DECIMAL,
DecimalColumnFormatter.makeCustomFormat(
defaultDecimalFormatOptions.defaultFormatString
Expand All @@ -316,6 +325,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
}
if (
isValidFormat(
dh,
TableUtils.dataType.INT,
IntegerColumnFormatter.makeCustomFormat(
defaultIntegerFormatOptions.defaultFormatString
Expand All @@ -339,6 +349,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
getRuleError(
rule: FormatterItem
): { hasColumnNameError: boolean; hasFormatError: boolean; message: string } {
const { dh } = this.props;
const error = {
hasColumnNameError: false,
hasFormatError: false,
Expand Down Expand Up @@ -369,7 +380,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
) {
error.hasFormatError = true;
errorMessages.push('Empty formatting rule.');
} else if (!isValidFormat(rule.columnType, rule.format)) {
} else if (!isValidFormat(dh, rule.columnType, rule.format)) {
error.hasFormatError = true;
errorMessages.push('Invalid formatting rule.');
}
Expand Down
5 changes: 4 additions & 1 deletion packages/code-studio/src/settings/DateTimeOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
DateTimeColumnFormatter,
TableUtils,
} from '@deephaven/jsapi-utils';
import { dh as DhType } from '@deephaven/jsapi-types';

interface DateTimeOptionProps {
dh: DhType;
timestamp: Date;
timeZone: string;
showTimeZone: boolean;
Expand All @@ -18,6 +20,7 @@ export default function DateTimeOptions(
props: DateTimeOptionProps
): ReactElement {
const {
dh,
Comment thread
vbabich marked this conversation as resolved.
Outdated
timestamp,
timeZone,
showTimeZone,
Expand All @@ -26,7 +29,7 @@ export default function DateTimeOptions(
legacyGlobalFormat,
} = props;

const formatter = new Formatter([], {
const formatter = new Formatter(dh, [], {
Comment thread
vbabich marked this conversation as resolved.
Outdated
timeZone,
showTimeZone,
showTSeparator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import dh from '@deephaven/jsapi-shim';
import { DateTimeColumnFormatter } from '@deephaven/jsapi-utils';
import { WorkspaceSettings } from '@deephaven/redux';
import { assertNotNull } from '@deephaven/utils';
Expand Down Expand Up @@ -46,6 +47,7 @@ function renderSectionContent({
} = {}) {
return render(
<FormattingSectionContent
dh={dh}
settings={settings as WorkspaceSettings}
formatter={formatter}
showTimeZone={showTimeZone}
Expand Down
16 changes: 14 additions & 2 deletions packages/code-studio/src/settings/FormattingSectionContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
DecimalColumnFormatter,
TableUtils,
} from '@deephaven/jsapi-utils';
import { dh as DhType } from '@deephaven/jsapi-types';
import Log from '@deephaven/log';
import {
getDefaultDateTimeFormat,
Expand All @@ -40,6 +41,7 @@ import {
isValidFormat,
removeFormatRuleExtraProps,
isFormatRuleValidForSave,
ValidFormatterItem,
} from './SettingsUtils';
import type { FormatterItem, FormatOption } from './SettingsUtils';
import DateTimeOptions from './DateTimeOptions';
Expand All @@ -48,6 +50,7 @@ import TimeZoneOptions from './TimeZoneOptions';
const log = Log.module('FormattingSectionContent');

interface FormattingSectionContentProps {
dh: DhType;
Comment thread
vbabich marked this conversation as resolved.
formatter: FormatterItem[];
defaultDateTimeFormat: string;
showTimeZone: boolean;
Expand Down Expand Up @@ -185,8 +188,10 @@ export class FormattingSectionContent extends PureComponent<
legacyGlobalFormat?: string
) => {
const { timestampAtMenuOpen } = this.state;
const { dh } = this.props;
return (
<DateTimeOptions
dh={dh}
timestamp={timestampAtMenuOpen}
timeZone={timeZone}
showTimeZone={showTimeZone}
Expand Down Expand Up @@ -353,10 +358,13 @@ export class FormattingSectionContent extends PureComponent<
defaultIntegerFormatOptions,
truncateNumbersWithPound,
} = this.state;
const { dh } = this.props;

const formatter =
formatSettings
.filter(isFormatRuleValidForSave)
.filter((format): format is ValidFormatterItem =>
isFormatRuleValidForSave(dh, format)
)
.map(removeFormatRuleExtraProps) ?? [];

const { settings, saveSettings } = this.props;
Expand All @@ -371,6 +379,7 @@ export class FormattingSectionContent extends PureComponent<
};
if (
isValidFormat(
dh,
TableUtils.dataType.DECIMAL,
DecimalColumnFormatter.makeCustomFormat(
defaultDecimalFormatOptions.defaultFormatString
Expand All @@ -381,6 +390,7 @@ export class FormattingSectionContent extends PureComponent<
}
if (
isValidFormat(
dh,
TableUtils.dataType.INT,
IntegerColumnFormatter.makeCustomFormat(
defaultIntegerFormatOptions.defaultFormatString
Expand All @@ -393,7 +403,7 @@ export class FormattingSectionContent extends PureComponent<
}

render(): ReactElement {
const { defaults } = this.props;
const { defaults, dh } = this.props;
const {
defaultDateTimeFormat,
defaultDecimalFormatOptions,
Expand Down Expand Up @@ -532,6 +542,7 @@ export class FormattingSectionContent extends PureComponent<
'default-decimal-format-input',
{
'is-invalid': !isValidFormat(
dh,
TableUtils.dataType.DECIMAL,
DecimalColumnFormatter.makeCustomFormat(
defaultDecimalFormatString
Expand Down Expand Up @@ -575,6 +586,7 @@ export class FormattingSectionContent extends PureComponent<
'default-integer-format-input',
{
'is-invalid': !isValidFormat(
dh,
TableUtils.dataType.INT,
IntegerColumnFormatter.makeCustomFormat(
defaultIntegerFormatString
Expand Down
7 changes: 5 additions & 2 deletions packages/code-studio/src/settings/SettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class SettingsMenu extends Component<
}
onToggle={this.handleSectionToggle}
>
<FormattingSectionContent />
<FormattingSectionContent dh={dh} />
Comment thread
vbabich marked this conversation as resolved.
Outdated
</SettingsMenuSection>

<SettingsMenuSection
Expand All @@ -229,7 +229,10 @@ export class SettingsMenu extends Component<
}
onToggle={this.handleSectionToggle}
>
<ColumnSpecificSectionContent scrollTo={this.handleScrollTo} />
<ColumnSpecificSectionContent
dh={dh}
scrollTo={this.handleScrollTo}
/>
</SettingsMenuSection>

<SettingsMenuSection
Expand Down
13 changes: 8 additions & 5 deletions packages/code-studio/src/settings/SettingsUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {
TableColumnFormat,
FormattingRule,
} from '@deephaven/jsapi-utils';
import { dh as DhType } from '@deephaven/jsapi-types';
import Log from '@deephaven/log';

const log = Log.module('FormattingSectionContent');
const log = Log.module('SettingsUtils');

export type FormatOption = {
defaultFormatString?: string;
Expand Down Expand Up @@ -68,6 +69,7 @@ export function isValidColumnName(name: string): boolean {
}

export function isValidFormat(
dh: DhType,
columnType: string,
format: Partial<TableColumnFormat>
): boolean {
Expand All @@ -81,11 +83,11 @@ export function isValidFormat(
}
switch (columnType) {
case 'datetime':
return DateTimeColumnFormatter.isValid(format);
return DateTimeColumnFormatter.isValid(dh, format);
case 'decimal':
return DecimalColumnFormatter.isValid(format);
return DecimalColumnFormatter.isValid(dh, format);
case 'int':
return IntegerColumnFormatter.isValid(format);
return IntegerColumnFormatter.isValid(dh, format);
default: {
log.warn('Trying to validate format of unknown type');
return true;
Expand All @@ -101,11 +103,12 @@ export function removeFormatRuleExtraProps(
}

export function isFormatRuleValidForSave(
dh: DhType,
rule: FormatterItem
): rule is ValidFormatterItem {
return (
isValidColumnName(rule.columnName) &&
isValidFormat(rule.columnType, rule.format)
isValidFormat(dh, rule.columnType, rule.format)
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/code-studio/src/styleguide/Charts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function Charts(): ReactElement {
<div>
<h2 className="ui-title">Chart</h2>
<div style={{ height: 500 }}>
<Chart model={model as ChartModel} />
<Chart dh={dh} model={model as ChartModel} />
</div>
</div>
);
Expand Down
14 changes: 11 additions & 3 deletions packages/dashboard-core-plugins/src/LinkerPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ import {
assertIsDashboardPluginProps,
DashboardPluginComponentProps,
} from '@deephaven/dashboard';
import { dh as DhType } from '@deephaven/jsapi-types';
import Linker from './linker/Linker';

export type LinkerPluginProps = Partial<DashboardPluginComponentProps>;
export type LinkerPluginProps = Partial<DashboardPluginComponentProps> & {
dh: DhType;
};

export function LinkerPlugin(props: LinkerPluginProps): JSX.Element {
assertIsDashboardPluginProps(props);
const { id, layout, panelManager } = props;
const { dh, id, layout, panelManager } = props;
return (
<Linker layout={layout} localDashboardId={id} panelManager={panelManager} />
<Linker
dh={dh}
Comment thread
vbabich marked this conversation as resolved.
Outdated
layout={layout}
localDashboardId={id}
panelManager={panelManager}
/>
);
}

Expand Down
Loading