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

refactor(date picker): Migrate Date Picker to Ant Design 5 #31019

Merged
merged 47 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2b1950a
refactor(date picker): initial commit
msyavuz Nov 19, 2024
ba7a325
refactor(moment): Replace Moment.js with DayJs
msyavuz Dec 5, 2024
ded1285
fix(package): sync package.json and tests
msyavuz Dec 6, 2024
63d7c02
refactor(moment): refactor moment out of components
msyavuz Dec 16, 2024
17d0041
refactor(dayjs): re-add moment and migrate components
msyavuz Dec 17, 2024
8eb99d3
refactor(dayjs): migrate some components
msyavuz Dec 17, 2024
f556d9c
chore(moment): add comment and change moment to dayjs
msyavuz Dec 17, 2024
8572277
refactor(dayjs): centralize dayjs extensions
msyavuz Dec 17, 2024
fd2f451
chore(dayjs): add test for extensions and change package.jsons
msyavuz Dec 17, 2024
4a55d06
fix(type): type from dayjs instead
msyavuz Dec 17, 2024
9c8eca1
Merge branch 'master' into msyavuz/momentjs-to-dayjs
msyavuz Dec 17, 2024
6cbac28
fix(test): only wait for load if its loading
msyavuz Dec 18, 2024
e9fcacd
test(AlertReportModal): use events directly instead?
msyavuz Dec 18, 2024
a035c87
test(AlertReportModal): fix the test
msyavuz Dec 18, 2024
af97ee0
refactor(pluigin-echarts): move to dayjs
msyavuz Dec 18, 2024
5a0862a
chore: remove unused waitfor
msyavuz Dec 18, 2024
a3e10bf
feat(moment): remove timezone-support, migrate handlebars to dayjs
msyavuz Dec 18, 2024
638599f
chore(timezone-support): remove usages
msyavuz Dec 18, 2024
854a66a
refactor(legacy-plugins): migrate to dayjs
msyavuz Dec 18, 2024
972bf08
fix(timezoneselector): use map instead of array and remove unneccessa…
msyavuz Dec 19, 2024
58a7355
refactor(alert report modal): remove loading check
msyavuz Dec 19, 2024
f60a221
chore(alert report modal): remove unused import
msyavuz Dec 19, 2024
568b4f5
Merge branch 'msyavuz/refactor/migrate-datepicker' of https://github.…
msyavuz Dec 20, 2024
962ad20
chore(package): remove package manager
msyavuz Dec 20, 2024
4fee444
feat(DatePicker): migrate to dayjs and fix some usages
msyavuz Dec 20, 2024
554b4f2
Merge branch 'master' into msyavuz/refactor/migrate-datepicker
msyavuz Dec 23, 2024
0a49f2f
chore(package): remove moment related stuff
msyavuz Dec 23, 2024
97f88be
chore(webpack): remove unused functions
msyavuz Dec 23, 2024
5aa5581
chore(moment): readd moment-plugin for peer deps
msyavuz Dec 23, 2024
c1c5cb5
Update superset-frontend/packages/superset-ui-chart-controls/src/cons…
msyavuz Dec 30, 2024
85f4664
fix(days): import and include locales dynamically
msyavuz Dec 31, 2024
9c0cb0c
Merge branch 'master' into msyavuz/refactor/migrate-datepicker
msyavuz Dec 31, 2024
056dc14
chore(datepicker): cleanup
msyavuz Jan 1, 2025
8710a60
fix(webpack): change plugin for build errors
msyavuz Jan 1, 2025
79925f3
chore(timezones): remove deduping logic
msyavuz Jan 8, 2025
b3d0a24
chore(moment): remove moment locales plugin
msyavuz Jan 8, 2025
4939091
Merge branch 'master' into msyavuz/refactor/migrate-datepicker
msyavuz Jan 8, 2025
3de0a5d
refactor(invalid date): turn to sentence case
msyavuz Jan 8, 2025
5835167
test(TimezoneSelector): change test for all timezones
msyavuz Jan 8, 2025
ace0177
fix(TimezoneSelector): change tests for all timezones
msyavuz Jan 8, 2025
5b22577
feat(useLocale): add useLocale hook to unify locale
msyavuz Jan 9, 2025
f5a699d
test(ListView): provide store
msyavuz Jan 9, 2025
32f2d46
chore(webpack): remove unused function
msyavuz Jan 9, 2025
246ad4d
feat(webpack): add ignore plugin
msyavuz Jan 10, 2025
407a819
fix(webpack): import dayjs locales directly instead of webpack plugin
msyavuz Jan 10, 2025
c6b6aab
Update superset-frontend/src/components/TimezoneSelector/index.tsx
geido Jan 13, 2025
ddb7af8
chore(format): remove line
msyavuz Jan 13, 2025
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
151 changes: 55 additions & 96 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@
"markdown-to-jsx": "^7.4.7",
"match-sorter": "^6.3.4",
"memoize-one": "^5.2.1",
"moment": "^2.30.1",
"moment-timezone": "^0.5.44",
"mousetrap": "^1.6.5",
"mustache": "^4.2.0",
"nanoid": "^5.0.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ export const DEFAULT_XAXIS_SORT_SERIES_DATA: SortSeriesData = {

