mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Update public/app/features/dashboard/components/ShareModal/SharePublicDashboard/ConfigPublicDashboard/SettingsBar.tsx Co-authored-by: Juan Cabanas <juan.cabanas@grafana.com> * revert modal styling and add specific styling to Sharing * Update public/app/features/dashboard/components/ShareModal/SharePublicDashboard/ConfigPublicDashboard/SettingsBar.tsx Co-authored-by: Juan Cabanas <juan.cabanas@grafana.com> * functions > const * put a gat between all items in email config, instead of margins for each item * fix html semantic elements * ad theme to class component ShareModal * add labels * fix failing tests; now Settings has a summary and has to be opened to be able to see the On/Off toggles * fix dashboard-public-create test with settings dropdown
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import React, { memo } from 'react';
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
|
|
import { useStyles2 } from '../../../../src/themes';
|
|
import { TimePickerButtonLabel, TimeRangePickerProps } from '../TimeRangePicker';
|
|
import { isValidTimeRange } from '../utils';
|
|
|
|
type LabelProps = Pick<TimeRangePickerProps, 'hideText' | 'value' | 'timeZone'> & {
|
|
placeholder?: string;
|
|
className?: string;
|
|
};
|
|
|
|
export const TimeRangeLabel = memo<LabelProps>(function TimePickerLabel({
|
|
hideText,
|
|
value,
|
|
timeZone = 'browser',
|
|
placeholder = 'No time range selected',
|
|
className,
|
|
}) {
|
|
const styles = useStyles2(getLabelStyles);
|
|
|
|
if (hideText) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<span className={className}>
|
|
{isValidTimeRange(value) ? (
|
|
<TimePickerButtonLabel value={value} timeZone={timeZone} />
|
|
) : (
|
|
<span className={styles.placeholder}>{placeholder}</span>
|
|
)}
|
|
</span>
|
|
);
|
|
});
|
|
|
|
const getLabelStyles = (theme: GrafanaTheme2) => {
|
|
return {
|
|
placeholder: css({
|
|
color: theme.colors.text.disabled,
|
|
opacity: 1,
|
|
}),
|
|
};
|
|
};
|