Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] TS, lint updates for ui-components #25322

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions js_modules/dagster-ui/packages/ui-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@chromatic-com/storybook": "^1.6.1",
"@dagster-io/eslint-config": "1.0.15",
"@dagster-io/eslint-config": "1.0.18",
"@mdx-js/react": "^1.6.22",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^21.0.3",
Expand Down Expand Up @@ -89,7 +89,7 @@
"eslint-plugin-storybook": "^0.8.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.5.0",
"prettier": "3.0.3",
"prettier": "3.3.3",
"react": "^18.3.1",
"react-docgen-typescript-plugin": "^1.0.8",
"react-dom": "^18.3.1",
Expand All @@ -98,7 +98,7 @@
"rollup-plugin-polyfill-node": "^0.8.0",
"rollup-plugin-styles": "^4.0.0",
"storybook": "^8.2.7",
"typescript": "5.4.5",
"typescript": "5.5.4",
"webpack": "^5.94.0"
},
"browserslist": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,46 +81,42 @@ export const NewConfigEditor = forwardRef<ConfigEditorHandle, ConfigEditorProps>
props;
const editor = useRef<CodeMirror.Editor | null>(null);

useImperativeHandle(
ref,
() => {
const moveCursor = (line: number, ch: number) => {
if (!editor.current) {
return;
}
useImperativeHandle(ref, () => {
const moveCursor = (line: number, ch: number) => {
if (!editor.current) {
return;
}

editor.current.setCursor(line, ch, {scroll: false});
const {clientHeight} = editor.current.getScrollInfo();
const {left, top} = editor.current.cursorCoords(true, 'local');
const offsetFromTop = 20;

editor.current?.scrollIntoView({
left,
right: left,
top: top - offsetFromTop,
bottom: top + (clientHeight - offsetFromTop),
});
editor.current.focus();
};

editor.current.setCursor(line, ch, {scroll: false});
const {clientHeight} = editor.current.getScrollInfo();
const {left, top} = editor.current.cursorCoords(true, 'local');
const offsetFromTop = 20;

editor.current?.scrollIntoView({
left,
right: left,
top: top - offsetFromTop,
bottom: top + (clientHeight - offsetFromTop),
});
editor.current.focus();
};

const moveCursorToPath = (path: string[]) => {
if (!editor.current) {
return;
}
const codeMirrorDoc = editor.current.getDoc();
const yamlDoc = yaml.parseDocument(configCode);
const range = findRangeInDocumentFromPath(yamlDoc, path, 'key');
if (!range) {
return;
}
const from = codeMirrorDoc.posFromIndex(range ? range.start : 0) as CodeMirror.Position;
moveCursor(from.line, from.ch);
};
const moveCursorToPath = (path: string[]) => {
if (!editor.current) {
return;
}
const codeMirrorDoc = editor.current.getDoc();
const yamlDoc = yaml.parseDocument(configCode);
const range = findRangeInDocumentFromPath(yamlDoc, path, 'key');
if (!range) {
return;
}
const from = codeMirrorDoc.posFromIndex(range ? range.start : 0) as CodeMirror.Position;
moveCursor(from.line, from.ch);
};

return {moveCursor, moveCursorToPath};
},
[configCode],
);
return {moveCursor, moveCursorToPath};
}, [configCode]);

const options = useMemo(() => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const RefreshableCountdown = (props: Props) => {
{refreshing
? `Refreshing ${dataDescription}…`
: seconds === undefined
? null
: secondsToCountdownTime(seconds)}
? null
: secondsToCountdownTime(seconds)}
</span>
<Tooltip content={<span style={{whiteSpace: 'nowrap'}}>Refresh now</span>} position="top">
<RefreshButton onClick={onRefresh}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ const defineYamlMode = () => {
parentContainer === ContainerType.List
? stream.match(/^[^,\]]+/)
: parentContainer === ContainerType.Dict
? stream.match(/^[^,\}]+/)
: stream.match(/^.+$/);
? stream.match(/^[^,\}]+/)
: stream.match(/^.+$/);
}
const value = match ? match[0]! : '';
if (value.match(RegExps.VARIABLE)) {
Expand Down
Loading