export const DEFAULT_DATE_PATTERN = /\d{4}-\d{2}-\d{2}/g;

// When moment fails to parse a date
export const INVALID_DATE = 'Invalid date';
// When it fails to parse a date
export const INVALID_DATE = 'Invalid Date';
msyavuz marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 10 additions & 2 deletions superset-frontend/src/components/AntdThemeProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@
import { ConfigProvider, type ConfigProviderProps } from 'antd-v5';
import { getTheme, ThemeType } from 'src/theme/index';

export const AntdThemeProvider = ({ theme, children }: ConfigProviderProps) => (
<ConfigProvider theme={theme || getTheme(ThemeType.LIGHT)} prefixCls="antd5">
export const AntdThemeProvider = ({
theme,
children,
...rest
}: ConfigProviderProps) => (
<ConfigProvider
theme={theme || getTheme(ThemeType.LIGHT)}
prefixCls="antd5"
{...rest}
>
{children}
</ConfigProvider>
);
38 changes: 30 additions & 8 deletions superset-frontend/src/components/DatePicker/DatePicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,26 @@
* specific language governing permissions and limitations
* under the License.
*/
import { DatePickerProps, RangePickerProps } from 'antd/lib/date-picker';
import { DatePickerProps } from 'antd-v5';
import { RangePickerProps } from 'antd-v5/es/date-picker';
import { DatePicker, RangePicker } from '.';

export default {
title: 'DatePicker',
component: DatePicker,
};

const commonArgs = {
allowClear: true,
const commonArgs: DatePickerProps = {
allowClear: false,
autoFocus: true,
bordered: true,
disabled: false,
format: 'YYYY-MM-DD hh:mm a',
Copy link

Choose a reason for hiding this comment

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

Incompatible Date-Time Format category Functionality

Tell me more
What is the issue?

The date-time format 'YYYY-MM-DD hh:mm a' is a moment.js format. Dayjs requires 'YYYY-MM-DD HH:mm A'.

Why this matters

Using moment.js date-time format with dayjs will result in incorrect date and time formatting in the UI.

Suggested change

Change the format to 'YYYY-MM-DD HH:mm A' to match dayjs formatting requirements.

Chat with Korbit by mentioning @korbit-ai, and give a 👍 or 👎 to help Korbit improve your reviews.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"YYYY-MM-DD-hh:mm a" is a valid dayjs format.
https://day.js.org/docs/en/display/format

inputReadOnly: false,
order: true,
picker: 'date',
placement: 'bottomLeft',
size: 'middle',
format: 'YYYY-MM-DD hh:mm a',
showNow: true,
showTime: { format: 'hh:mm a' },
};

Expand All @@ -49,6 +53,25 @@ const interactiveTypes = {
},
options: ['large', 'middle', 'small'],
},
placement: {
control: {
type: 'select',
},
options: ['bottomLeft', 'bottomRight', 'topLeft', 'topRight'],
},
status: {
control: {
type: 'select',
},
options: ['error', 'warning'],
},

variant: {
control: {
type: 'select',
},
options: ['outlined', 'borderless', 'filled'],
},
};

export const InteractiveDatePicker = (args: DatePickerProps) => (
Expand All @@ -57,9 +80,9 @@ export const InteractiveDatePicker = (args: DatePickerProps) => (

InteractiveDatePicker.args = {
...commonArgs,
picker: 'date',
placeholder: 'Placeholder',
showToday: true,
showTime: { format: 'hh:mm a', needConfirm: false },
};

InteractiveDatePicker.argTypes = interactiveTypes;
Expand All @@ -70,9 +93,8 @@ export const InteractiveRangePicker = (args: RangePickerProps) => (

InteractiveRangePicker.args = {
...commonArgs,
allowEmpty: true,
showNow: true,
separator: '-',
showTime: { format: 'hh:mm a', needConfirm: false },
};

InteractiveRangePicker.argTypes = interactiveTypes;
31 changes: 31 additions & 0 deletions superset-frontend/src/components/DatePicker/DatePicker.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { render } from 'spec/helpers/testing-library';
import { DatePicker, RangePicker } from '.';

test('should render date picker', () => {
const { container } = render(<DatePicker />);
expect(container).toBeInTheDocument();
});

test('should render range picker', () => {
const { container } = render(<RangePicker />);
expect(container).toBeInTheDocument();
});
Loading
Loading