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

[bug]: fix time zone cannot select #114

Merged
merged 1 commit into from
Aug 14, 2023
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
74 changes: 40 additions & 34 deletions web/src/features/setting/datasource/EditDataSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ specific language governing permissions and limitations
under the License.
*/
import React, { useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
import { isEmpty, get } from 'lodash-es';
import { isEmpty, get, filter } from 'lodash-es';
import { Button, Select, Card, Typography, Form, Space, Tag } from '@douyinfe/semi-ui';
import { IconSaveStroked } from '@douyinfe/semi-icons';
import { DatasourceSrv } from '@src/services';
Expand All @@ -33,6 +33,44 @@ import './datasource.scss';

const { Text, Title } = Typography;

const TimeZoneSelect: React.FC = () => {
const [timeZones, setTimeZones] = useState<string[]>(moment.tz.names());
return (
<Form.Select
field="timeZone"
label="Time zone"
style={{ width: '100%' }}
filter
onSearch={(v: string) => {
const search = v.toLowerCase();
setTimeZones(
filter(moment.tz.names(), (tz: string) => {
return tz.toLowerCase().indexOf(search) >= 0;
})
);
}}
renderSelectedItem={(n: Record<string, any>) => {
if (isEmpty(n.value)) {
return null;
}
return (
<div style={{ display: 'flex', gap: 4 }}>
<Text>{n.value}</Text>
<Tag>{TimeKit.utcOffset(n.value)}</Tag>
</div>
);
}}>
{timeZones.map((tz: string) => {
return (
<Select.Option key={tz} value={tz} showTick={false} className="time-zone-select">
<Text className="time-zone-name">{tz}</Text>
<Tag>{TimeKit.utcOffset(tz)}</Tag>
</Select.Option>
);
})}
</Form.Select>
);
};
const DatasourceSettingForm: React.FC<{
formApi: any;
datasource?: DatasourceSetting;
Expand Down Expand Up @@ -85,7 +123,6 @@ const EditDataSource: React.FC = () => {
const gotoDatasourceList = () => {
navigate({ pathname: '/setting/datasources' });
};

return (
<Card
loading={!isEmpty(uid) && loading}
Expand Down Expand Up @@ -141,38 +178,7 @@ const EditDataSource: React.FC = () => {
}}>
<Form.Input field="name" label="Name" rules={[{ required: true, message: 'Name is required' }]} />
<Form.Switch field="isDefault" label="Default" />
<Form.Select
field="timeZone"
label="Time zone"
style={{ width: '100%' }}
filter
optionList={moment.tz.names().map((n: string) => {
return { label: n, value: n, showTick: true };
})}
onChange={(value: any): void => {
console.error('kkkk', value);
}}
renderOptionItem={(props: any) => {
const { value, onClick } = props;
return (
<Select.Option value={value} showTick={false} className="time-zone-select" onClick={() => onClick()}>
<Text className="time-zone-name">{value}</Text>
<Tag>{TimeKit.utcOffset(value)}</Tag>
</Select.Option>
);
}}
renderSelectedItem={(n: Record<string, any>) => {
if (isEmpty(n.value)) {
return null;
}
return (
<div style={{ display: 'flex', gap: 4 }}>
<Text>{n.value}</Text>
<Tag>{TimeKit.utcOffset(n.value)}</Tag>
</div>
);
}}
/>
<TimeZoneSelect />
<Form.Select
label="Type"
field="type"
Expand Down
3 changes: 1 addition & 2 deletions web/src/features/trace/TraceView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ under the License.
*/
import { Button, Dropdown, Layout } from '@douyinfe/semi-ui';
import { IconInheritStroked, IconDescend, IconFlowChartStroked, IconPieChart2Stroked } from '@douyinfe/semi-icons';
import { useRequest, useTrace } from '@src/hooks';
import { DataQuerySrv } from '@src/services';
import { useTrace } from '@src/hooks';
import React, { useState } from 'react';
import TimelineView from './timeline/TimelineView';
import { Trace } from '@src/types';
Expand Down