Skip to content

Commit

Permalink
Merge branch 'main' into DH-18171-resize-all-columns-option-in-web-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlln committed Feb 12, 2025
2 parents fbece99 + 77c620f commit 125c58a
Show file tree
Hide file tree
Showing 267 changed files with 659 additions and 157 deletions.
25 changes: 18 additions & 7 deletions packages/chart/src/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const log = Log.module('Chart');

type ChartSettings = ColumnFormatSettings &
DateTimeFormatSettings & {
decimalFormatOptions?: DecimalColumnFormatterOptions;
integerFormatOptions?: IntegerColumnFormatterOptions;
defaultDecimalFormatOptions?: DecimalColumnFormatterOptions;
defaultIntegerFormatOptions?: IntegerColumnFormatterOptions;
webgl?: boolean;
};

Expand Down Expand Up @@ -531,6 +531,14 @@ class Chart extends Component<ChartProps, ChartState> {
this.setState({ shownBlocker: null });
break;
}
case ChartModel.EVENT_LAYOUT_UPDATED: {
const newLayout = detail as Partial<Layout>;
this.setState(({ layout, revision }) => ({
layout: { ...layout, ...newLayout },
revision: revision + 1,
}));
break;
}
default:
log.debug('Unknown event type', type, event);
}
Expand Down Expand Up @@ -651,18 +659,21 @@ class Chart extends Component<ChartProps, ChartState> {
const columnFormats = FormatterUtils.getColumnFormats(settings);
const dateTimeFormatterOptions =
FormatterUtils.getDateTimeFormatterOptions(settings);
const { decimalFormatOptions = {}, integerFormatOptions = {} } = settings;
const {
defaultDecimalFormatOptions = {},
defaultIntegerFormatOptions = {},
} = settings;

if (
!deepEqual(this.columnFormats, columnFormats) ||
!deepEqual(this.dateTimeFormatterOptions, dateTimeFormatterOptions) ||
!deepEqual(this.decimalFormatOptions, decimalFormatOptions) ||
!deepEqual(this.integerFormatOptions, integerFormatOptions)
!deepEqual(this.decimalFormatOptions, defaultDecimalFormatOptions) ||
!deepEqual(this.integerFormatOptions, defaultIntegerFormatOptions)
) {
this.columnFormats = FormatterUtils.getColumnFormats(settings);
this.dateTimeFormatterOptions = dateTimeFormatterOptions;
this.decimalFormatOptions = decimalFormatOptions;
this.integerFormatOptions = integerFormatOptions;
this.decimalFormatOptions = defaultDecimalFormatOptions;
this.integerFormatOptions = defaultIntegerFormatOptions;
this.updateFormatter();
}

Expand Down
8 changes: 8 additions & 0 deletions packages/chart/src/ChartModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class ChartModel {

static EVENT_BLOCKER_CLEAR = 'ChartModel.EVENT_BLOCKER_CLEAR';

static EVENT_LAYOUT_UPDATED = 'ChartModel.EVENT_LAYOUT_UPDATED';

constructor(dh: typeof DhType) {
this.dh = dh;
this.listeners = [];
Expand Down Expand Up @@ -205,6 +207,12 @@ class ChartModel {
fireBlockerClear(): void {
this.fireEvent(new CustomEvent(ChartModel.EVENT_BLOCKER_CLEAR));
}

fireLayoutUpdated(detail: Partial<Layout>): void {
this.fireEvent(
new CustomEvent(ChartModel.EVENT_LAYOUT_UPDATED, { detail })
);
}
}

export default ChartModel;
5 changes: 5 additions & 0 deletions packages/chart/src/ChartTheme.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@
ocean-color: var(--dh-color-chart-geo-ocean);
lake-color: var(--dh-color-chart-geo-lake);
river-color: var(--dh-color-chart-geo-river);

/* Indicator */
indicator-increasing: var(--dh-color-chart-indicator-increase);
indicator-decreasing: var(--dh-color-chart-indicator-decrease);
indicator-gauge: var(--dh-color-chart-indicator-gauge);
}
9 changes: 9 additions & 0 deletions packages/chart/src/ChartTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export interface ChartTheme {
ocean_color: string;
lake_color: string;
river_color: string;

// Indicator
indicator_increasing: string;
indicator_decreasing: string;
indicator_gauge: string;
}

export function defaultChartTheme(): Readonly<ChartTheme> {
Expand Down Expand Up @@ -65,6 +70,10 @@ export function defaultChartTheme(): Readonly<ChartTheme> {
ocean_color: chartTheme['ocean-color'],
lake_color: chartTheme['lake-color'],
river_color: chartTheme['river-color'],
// Indicator
indicator_increasing: chartTheme['indicator-increasing'],
indicator_decreasing: chartTheme['indicator-decreasing'],
indicator_gauge: chartTheme['indicator-gauge'],
});
}

Expand Down
18 changes: 18 additions & 0 deletions packages/chart/src/ChartUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
AxisType as PlotlyAxisType,
MarkerSymbol,
Template,
Delta,
} from 'plotly.js';
import { assertNotNull, bindAllMethods, type Range } from '@deephaven/utils';
import { type ChartTheme } from './ChartTheme';
Expand Down Expand Up @@ -2038,6 +2039,9 @@ class ChartUtils {
ohlc_increasing,
ohlc_decreasing,
title_color,
indicator_increasing,
indicator_decreasing,
indicator_gauge,
} = theme;

