Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rshen91 committed Oct 1, 2024
1 parent adc1846 commit bb77b0d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

import { apiHasParentApi } from '@kbn/presentation-publishing';

export interface HasCompressed {
interface HasCompressed {
compressed: boolean;
}

export const apiHasCompressed = (unknownApi: unknown): unknownApi is HasCompressed => {
const apiHasCompressed = (unknownApi: unknown): unknownApi is HasCompressed => {
return Boolean(unknownApi) && typeof (unknownApi as HasCompressed).compressed === 'boolean';
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ interface Props {
value: RangeValue | undefined;
uuid: string;
controlPanelClassName?: string;
compressed: boolean;
}

export const RangeSliderControl: FC<Props> = ({
Expand All @@ -46,6 +47,7 @@ export const RangeSliderControl: FC<Props> = ({
value,
uuid,
controlPanelClassName,
compressed,
}: Props) => {
const rangeSliderRef = useRef<EuiDualRangeProps | null>(null);

Expand Down Expand Up @@ -194,7 +196,7 @@ export const RangeSliderControl: FC<Props> = ({
min={displayedMin}
max={displayedMax}
isLoading={isLoading}
compressed
compressed={compressed}
inputPopoverProps={{
className: controlPanelClassName,
panelMinWidth: MIN_POPOVER_WIDTH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { EuiFieldNumber, EuiFormRow } from '@elastic/eui';
import { Filter, RangeFilterParams, buildRangeFilter } from '@kbn/es-query';
import { useBatchedPublishingSubjects } from '@kbn/presentation-publishing';

import { isCompressed } from '../../../control_group/utils/is_compressed';
import { RANGE_SLIDER_CONTROL } from '../../../../common';
import { initializeDataControl } from '../initialize_data_control';
import type { DataControlFactory } from '../types';
Expand Down Expand Up @@ -248,6 +249,7 @@ export const getRangesliderControlFactory = (): DataControlFactory<
step={step ?? 1}
value={value}
uuid={uuid}
compressed={isCompressed(api)}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface Props {
ticks: EuiRangeTick[];
timeRangeMin: number;
timeRangeMax: number;
compressed: boolean;
}

export function TimeSliderAnchoredRange(props: Props) {
Expand All @@ -40,7 +41,7 @@ export function TimeSliderAnchoredRange(props: Props) {
max={props.timeRangeMax}
step={props.stepSize}
ticks={props.ticks}
compressed
compressed={props.compressed}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface Props {
ticks: EuiRangeTick[];
timeRangeMin: number;
timeRangeMax: number;
compressed: boolean;
}

export function TimeSliderPopoverContent(props: Props) {
Expand All @@ -35,6 +36,7 @@ export function TimeSliderPopoverContent(props: Props) {
ticks={props.ticks}
timeRangeMin={props.timeRangeMin}
timeRangeMax={props.timeRangeMax}
compressed={props.compressed}
/>
) : (
<TimeSliderSlidingWindowRange
Expand All @@ -44,6 +46,7 @@ export function TimeSliderPopoverContent(props: Props) {
ticks={props.ticks}
timeRangeMin={props.timeRangeMin}
timeRangeMax={props.timeRangeMax}
compressed={props.compressed}
/>
);
const anchorStartToggleButtonLabel = props.isAnchored
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface Props {
ticks: EuiRangeTick[];
timeRangeMin: number;
timeRangeMax: number;
compressed: boolean;
}

export function TimeSliderSlidingWindowRange(props: Props) {
Expand All @@ -36,7 +37,7 @@ export function TimeSliderSlidingWindowRange(props: Props) {
step={props.stepSize}
ticks={props.ticks}
isDraggable
compressed
compressed={props.compressed}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
roundUpToNextStepSizeFactor,
} from './time_utils';
import { Timeslice, TimesliderControlApi, TimesliderControlState } from './types';
import { isCompressed } from '../../control_group/utils/is_compressed';

const displayName = i18n.translate('controls.timesliderControl.displayName', {
defaultMessage: 'Time slider',
Expand Down Expand Up @@ -306,6 +307,7 @@ export const getTimesliderControlFactory = (): ControlFactory<
ticks={timeRangeMeta.ticks}
timeRangeMin={timeRangeMeta.timeRangeMin}
timeRangeMax={timeRangeMeta.timeRangeMax}
compressed={isCompressed(api)}
/>
</EuiInputPopover>
);
Expand Down

0 comments on commit bb77b0d

Please sign in to comment.