mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 16:45:43 -06:00
* Scene url sync * muu * Progress * Time range stuff * Progress * Progress * Adding tests * Rennamed interface * broken test * handling of unique url keys * Fixing isuse with unique key mapping and depth * Testing grid row expand sync * Updates * Switched from Map to Object * Now arrays work * Update public/app/features/scenes/core/types.ts Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> * Update public/app/features/scenes/core/SceneTimeRange.tsx Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> * Update public/app/features/scenes/core/SceneObjectBase.tsx Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com> Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
|
|
import { RefreshPicker, ToolbarButtonRow } from '@grafana/ui';
|
|
import { TimePickerWithHistory } from 'app/core/components/TimePicker/TimePickerWithHistory';
|
|
|
|
import { SceneObjectBase } from '../core/SceneObjectBase';
|
|
import { sceneGraph } from '../core/sceneGraph';
|
|
import { SceneComponentProps, SceneObjectStatePlain } from '../core/types';
|
|
|
|
export interface SceneTimePickerState extends SceneObjectStatePlain {
|
|
hidePicker?: boolean;
|
|
}
|
|
|
|
export class SceneTimePicker extends SceneObjectBase<SceneTimePickerState> {
|
|
public static Component = SceneTimePickerRenderer;
|
|
}
|
|
|
|
function SceneTimePickerRenderer({ model }: SceneComponentProps<SceneTimePicker>) {
|
|
const { hidePicker } = model.useState();
|
|
const timeRange = sceneGraph.getTimeRange(model);
|
|
const timeRangeState = timeRange.useState();
|
|
|
|
if (hidePicker) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<ToolbarButtonRow alignment="right">
|
|
<TimePickerWithHistory
|
|
value={timeRangeState.value}
|
|
onChange={timeRange.onTimeRangeChange}
|
|
timeZone={'browser'}
|
|
fiscalYearStartMonth={0}
|
|
onMoveBackward={() => {}}
|
|
onMoveForward={() => {}}
|
|
onZoom={() => {}}
|
|
onChangeTimeZone={() => {}}
|
|
onChangeFiscalYearStartMonth={() => {}}
|
|
/>
|
|
|
|
<RefreshPicker onRefresh={timeRange.onRefresh} onIntervalChanged={timeRange.onIntervalChanged} />
|
|
</ToolbarButtonRow>
|
|
);
|
|
}
|