Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
3 changes: 1 addition & 2 deletions packages/code-studio/src/main/AppInit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
setWorkspaceStorage as setWorkspaceStorageAction,
setServerConfigValues as setServerConfigValuesAction,
User,
Workspace,
WorkspaceStorage,
ServerConfigValues,
WorkspaceSettings,
Expand All @@ -59,7 +58,7 @@ import GrpcFileStorage from '../storage/grpc/GrpcFileStorage';
const log = Log.module('AppInit');

interface AppInitProps {
workspace: Workspace;
workspace: CustomizableWorkspace;
workspaceStorage: WorkspaceStorage;

setActiveTool: (type: (typeof ToolType)[keyof typeof ToolType]) => void;
Expand Down
4 changes: 2 additions & 2 deletions packages/code-studio/src/main/AppMainContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ import {
setActiveTool as setActiveToolAction,
updateWorkspaceData as updateWorkspaceDataAction,
getPlugins,
Workspace,
WorkspaceData,
RootState,
User,
ServerConfigValues,
CustomizableWorkspace,
} from '@deephaven/redux';
import { bindAllMethods, PromiseUtils } from '@deephaven/utils';
import GoldenLayout from '@deephaven/golden-layout';
Expand Down Expand Up @@ -130,7 +130,7 @@ interface AppMainContainerProps {
updateDashboardData: (id: string, data: Partial<AppDashboardData>) => void;
updateWorkspaceData: (workspaceData: Partial<WorkspaceData>) => void;
user: User;
workspace: Workspace;
workspace: CustomizableWorkspace;
plugins: PluginModuleMap;
serverConfigValues: ServerConfigValues;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function renderContent({
timeZone = '',
truncateNumbersWithPound = false,
settings = {} as WorkspaceSettings,
saveSettings = jest.fn(),
updateSettings = jest.fn(),
scrollTo = undefined,
defaultDecimalFormatOptions = {
defaultFormatString: DEFAULT_DECIMAL_STRING,
Expand All @@ -45,7 +45,7 @@ function renderContent({
timeZone={timeZone}
truncateNumbersWithPound={truncateNumbersWithPound}
settings={settings}
saveSettings={saveSettings}
updateSettings={updateSettings}
scrollTo={scrollTo}
defaultDecimalFormatOptions={defaultDecimalFormatOptions}
defaultIntegerFormatOptions={defaultIntegerFormatOptions}
Expand Down
45 changes: 12 additions & 33 deletions packages/code-studio/src/settings/ColumnSpecificSectionContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
getTimeZone,
getShowTimeZone,
getShowTSeparator,
saveSettings as saveSettingsAction,
updateSettings as updateSettingsAction,
RootState,
WorkspaceSettings,
} from '@deephaven/redux';
Expand All @@ -49,14 +49,14 @@ import DateTimeOptions from './DateTimeOptions';

export interface ColumnSpecificSectionContentProps {
dh: DhType;
formatter?: FormatterItem[];
showTimeZone?: boolean;
showTSeparator?: boolean;
timeZone?: string;
saveSettings: (settings: Partial<WorkspaceSettings>) => void;
formatter: FormatterItem[];
showTimeZone: boolean;
showTSeparator: boolean;
timeZone: string;
updateSettings: (settings: Partial<WorkspaceSettings>) => void;
scrollTo: (x: number, y: number) => void;
defaultDecimalFormatOptions?: FormatOption;
defaultIntegerFormatOptions?: FormatOption;
defaultDecimalFormatOptions: FormatOption;
defaultIntegerFormatOptions: FormatOption;
}

interface ColumnSpecificSectionContentState {
Expand All @@ -74,19 +74,6 @@ export class ColumnSpecificSectionContent extends PureComponent<
> {
static defaultProps = {
scrollTo: (): void => undefined,
defaults: {
defaultDateTimeFormat:
DateTimeColumnFormatter.DEFAULT_DATETIME_FORMAT_STRING,
defaultDecimalFormatOptions: {
defaultFormatString: DecimalColumnFormatter.DEFAULT_FORMAT_STRING,
},
defaultIntegerFormatOptions: {
defaultFormatString: IntegerColumnFormatter.DEFAULT_FORMAT_STRING,
},
showTimeZone: false,
showTSeparator: true,
timeZone: DateTimeColumnFormatter.DEFAULT_TIME_ZONE_ID,
},
};

static inputDebounceTime = 250;
Expand All @@ -106,11 +93,6 @@ export class ColumnSpecificSectionContent extends PureComponent<

const { formatter, showTimeZone, showTSeparator, timeZone } = props;

assertNotNull(formatter);
assertNotNull(showTimeZone);
assertNotNull(showTSeparator);
assertNotNull(timeZone);

const formatSettings = formatter.map((item, i) => ({
...item,
id: i,
Expand Down Expand Up @@ -275,11 +257,11 @@ export class ColumnSpecificSectionContent extends PureComponent<
)
.map(removeFormatRuleExtraProps) ?? [];

const { saveSettings } = this.props;
const { updateSettings } = this.props;
const newSettings = {
formatter: formatter as FormattingRule[],
};
saveSettings(newSettings);
updateSettings(newSettings);
}

scrollToFormatBlockBottom(): void {
Expand Down Expand Up @@ -342,7 +324,6 @@ export class ColumnSpecificSectionContent extends PureComponent<
switch (TableUtils.getNormalizedType(columnType)) {
case TableUtils.dataType.INT: {
const { defaultIntegerFormatOptions } = this.props;
assertNotNull(defaultIntegerFormatOptions);
const { defaultFormatString: defaultIntegerFormatString } =
defaultIntegerFormatOptions;
return IntegerColumnFormatter.makeFormat(
Expand All @@ -356,7 +337,6 @@ export class ColumnSpecificSectionContent extends PureComponent<

case TableUtils.dataType.DECIMAL: {
const { defaultDecimalFormatOptions } = this.props;
assertNotNull(defaultDecimalFormatOptions);
const { defaultFormatString: defaultDecimalFormatString } =
defaultDecimalFormatOptions;
return DecimalColumnFormatter.makeFormat(
Expand Down Expand Up @@ -565,7 +545,6 @@ export class ColumnSpecificSectionContent extends PureComponent<
isInvalid: boolean
): ReactElement {
const { defaultDecimalFormatOptions } = this.props;
assertNotNull(defaultDecimalFormatOptions);
const { defaultFormatString } = defaultDecimalFormatOptions;

const value = format.formatString ?? '';
Expand Down Expand Up @@ -643,7 +622,7 @@ export class ColumnSpecificSectionContent extends PureComponent<

const mapStateToProps = (
state: RootState
): Omit<ColumnSpecificSectionContentProps, 'saveSettings' | 'scrollTo'> => ({
): Omit<ColumnSpecificSectionContentProps, 'updateSettings' | 'scrollTo'> => ({
formatter: getFormatter(state),
defaultDecimalFormatOptions: getDefaultDecimalFormatOptions(state),
defaultIntegerFormatOptions: getDefaultIntegerFormatOptions(state),
Expand All @@ -654,7 +633,7 @@ const mapStateToProps = (
});

const ConnectedColumnSpecificSectionContent = connect(mapStateToProps, {
saveSettings: saveSettingsAction,
updateSettings: updateSettingsAction,
})(ColumnSpecificSectionContent);

export default ConnectedColumnSpecificSectionContent;
32 changes: 18 additions & 14 deletions packages/code-studio/src/settings/FormattingSectionContent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function renderSectionContent({
showTSeparator = false,
timeZone = '',
defaultDateTimeFormat = '',
saveSettings = jest.fn(),
updateSettings = jest.fn(),
scrollTo = jest.fn(),
defaultDecimalFormatOptions = {
defaultFormatString: DEFAULT_DECIMAL_STRING,
Expand All @@ -57,7 +57,7 @@ function renderSectionContent({
timeZone={timeZone}
defaultDateTimeFormat={defaultDateTimeFormat}
truncateNumbersWithPound={truncateNumbersWithPound}
saveSettings={saveSettings}
updateSettings={updateSettings}
scrollTo={scrollTo}
defaultDecimalFormatOptions={defaultDecimalFormatOptions}
defaultIntegerFormatOptions={defaultIntegerFormatOptions}
Expand Down Expand Up @@ -90,16 +90,18 @@ describe('default decimal formatting', () => {

it('updates settings when value is changed', async () => {
const user = userEvent.setup({ delay: null });
const saveSettings = jest.fn();
const { getByLabelText, unmount } = renderSectionContent({ saveSettings });
const updateSettings = jest.fn();
const { getByLabelText, unmount } = renderSectionContent({
updateSettings,
});
const newFormat = '00.0';
const input = getByLabelText('Decimal');
await user.clear(input);
await user.type(input, newFormat);

jest.runOnlyPendingTimers();

expect(saveSettings).toHaveBeenCalledWith(
expect(updateSettings).toHaveBeenCalledWith(
expect.objectContaining({
defaultDecimalFormatOptions: { defaultFormatString: newFormat },
})
Expand All @@ -110,12 +112,12 @@ describe('default decimal formatting', () => {

it('resets to default', async () => {
const user = userEvent.setup({ delay: null });
const saveSettings = jest.fn();
const updateSettings = jest.fn();
const defaultFormatOptions = {
defaultFormatString: DEFAULT_DECIMAL_STRING,
};
renderSectionContent({
saveSettings,
updateSettings,
defaultDecimalFormatOptions: {
defaultFormatString: '000',
},
Expand All @@ -131,7 +133,7 @@ describe('default decimal formatting', () => {

jest.runOnlyPendingTimers();

expect(saveSettings).toHaveBeenCalledWith(
expect(updateSettings).toHaveBeenCalledWith(
expect.objectContaining({
defaultDecimalFormatOptions: undefined,
})
Expand All @@ -150,8 +152,10 @@ describe('default integer formatting', () => {

it('updates settings when value is changed', async () => {
const user = userEvent.setup({ delay: null });
const saveSettings = jest.fn();
const { getByLabelText, unmount } = renderSectionContent({ saveSettings });
const updateSettings = jest.fn();
const { getByLabelText, unmount } = renderSectionContent({
updateSettings,
});
const newFormat = '000,000';

const input = getByLabelText('Integer');
Expand All @@ -160,7 +164,7 @@ describe('default integer formatting', () => {

jest.runOnlyPendingTimers();

expect(saveSettings).toHaveBeenCalledWith(
expect(updateSettings).toHaveBeenCalledWith(
expect.objectContaining({
defaultIntegerFormatOptions: { defaultFormatString: newFormat },
})
Expand All @@ -171,12 +175,12 @@ describe('default integer formatting', () => {

it('resets to default', async () => {
const user = userEvent.setup({ delay: null });
const saveSettings = jest.fn();
const updateSettings = jest.fn();
const defaultFormatOptions = {
defaultFormatString: DEFAULT_INTEGER_STRING,
};
renderSectionContent({
saveSettings,
updateSettings,
defaultIntegerFormatOptions: {
defaultFormatString: '000',
},
Expand All @@ -192,7 +196,7 @@ describe('default integer formatting', () => {

jest.runOnlyPendingTimers();

expect(saveSettings).toHaveBeenCalledWith(
expect(updateSettings).toHaveBeenCalledWith(
expect.objectContaining({
defaultIntegerFormatOptions: undefined,
})
Expand Down
Loading