return {
Expand Down Expand Up @@ -2075,6 +2079,20 @@ class ChartUtils {
},
},
],
indicator: [
{
title: { font: { color: title_color } },
delta: {
decreasing: {
color: indicator_decreasing,
} as Delta['increasing'],
increasing: {
color: indicator_increasing,
} as Delta['decreasing'],
},
gauge: { bar: { color: indicator_gauge } },
},
],
},
/* eslint-enable camelcase */
layout: this.makeDefaultLayout(theme),
Expand Down
3 changes: 3 additions & 0 deletions packages/chart/src/__snapshots__/ChartTheme.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ exports[`defaultChartTheme should create the default chart theme 1`] = `
"colorway": "chartTheme['colorway']",
"error_band_line_color": "chartTheme['error-band-line-color']",
"gridcolor": "chartTheme['gridcolor']",
"indicator_decreasing": "chartTheme['indicator-decreasing']",
"indicator_gauge": "chartTheme['indicator-gauge']",
"indicator_increasing": "chartTheme['indicator-increasing']",
"lake_color": "chartTheme['lake-color']",
"land_color": "chartTheme['land-color']",
"legend_color": "chartTheme['legend-color']",
Expand Down
22 changes: 22 additions & 0 deletions packages/chart/src/__snapshots__/ChartUtils.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@ exports[`makeDefaultTemplate should create a default template 1`] = `
},
},
],
"indicator": [
{
"delta": {
"decreasing": {
"color": "ChartTheme['indicator_decreasing']",
},
"increasing": {
"color": "ChartTheme['indicator_increasing']",
},
},
"gauge": {
"bar": {
"color": "ChartTheme['indicator_gauge']",
},
},
"title": {
"font": {
"color": "ChartTheme['title_color']",
},
},
},
],
"ohlc": [
{
"decreasing": {
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/navigation/NavTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { NavTabItem } from './NavTabList';
import Button from '../Button';
import ContextActions from '../context-actions/ContextActions';
import { type ResolvableContextAction } from '../context-actions';
import { Tooltip } from '../popper';

interface NavTabProps {
tab: NavTabItem;
Expand Down Expand Up @@ -93,7 +94,10 @@ const NavTab = memo(
}}
>
{iconElem}
{title}
<span className="btn-nav-tab-title">
{title}
<Tooltip>{title}</Tooltip>
</span>
{isClosable && (
<Button
kind="ghost"
Expand Down
8 changes: 6 additions & 2 deletions packages/components/src/navigation/NavTabList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@ $tab-control-btn-offset: -8px;
overflow: hidden;
padding: 0 $tab-link-side-padding;
position: relative;
text-overflow: ellipsis;
user-select: none;
white-space: nowrap;
flex-shrink: 0;
background: none;
background-clip: padding-box;

.btn-nav-tab-title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.btn-nav-tab-close {
position: absolute;
height: 20px;
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/spectrum/comboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { NormalizedItem } from '../utils';
import { type PickerPropsT, usePickerProps } from '../picker';

export type ComboBoxProps = PickerPropsT<SpectrumComboBoxProps<NormalizedItem>>;
export { type MenuTriggerAction } from '@react-types/combobox';
export type { MenuTriggerAction } from '@react-types/combobox';
export { SpectrumComboBox };

export const ComboBox = React.forwardRef(function ComboBox(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@
--dh-color-chart-geo-ocean: var(--dh-color-gray-300);
--dh-color-chart-geo-lake: var(--dh-color-blue-200);
--dh-color-chart-geo-river: var(--dh-color-blue-200);

/* Indicator */
--dh-color-chart-indicator-increase: var(--dh-color-visual-green);
--dh-color-chart-indicator-decrease: var(--dh-color-visual-red);
--dh-color-chart-indicator-gauge: var(--dh-color-green-1000);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@
--dh-color-chart-geo-ocean: var(--dh-color-gray-300);
--dh-color-chart-geo-lake: var(--dh-color-blue-400);
--dh-color-chart-geo-river: var(--dh-color-blue-400);

/* Indicator */
--dh-color-chart-indicator-increase: var(--dh-color-visual-green);
--dh-color-chart-indicator-decrease: var(--dh-color-visual-red);
--dh-color-chart-indicator-gauge: var(--dh-color-green-1000);
}
80 changes: 55 additions & 25 deletions packages/console/src/monaco/MonacoProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ class MonacoProviders extends PureComponent<
d.end_location.row,
d.end_location.column
);
return diagnosticRange.intersectRanges(range);
return (
d.code != null && // Syntax errors have no code and can't be fixed/disabled
diagnosticRange.intersectRanges(range)
);
});

const fixActions: monaco.languages.CodeAction[] = diagnostics
Expand Down Expand Up @@ -296,8 +299,24 @@ class MonacoProviders extends PureComponent<
};
});

const disableActions: monaco.languages.CodeAction[] = diagnostics
const seenCodes = new Set<string>();
const duplicateCodes = new Set<string>();
diagnostics.forEach(d => {
if (d.code == null) {
return;
}
if (seenCodes.has(d.code)) {
duplicateCodes.add(d.code);
}
seenCodes.add(d.code);
});

const disableLineActions: monaco.languages.CodeAction[] = diagnostics
.map(d => {
if (d.code == null) {
// The nulls are already filtered out, but TS doesn't know that
return [];
}
const line = model.getLineContent(d.location.row);
const lastToken = monaco.editor
.tokenize(line, model.getLanguageId())[0]
Expand Down Expand Up @@ -327,7 +346,11 @@ class MonacoProviders extends PureComponent<
}
return [
{
title: `Disable ${d.code} for this line`,
title: `Disable ${d.code} for ${
duplicateCodes.has(d.code)
? `line ${d.location.row}`
: 'this line'
}`,
kind: 'quickfix',
edit: {
edits: [
Expand All @@ -339,33 +362,40 @@ class MonacoProviders extends PureComponent<
],
},
},
];
})
.flat()
.filter(
// Remove actions with duplicate titles as you can't disable the same rule on a line twice
(action, i, arr) => arr.find(a => a.title === action.title) === action
);

