Explore: Unified Logs Volume and Logs panels (#73825)

Wrap Logs Volume and Logs panels with PanelChrome instead of Collapse
This commit is contained in:
Haris Rozajac
2023-08-30 12:20:43 +02:00
committed by GitHub
parent f900098cc9
commit 2cf4f641f2
+29 -25
View File
@@ -41,7 +41,7 @@ import {
InlineSwitch, InlineSwitch,
withTheme2, withTheme2,
Themeable2, Themeable2,
Collapse, PanelChrome,
} from '@grafana/ui'; } from '@grafana/ui';
import store from 'app/core/store'; import store from 'app/core/store';
import { createAndCopyShortLink } from 'app/core/utils/shortLinks'; import { createAndCopyShortLink } from 'app/core/utils/shortLinks';
@@ -121,16 +121,6 @@ interface State {
} }
const scrollableLogsContainer = config.featureToggles.exploreScrollableLogsContainer; const scrollableLogsContainer = config.featureToggles.exploreScrollableLogsContainer;
// We need to override css overflow of divs in Collapse element to enable sticky Logs navigation
const styleOverridesForStickyNavigation = css`
${scrollableLogsContainer && 'margin-bottom: 0px'};
& > div {
overflow: visible;
& > div {
overflow: visible;
}
}
`;
// we need to define the order of these explicitly // we need to define the order of these explicitly
const DEDUP_OPTIONS = [ const DEDUP_OPTIONS = [
@@ -292,11 +282,11 @@ class UnthemedLogs extends PureComponent<Props, State> {
this.setState({ hiddenLogLevels }); this.setState({ hiddenLogLevels });
}; };
onToggleLogsVolumeCollapse = (isOpen: boolean) => { onToggleLogsVolumeCollapse = (collapsed: boolean) => {
this.props.onSetLogsVolumeEnabled(isOpen); this.props.onSetLogsVolumeEnabled(!collapsed);
reportInteraction('grafana_explore_logs_histogram_toggle_clicked', { reportInteraction('grafana_explore_logs_histogram_toggle_clicked', {
datasourceType: this.props.datasourceType, datasourceType: this.props.datasourceType,
type: isOpen ? 'open' : 'close', type: !collapsed ? 'open' : 'close',
}); });
}; };
@@ -540,7 +530,12 @@ class UnthemedLogs extends PureComponent<Props, State> {
timeZone={timeZone} timeZone={timeZone}
/> />
)} )}
<Collapse label="Logs volume" collapsible isOpen={logsVolumeEnabled} onToggle={this.onToggleLogsVolumeCollapse}> <PanelChrome
title="Logs volume"
collapsible
collapsed={!logsVolumeEnabled}
onToggleCollapse={this.onToggleLogsVolumeCollapse}
>
{logsVolumeEnabled && ( {logsVolumeEnabled && (
<LogsVolumePanelList <LogsVolumePanelList
absoluteRange={absoluteRange} absoluteRange={absoluteRange}
@@ -552,16 +547,22 @@ class UnthemedLogs extends PureComponent<Props, State> {
onLoadLogsVolume={loadLogsVolumeData} onLoadLogsVolume={loadLogsVolumeData}
onHiddenSeriesChanged={this.onToggleLogLevel} onHiddenSeriesChanged={this.onToggleLogLevel}
eventBus={this.logsVolumeEventBus} eventBus={this.logsVolumeEventBus}
onClose={() => this.onToggleLogsVolumeCollapse(false)} onClose={() => this.onToggleLogsVolumeCollapse(true)}
/> />
)} )}
</Collapse> </PanelChrome>
<Collapse <PanelChrome
label={ title={
config.featureToggles.logsExploreTableVisualisation
? this.state.visualisationType === 'logs'
? 'Logs'
: 'Table'
: 'Logs'
}
actions={
<> <>
{config.featureToggles.logsExploreTableVisualisation && ( {config.featureToggles.logsExploreTableVisualisation && (
<div className={styles.visualisationType}> <div className={styles.visualisationType}>
{this.state.visualisationType === 'logs' ? 'Logs' : 'Table'}
<RadioButtonGroup <RadioButtonGroup
className={styles.visualisationTypeRadio} className={styles.visualisationTypeRadio}
options={[ options={[
@@ -582,13 +583,11 @@ class UnthemedLogs extends PureComponent<Props, State> {
/> />
</div> </div>
)} )}
{!config.featureToggles.logsExploreTableVisualisation && 'Logs'}
</> </>
} }
loading={loading} loadingState={loading ? LoadingState.Loading : LoadingState.Done}
isOpen
className={styleOverridesForStickyNavigation}
> >
<div className={styles.stickyNavigation}>
{this.state.visualisationType !== 'table' && ( {this.state.visualisationType !== 'table' && (
<div className={styles.logOptions}> <div className={styles.logOptions}>
<InlineFieldRow> <InlineFieldRow>
@@ -678,6 +677,7 @@ class UnthemedLogs extends PureComponent<Props, State> {
onEscapeNewlines={this.onEscapeNewlines} onEscapeNewlines={this.onEscapeNewlines}
clearDetectedFields={this.clearDetectedFields} clearDetectedFields={this.clearDetectedFields}
/> />
</div>
<div className={styles.logsSection}> <div className={styles.logsSection}>
{this.state.visualisationType === 'table' && hasData && ( {this.state.visualisationType === 'table' && hasData && (
<div className={styles.logRows} data-testid="logRowsTable"> <div className={styles.logRows} data-testid="logRowsTable">
@@ -757,7 +757,7 @@ class UnthemedLogs extends PureComponent<Props, State> {
clearCache={clearCache} clearCache={clearCache}
/> />
</div> </div>
</Collapse> </PanelChrome>
</> </>
); );
} }
@@ -816,5 +816,9 @@ const getStyles = (theme: GrafanaTheme2, wrapLogMessage: boolean) => {
visualisationTypeRadio: css` visualisationTypeRadio: css`
margin: 0 0 0 ${theme.spacing(1)}; margin: 0 0 0 ${theme.spacing(1)};
`, `,
stickyNavigation: css`
${scrollableLogsContainer && 'margin-bottom: 0px'}
overflow: visible;
`,
}; };
}; };