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

[chore]: Remove moment package #572

Merged
merged 2 commits into from
Jan 21, 2025
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
"json2md": "^2.0.0",
"lodash": "^4.17.21",
"lz-string": "1.5.0",
"moment": "^2.29.4",
"monaco-editor": "^0.34.1",
"nprogress": "^0.2.0",
"query-string": "^7.1.1",
Expand Down
5 changes: 2 additions & 3 deletions packages/shared/lib/utils/Common.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { AxiosResponse } from 'axios';
import moment from 'moment';
import i18n from 'i18next';
import { MIMETypeEnum, ResponseBlobJsonType } from '../enum';
import { Dayjs } from 'dayjs';
import dayjs, { Dayjs } from 'dayjs';

export const emailValidate = (email: string): boolean => {
if (!email || typeof email !== 'string') {
Expand Down Expand Up @@ -47,7 +46,7 @@ export const formatTime = (
if (!timeVal) {
return defaultVal;
}
return moment(timeVal).format('YYYY-MM-DD HH:mm:ss');
return dayjs(timeVal).format('YYYY-MM-DD HH:mm:ss');
};

export function translateTimeForRequest(time: undefined): undefined;
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/lib/utils/__tests__/Common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('utils/Common', () => {
spy.mockRestore();
});

test('should format moment to YYYY-MM-DD HH:mm:ss', () => {
test('should format dayjs to YYYY-MM-DD HH:mm:ss', () => {
expect(formatTime('2021-06-09T08:11:52Z')).toBe('2021-06-09 16:11:52');
expect(formatTime('2021-06-09T08:11:52Z', '--')).toBe(
'2021-06-09 16:11:52'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ exports[`test PushRuleConfiguration/ce should match snapshot 1`] = `
<span
class="ant-descriptions-item-content"
>
0001-01-01 08:05:43
1-01-01 08:05:43
</span>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ exports[`test PushRuleConfiguration should match snapshot 1`] = `
<span
class="ant-descriptions-item-content"
>
0001-01-01 08:05:43
1-01-01 08:05:43
</span>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ exports[`test SqlManagementIssuePush should render the component and display ini
<span
class="ant-descriptions-item-content"
>
0001-01-01 08:05:43
1-01-01 08:05:43
</span>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ exports[`test WorkflowUpdateNotifier should render the component with the initia
<span
class="ant-descriptions-item-content"
>
0001-01-01 08:05:43
1-01-01 08:05:43
</span>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { Progress, Typography } from 'antd';
import { useTranslation } from 'react-i18next';
import useThemeStyleData from '../../../../../hooks/useThemeStyleData';
import { useGetLevelData } from '../../../hooks/useGetLevelData';
import moment from 'moment';
import { ClockCircleOutlined } from '@actiontech/icons';
import { formatTime } from '@actiontech/shared/lib/utils/Common';

const WorkflowTemplateAuthInfo: React.FC<WorkflowTemplateAuthInfoProps> = ({
level,
Expand Down Expand Up @@ -60,9 +60,7 @@ const WorkflowTemplateAuthInfo: React.FC<WorkflowTemplateAuthInfoProps> = ({
</Typography.Text>
<Typography.Paragraph className="auth-info-item auth-info-time">
<ClockCircleOutlined />
<span className="update-time">
{time ? moment(time).format('YYYY-MM-DD HH:mm:ss') : '-'}
</span>
<span className="update-time">{time ? formatTime(time) : '-'}</span>
</Typography.Paragraph>
</WorkflowTemplateAuthInfoStyleWrapper>
</WorkflowTemplateDetailRightContentStyleWrapper>
Expand Down
16 changes: 4 additions & 12 deletions pnpm-lock.yaml

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

Loading