const disableGlobalActions: monaco.languages.CodeAction[] = [
...seenCodes,
].map(code => ({
title: `Disable ${code} for this file`,
kind: 'quickfix',
edit: {
edits: [
{
title: `Disable ${d.code} for this file`,
kind: 'quickfix',
edit: {
edits: [
{
resource: model.uri,
versionId: model.getVersionId(),
textEdit: {
range: {
startLineNumber: 1,
startColumn: 1,
endLineNumber: 1,
endColumn: 1,
},
text: `# ruff: noqa: ${d.code}\n`,
},
},
],
resource: model.uri,
versionId: model.getVersionId(),
textEdit: {
range: {
startLineNumber: 1,
startColumn: 1,
endLineNumber: 1,
endColumn: 1,
},
text: `# ruff: noqa: ${code}\n`,
},
},
];
})
.flat();
],
},
}));

return {
actions: [...fixActions, ...disableActions],
actions: [...fixActions, ...disableLineActions, ...disableGlobalActions],
dispose: () => {
/* no-op */
},
Expand Down
2 changes: 1 addition & 1 deletion packages/golden-layout/src/controls/DragProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default class DragProxy extends EventEmitter {
'title',
stripTags(this._contentItem.config.title ?? '')
);
this.element.find('.lm_title').html(this._contentItem.config.title ?? '');
this.element.find('.lm_title').text(this._contentItem.config.title ?? '');
this.childElementContainer = this.element.find('.lm_content');
this.childElementContainer.append(contentItem.element);

Expand Down
2 changes: 1 addition & 1 deletion packages/golden-layout/src/controls/Tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class Tab {
setTitle(title = '') {
// Disabling for illumon project, we want to manage our own tooltips
// this.element.attr( 'title', lm.utils.stripTags( title ) );
this.titleElement.html(title);
this.titleElement.text(title);
}

/**
Expand Down
Loading

0 comments on commit 125c58a

Please sign in to comment.