mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-27 02:16:18 +00:00
Fix(UI): Updated labels for add and edit announcement modals (#6988)
* announcement add and edit modal label updated * Added feature to see the local time zone while creating or editing announcement * fixed failing unit tests * improved the function to get time zone
This commit is contained in:
parent
b59878e1b5
commit
f0560d121f
@ -42,6 +42,7 @@ jest.mock('../../../utils/EntityUtils', () => ({
|
||||
|
||||
jest.mock('../../../utils/TimeUtils', () => ({
|
||||
getUTCDateTime: jest.fn(),
|
||||
getTimeZone: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../../utils/ToastUtils', () => ({
|
||||
|
@ -26,7 +26,7 @@ import {
|
||||
validateMessages,
|
||||
} from '../../../utils/AnnouncementsUtils';
|
||||
import { getEntityFeedLink } from '../../../utils/EntityUtils';
|
||||
import { getUTCDateTime } from '../../../utils/TimeUtils';
|
||||
import { getTimeZone, getUTCDateTime } from '../../../utils/TimeUtils';
|
||||
import { showErrorToast, showSuccessToast } from '../../../utils/ToastUtils';
|
||||
import RichTextEditor from '../../common/rich-text-editor/RichTextEditor';
|
||||
import './AnnouncementModal.less';
|
||||
@ -130,7 +130,7 @@ const AddAnnouncementModal: FC<Props> = ({
|
||||
</Form.Item>
|
||||
<Space className="announcement-date-space" size={16}>
|
||||
<Form.Item
|
||||
label="Start Date (UTC):"
|
||||
label={`Start Date: (${getTimeZone()})`}
|
||||
name="startDate"
|
||||
rules={[
|
||||
{
|
||||
@ -144,7 +144,7 @@ const AddAnnouncementModal: FC<Props> = ({
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="End Date (UTC):"
|
||||
label={`End Date: (${getTimeZone()})`}
|
||||
name="endtDate"
|
||||
rules={[
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ jest.mock('../../../utils/EntityUtils', () => ({
|
||||
jest.mock('../../../utils/TimeUtils', () => ({
|
||||
getUTCDateTime: jest.fn(),
|
||||
getLocaleDate: jest.fn(),
|
||||
getTimeZone: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('../../common/rich-text-editor/RichTextEditor', () => {
|
||||
|
@ -19,7 +19,11 @@ import {
|
||||
announcementInvalidStartTime,
|
||||
validateMessages,
|
||||
} from '../../../utils/AnnouncementsUtils';
|
||||
import { getLocaleDate, getUTCDateTime } from '../../../utils/TimeUtils';
|
||||
import {
|
||||
getLocaleDate,
|
||||
getTimeZone,
|
||||
getUTCDateTime,
|
||||
} from '../../../utils/TimeUtils';
|
||||
import { showErrorToast } from '../../../utils/ToastUtils';
|
||||
import RichTextEditor from '../../common/rich-text-editor/RichTextEditor';
|
||||
import './AnnouncementModal.less';
|
||||
@ -108,7 +112,7 @@ const EditAnnouncementModal: FC<Props> = ({
|
||||
</Form.Item>
|
||||
<Space className="announcement-date-space" size={16}>
|
||||
<Form.Item
|
||||
label="Start Date (UTC):"
|
||||
label={`Start Date: (${getTimeZone()})`}
|
||||
name="startDate"
|
||||
rules={[
|
||||
{
|
||||
@ -122,7 +126,7 @@ const EditAnnouncementModal: FC<Props> = ({
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label="End Date (UTC):"
|
||||
label={`End Date: (${getTimeZone()})`}
|
||||
name="endDate"
|
||||
rules={[
|
||||
{
|
||||
|
@ -128,3 +128,19 @@ export const getDateTimeByTimeStamp = (timeStamp: number): string => {
|
||||
export const getLocaleDate = (timeStamp: number): string => {
|
||||
return moment(timeStamp, 'x').format('yyyy-MM-DDThh:mm');
|
||||
};
|
||||
|
||||
export const getTimeZone = (): string => {
|
||||
// Getting local time zone
|
||||
const timeZoneToString = new Date()
|
||||
.toLocaleDateString('en-US', {
|
||||
day: '2-digit',
|
||||
timeZoneName: 'long',
|
||||
})
|
||||
.slice(4);
|
||||
|
||||
// Line below finds out the abbrevation for time zone
|
||||
// e.g. India Standard Time --> IST
|
||||
const abbreviation = timeZoneToString.match(/\b[A-Z]+/g)?.join('') || '';
|
||||
|
||||
return abbreviation;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user