mirror of
https://github.com/apache/superset.git
synced 2026-04-21 17:14:57 +00:00
feat(fe): upgrade superset-frontend to Typescript v5 (#31979)
Signed-off-by: hainenber <dotronghai96@gmail.com> Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
import { fireEvent, render } from 'spec/helpers/testing-library';
|
||||
import KeyboardShortcutButton, { KEY_MAP } from '.';
|
||||
import KeyboardShortcutButton, { KEY_MAP, KeyboardShortcut } from '.';
|
||||
|
||||
test('renders shortcut description', () => {
|
||||
const { getByText, getByRole } = render(
|
||||
@@ -26,7 +26,7 @@ test('renders shortcut description', () => {
|
||||
fireEvent.click(getByRole('button'));
|
||||
expect(getByText('Keyboard shortcuts')).toBeInTheDocument();
|
||||
Object.keys(KEY_MAP)
|
||||
.filter(key => Boolean(KEY_MAP[key]))
|
||||
.filter(key => Boolean(KEY_MAP[key as KeyboardShortcut]))
|
||||
.forEach(key => {
|
||||
expect(getByText(key)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@ export enum KeyboardShortcut {
|
||||
CtrlRight = 'ctrl+]',
|
||||
}
|
||||
|
||||
export const KEY_MAP = {
|
||||
export const KEY_MAP: Record<KeyboardShortcut, string | undefined> = {
|
||||
[KeyboardShortcut.CtrlR]: t('Run query'),
|
||||
[KeyboardShortcut.CtrlEnter]: t('Run query'),
|
||||
[KeyboardShortcut.AltEnter]: t('Run query'),
|
||||
@@ -62,15 +62,14 @@ export const KEY_MAP = {
|
||||
[KeyboardShortcut.CtrlH]: userOS !== 'MacOS' ? t('Replace') : undefined,
|
||||
};
|
||||
|
||||
const KeyMapByCommand = Object.entries(KEY_MAP).reduce(
|
||||
(acc, [shortcut, command]) => {
|
||||
if (command) {
|
||||
acc[command] = [...(acc[command] || []), shortcut];
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, string[]>,
|
||||
);
|
||||
const KeyMapByCommand = Object.entries(KEY_MAP).reduce<
|
||||
Record<string, string[]>
|
||||
>((acc, [shortcut, command]) => {
|
||||
if (command) {
|
||||
acc[command] = [...(acc[command] || []), shortcut];
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const ShortcutDescription = styled.span`
|
||||
font-size: ${({ theme }) => theme.typography.sizes.m}px;
|
||||
|
||||
@@ -103,7 +103,9 @@ const QueryTable = ({
|
||||
columns.map(column => ({
|
||||
accessor: column,
|
||||
Header:
|
||||
QUERY_HISTORY_TABLE_HEADERS_LOCALIZED[column] || setHeaders(column),
|
||||
QUERY_HISTORY_TABLE_HEADERS_LOCALIZED[
|
||||
column as keyof typeof QUERY_HISTORY_TABLE_HEADERS_LOCALIZED
|
||||
] || setHeaders(column),
|
||||
disableSortBy: true,
|
||||
})),
|
||||
[columns],
|
||||
@@ -221,6 +223,17 @@ const QueryTable = ({
|
||||
label: t('Unknown Status'),
|
||||
},
|
||||
},
|
||||
started: {
|
||||
config: {
|
||||
icon: (
|
||||
<Icons.LoadingOutlined
|
||||
iconColor={theme.colors.primary.base}
|
||||
iconSize="m"
|
||||
/>
|
||||
),
|
||||
label: t('Started'),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return queries
|
||||
|
||||
@@ -68,10 +68,10 @@ const getValidator = () => {
|
||||
const rules: any = getValidationRules();
|
||||
return (formData: Record<string, any>, errors: FormValidation) => {
|
||||
rules.forEach((rule: any) => {
|
||||
const test = validators[rule.name];
|
||||
const test = validators[rule.name as keyof typeof validators];
|
||||
const args = rule.arguments.map((name: string) => formData[name]);
|
||||
const container = rule.container || rule.arguments.slice(-1)[0];
|
||||
if (!test(...args)) {
|
||||
if (!test(args[0], args[1])) {
|
||||
errors[container]?.addError(rule.message);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user