Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
59 changes: 45 additions & 14 deletions packages/code-studio/src/settings/ColumnSpecificSectionContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ interface ColumnSpecificSectionContentState {
showTimeZone: boolean;
showTSeparator: boolean;
timeZone: string;
defaultDateTimeFormat: string;
defaultDecimalFormatOptions: FormatOption;
defaultIntegerFormatOptions: FormatOption;
truncateNumbersWithPound: boolean;
timestampAtMenuOpen: Date;
}
Expand Down Expand Up @@ -116,9 +113,6 @@ export class ColumnSpecificSectionContent extends PureComponent<

const {
formatter,
defaultDateTimeFormat,
defaultDecimalFormatOptions,
defaultIntegerFormatOptions,
showTimeZone,
showTSeparator,
timeZone,
Expand All @@ -141,9 +135,6 @@ export class ColumnSpecificSectionContent extends PureComponent<
showTimeZone,
showTSeparator,
timeZone,
defaultDateTimeFormat,
defaultDecimalFormatOptions,
defaultIntegerFormatOptions,
truncateNumbersWithPound,
timestampAtMenuOpen: new Date(),
};
Expand Down Expand Up @@ -284,14 +275,18 @@ export class ColumnSpecificSectionContent extends PureComponent<
commitChanges(): void {
const {
formatSettings,
defaultDateTimeFormat,
showTimeZone,
showTSeparator,
timeZone,
defaultDecimalFormatOptions,
defaultIntegerFormatOptions,
truncateNumbersWithPound,
} = this.state;

const {
defaultDateTimeFormat,
defaultDecimalFormatOptions,
defaultIntegerFormatOptions,
} = this.props;

const { dh } = this.props;

const formatter =
Expand Down Expand Up @@ -511,6 +506,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
isInvalid: boolean
): ReactElement {
const { showTimeZone, showTSeparator, timeZone } = this.state;

const value = format.formatString ?? '';
return (
<select
Expand Down Expand Up @@ -544,6 +540,8 @@ export class ColumnSpecificSectionContent extends PureComponent<
format: Partial<TableColumnFormat>,
isInvalid: boolean
): ReactElement {
const { defaultIntegerFormatOptions } = this.props;
const { defaultFormatString } = defaultIntegerFormatOptions;
const value = format.formatString ?? '';
return (
<input
Expand All @@ -552,7 +550,22 @@ export class ColumnSpecificSectionContent extends PureComponent<
})}
data-lpignore
id={formatId}
placeholder={IntegerColumnFormatter.DEFAULT_FORMAT_STRING}
placeholder={
defaultFormatString ?? IntegerColumnFormatter.DEFAULT_FORMAT_STRING
}
onKeyDown={e => {
if (e.key === 'Enter' && value === '') {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I like this - it's kind of hidden functionality that is difficult for the user to find. Granted, I don't know a better way to start with the default/edit it, other than copying pasting from above.
@dsmmcken Do you have any ideas for creating a new rule based off the default but edited slightly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just set it to the initial value instead of a placeholder.

e.preventDefault();
const selectedFormat = IntegerColumnFormatter.makeFormat(
'',
defaultFormatString ??
IntegerColumnFormatter.DEFAULT_FORMAT_STRING,
IntegerColumnFormatter.TYPE_GLOBAL,
undefined
);
this.handleFormatRuleChange(i, 'format', selectedFormat);
}
}}
type="text"
value={value}
onChange={e => {
Expand All @@ -574,6 +587,9 @@ export class ColumnSpecificSectionContent extends PureComponent<
format: Partial<TableColumnFormat>,
isInvalid: boolean
): ReactElement {
const { defaultDecimalFormatOptions } = this.props;
const { defaultFormatString } = defaultDecimalFormatOptions;

const value = format.formatString ?? '';
return (
<input
Expand All @@ -582,7 +598,22 @@ export class ColumnSpecificSectionContent extends PureComponent<
})}
data-lpignore
id={formatId}
placeholder={DecimalColumnFormatter.DEFAULT_FORMAT_STRING}
placeholder={
defaultFormatString ?? DecimalColumnFormatter.DEFAULT_FORMAT_STRING
}
onKeyDown={e => {
if (e.key === 'Enter' && value === '') {
e.preventDefault();
const selectedFormat = DecimalColumnFormatter.makeFormat(
'',
defaultFormatString ??
DecimalColumnFormatter.DEFAULT_FORMAT_STRING,
DecimalColumnFormatter.TYPE_GLOBAL,
undefined
);
this.handleFormatRuleChange(i, 'format', selectedFormat);
}
}}
type="text"
value={value}
onChange={e => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ export class FormattingSectionContent extends PureComponent<
checked={truncateNumbersWithPound ?? null}
onChange={this.handleTruncateNumbersWithPoundChange}
>
Truncate numbers with #
Show truncated numbers as ###
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A contextual help bubble could be useful here... I think the phrase "Mask truncated numbers with ###" may be better as well, @dsmmcken any opinion?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fine with this suggestion. Using the word show is more consistent wit the other labels, like "Show T seperator", and I like the multiple hashtags in the label. It's a bit long now is my only complaint.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about Show truncation as ###

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only applies to numbers though

</Checkbox>
</div>
</div>
Expand Down
7 changes: 6 additions & 1 deletion packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ module.exports = {
'react-refresh',
],
rules: {
'prettier/prettier': ['error'],
'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be changing the endOfLine default, we want to keep it to lf instead of crlf. Might need to configure something on Windows so that line endings are handled correctly in git.

],
'react/forbid-prop-types': 'off',
'react/jsx-curly-newline': 'off',
'react/jsx-uses-react': 'error',
Expand Down