-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from quickwit-oss/ddelemeny/log-end-selector
Improve log limits UX : select log end & raised limit
- Loading branch information
Showing
10 changed files
with
124 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/LogsSettingsEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { css } from "@emotion/css"; | ||
import { RadioButtonGroup } from "@grafana/ui"; | ||
import React from "react"; | ||
import { Logs, LogsSortDirection, LogsEnd } from "types"; | ||
import { SettingField } from "./SettingField"; | ||
import { useDispatch } from "hooks/useStatelessReducer"; | ||
import { changeMetricSetting } from '../state/actions'; | ||
import { metricAggregationConfig } from "../utils"; | ||
|
||
|
||
// type LogsSortDirection = 'asc' | 'desc' | ||
|
||
interface Props { metric: Logs } | ||
|
||
export const LogsSettingsEditor = ({metric}: Props)=>{ | ||
const config = metricAggregationConfig['logs'] | ||
const dispatch = useDispatch(); | ||
return ( | ||
<div className={css({display:"inline-flex", justifyContent:"start", gap:"4px", height:"100%"})} > | ||
<RadioButtonGroup | ||
className={css({height:"100%"})} | ||
options={Object.values(LogsSortDirection).map((v)=>({label:LogsEnd[v], value:v}))} | ||
value={metric.settings?.sortDirection || config.defaults.settings?.sortDirection } | ||
onChange={(v)=>{ dispatch( | ||
changeMetricSetting({ metric, settingName: 'sortDirection', newValue: v }) | ||
)}}/> | ||
<SettingField label="Limit" metric={metric} settingName="limit" placeholder={config.defaults.settings?.limit} /> | ||
</div> | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,79 @@ | ||
import { css } from '@emotion/css'; | ||
import { noop } from 'lodash'; | ||
import React, { PropsWithChildren } from 'react'; | ||
import React, { PropsWithChildren, ReactNode } from 'react'; | ||
|
||
import { GrafanaTheme2 } from '@grafana/data'; | ||
import { IconButton, InlineFieldRow, InlineLabel, InlineSegmentGroup, useStyles2 } from '@grafana/ui'; | ||
|
||
interface Props { | ||
label: string; | ||
const getStyles = (theme: GrafanaTheme2) => { | ||
return { | ||
iconWrapper: css` | ||
display: flex; | ||
`, | ||
icon: css` | ||
color: ${theme.colors.text.secondary}; | ||
margin-left: ${theme.spacing(0.25)}; | ||
`, | ||
}; | ||
}; | ||
|
||
interface BaseRowProps { label: ReactNode; }; | ||
export const QueryEditorBaseRow = ({ label, children }: PropsWithChildren<BaseRowProps>) => { | ||
return ( | ||
<InlineFieldRow> | ||
<InlineSegmentGroup> | ||
<InlineLabel width={17} as="div"> | ||
{label} | ||
</InlineLabel> | ||
</InlineSegmentGroup> | ||
{children} | ||
</InlineFieldRow> | ||
); | ||
}; | ||
|
||
interface RowProps extends BaseRowProps { | ||
onRemoveClick?: false | (() => void); | ||
onHideClick?: false | (() => void); | ||
hidden?: boolean; | ||
} | ||
|
||
export const QueryEditorRow = ({ | ||
children, | ||
label, | ||
onRemoveClick, | ||
onHideClick, | ||
hidden = false, | ||
}: PropsWithChildren<Props>) => { | ||
}: PropsWithChildren<RowProps>) => { | ||
const styles = useStyles2(getStyles); | ||
|
||
return ( | ||
<InlineFieldRow> | ||
<InlineSegmentGroup> | ||
<InlineLabel width={17} as="div"> | ||
<span>{label}</span> | ||
<span className={styles.iconWrapper}> | ||
{onHideClick && ( | ||
<IconButton | ||
name={hidden ? 'eye-slash' : 'eye'} | ||
onClick={onHideClick} | ||
size="sm" | ||
aria-pressed={hidden} | ||
aria-label="hide metric" | ||
className={styles.icon} | ||
type="button" | ||
/> | ||
)} | ||
<QueryEditorBaseRow label={(<> | ||
<span>{label}</span> | ||
<span className={styles.iconWrapper}> | ||
{onHideClick && ( | ||
<IconButton | ||
name="trash-alt" | ||
name={hidden ? 'eye-slash' : 'eye'} | ||
onClick={onHideClick} | ||
size="sm" | ||
aria-pressed={hidden} | ||
aria-label="hide metric" | ||
className={styles.icon} | ||
onClick={onRemoveClick || noop} | ||
disabled={!onRemoveClick} | ||
aria-label="remove metric" | ||
type="button" | ||
/> | ||
</span> | ||
</InlineLabel> | ||
</InlineSegmentGroup> | ||
)} | ||
<IconButton | ||
name="trash-alt" | ||
size="sm" | ||
className={styles.icon} | ||
onClick={onRemoveClick || noop} | ||
disabled={!onRemoveClick} | ||
aria-label="remove metric" | ||
type="button" | ||
/> | ||
</span> | ||
</>)}> | ||
{children} | ||
</InlineFieldRow> | ||
</QueryEditorBaseRow> | ||
); | ||
}; | ||
|
||
const getStyles = (theme: GrafanaTheme2) => { | ||
return { | ||
iconWrapper: css` | ||
display: flex; | ||
`, | ||
icon: css` | ||
color: ${theme.colors.text.secondary}; | ||
margin-left: ${theme.spacing(0.25)}; | ||
`, | ||
}; | ||
}; | ||
|
30 changes: 0 additions & 30 deletions
30
src/components/QueryEditor/QueryEditorSpecialMetricRow.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters