mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 22:25:57 +08:00
fix: [FE-3128]: Logs Explorer: Show options based on format type selected (#3333)
* fix: [FE-3128]: Logs Explorer: Show options based on format type selected * fix: build is fixed --------- Co-authored-by: Palash Gupta <palashgdev@gmail.com>
This commit is contained in:
parent
2aef4578b0
commit
4d5ee861ec
5
frontend/src/constants/optionsFormatTypes.ts
Normal file
5
frontend/src/constants/optionsFormatTypes.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export enum OptionFormatTypes {
|
||||||
|
RAW = 'raw',
|
||||||
|
LIST = 'list',
|
||||||
|
TABLE = 'table',
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
import { OptionsMenuConfig } from 'container/OptionsMenu/types';
|
import { OptionsMenuConfig } from 'container/OptionsMenu/types';
|
||||||
|
|
||||||
export type ExplorerControlPanelProps = {
|
export type ExplorerControlPanelProps = {
|
||||||
|
selectedOptionFormat: string;
|
||||||
isShowPageSize: boolean;
|
isShowPageSize: boolean;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
optionsMenuConfig?: OptionsMenuConfig;
|
optionsMenuConfig?: OptionsMenuConfig;
|
||||||
|
@ -6,6 +6,7 @@ import { ExplorerControlPanelProps } from './ExplorerControlPanel.interfaces';
|
|||||||
import { ContainerStyled } from './styles';
|
import { ContainerStyled } from './styles';
|
||||||
|
|
||||||
function ExplorerControlPanel({
|
function ExplorerControlPanel({
|
||||||
|
selectedOptionFormat,
|
||||||
isLoading,
|
isLoading,
|
||||||
isShowPageSize,
|
isShowPageSize,
|
||||||
optionsMenuConfig,
|
optionsMenuConfig,
|
||||||
@ -15,7 +16,10 @@ function ExplorerControlPanel({
|
|||||||
<Row justify="end" gutter={30}>
|
<Row justify="end" gutter={30}>
|
||||||
{optionsMenuConfig && (
|
{optionsMenuConfig && (
|
||||||
<Col>
|
<Col>
|
||||||
<OptionsMenu config={optionsMenuConfig} />
|
<OptionsMenu
|
||||||
|
selectedOptionFormat={selectedOptionFormat}
|
||||||
|
config={optionsMenuConfig}
|
||||||
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
)}
|
)}
|
||||||
<Col>
|
<Col>
|
||||||
|
@ -141,6 +141,7 @@ function LogsExplorerList({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ExplorerControlPanel
|
<ExplorerControlPanel
|
||||||
|
selectedOptionFormat={options.format}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
isShowPageSize={false}
|
isShowPageSize={false}
|
||||||
optionsMenuConfig={config}
|
optionsMenuConfig={config}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { SettingFilled, SettingOutlined } from '@ant-design/icons';
|
import { SettingFilled, SettingOutlined } from '@ant-design/icons';
|
||||||
import { Popover, Space } from 'antd';
|
import { Popover, Space } from 'antd';
|
||||||
|
import { OptionFormatTypes } from 'constants/optionsFormatTypes';
|
||||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
@ -12,10 +13,14 @@ import { OptionsMenuConfig } from './types';
|
|||||||
import useOptionsMenu from './useOptionsMenu';
|
import useOptionsMenu from './useOptionsMenu';
|
||||||
|
|
||||||
interface OptionsMenuProps {
|
interface OptionsMenuProps {
|
||||||
|
selectedOptionFormat?: string;
|
||||||
config: OptionsMenuConfig;
|
config: OptionsMenuConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
function OptionsMenu({ config }: OptionsMenuProps): JSX.Element {
|
function OptionsMenu({
|
||||||
|
selectedOptionFormat,
|
||||||
|
config,
|
||||||
|
}: OptionsMenuProps): JSX.Element {
|
||||||
const { t } = useTranslation(['trace']);
|
const { t } = useTranslation(['trace']);
|
||||||
const isDarkMode = useIsDarkMode();
|
const isDarkMode = useIsDarkMode();
|
||||||
|
|
||||||
@ -23,11 +28,15 @@ function OptionsMenu({ config }: OptionsMenuProps): JSX.Element {
|
|||||||
() => (
|
() => (
|
||||||
<OptionsContentWrapper direction="vertical">
|
<OptionsContentWrapper direction="vertical">
|
||||||
{config?.format && <FormatField config={config.format} />}
|
{config?.format && <FormatField config={config.format} />}
|
||||||
{config?.maxLines && <MaxLinesField config={config.maxLines} />}
|
{selectedOptionFormat === OptionFormatTypes.RAW && config?.maxLines && (
|
||||||
{config?.addColumn && <AddColumnField config={config.addColumn} />}
|
<MaxLinesField config={config.maxLines} />
|
||||||
|
)}
|
||||||
|
{(selectedOptionFormat === OptionFormatTypes.LIST ||
|
||||||
|
selectedOptionFormat === OptionFormatTypes.TABLE) &&
|
||||||
|
config?.addColumn && <AddColumnField config={config.addColumn} />}
|
||||||
</OptionsContentWrapper>
|
</OptionsContentWrapper>
|
||||||
),
|
),
|
||||||
[config],
|
[config, selectedOptionFormat],
|
||||||
);
|
);
|
||||||
|
|
||||||
const SettingIcon = isDarkMode ? SettingOutlined : SettingFilled;
|
const SettingIcon = isDarkMode ? SettingOutlined : SettingFilled;
|
||||||
@ -46,4 +55,8 @@ function OptionsMenu({ config }: OptionsMenuProps): JSX.Element {
|
|||||||
|
|
||||||
export default OptionsMenu;
|
export default OptionsMenu;
|
||||||
|
|
||||||
|
OptionsMenu.defaultProps = {
|
||||||
|
selectedOptionFormat: 'raw',
|
||||||
|
};
|
||||||
|
|
||||||
export { useOptionsMenu };
|
export { useOptionsMenu };
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { OptionFormatTypes } from 'constants/optionsFormatTypes';
|
||||||
import Controls, { ControlsProps } from 'container/Controls';
|
import Controls, { ControlsProps } from 'container/Controls';
|
||||||
import OptionsMenu from 'container/OptionsMenu';
|
import OptionsMenu from 'container/OptionsMenu';
|
||||||
import { OptionsMenuConfig } from 'container/OptionsMenu/types';
|
import { OptionsMenuConfig } from 'container/OptionsMenu/types';
|
||||||
@ -21,7 +22,12 @@ function TraceExplorerControls({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
{config && <OptionsMenu config={{ addColumn: config?.addColumn }} />}
|
{config && (
|
||||||
|
<OptionsMenu
|
||||||
|
selectedOptionFormat={OptionFormatTypes.LIST} // Defaulting it to List view as options are shown only in the List view tab
|
||||||
|
config={{ addColumn: config?.addColumn }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<Controls
|
<Controls
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user