Data links: Show oneClick option just for specific panels (#100298)
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
co-authored by
Leon Sorokin
parent
f9c329bbd1
commit
3dcd885644
@@ -50,7 +50,9 @@ export interface SliderFieldConfigSettings {
|
||||
ariaLabelForHandle?: string;
|
||||
}
|
||||
|
||||
export interface DataLinksFieldConfigSettings {}
|
||||
export interface DataLinksFieldConfigSettings {
|
||||
showOneClick?: boolean;
|
||||
}
|
||||
|
||||
export const dataLinksOverrideProcessor = (
|
||||
value: any,
|
||||
|
||||
@@ -144,6 +144,7 @@ export enum FieldConfigProperty {
|
||||
Thresholds = 'thresholds',
|
||||
Mappings = 'mappings',
|
||||
Links = 'links',
|
||||
Actions = 'actions',
|
||||
Color = 'color',
|
||||
Filterable = 'filterable',
|
||||
}
|
||||
|
||||
+7
-2
@@ -9,7 +9,12 @@ type DataLinksInlineEditorProps = Omit<DataLinksInlineEditorBaseProps<DataLink>,
|
||||
getSuggestions: () => VariableSuggestion[];
|
||||
};
|
||||
|
||||
export const DataLinksInlineEditor = ({ links, getSuggestions, showOneClick, ...rest }: DataLinksInlineEditorProps) => (
|
||||
export const DataLinksInlineEditor = ({
|
||||
links,
|
||||
getSuggestions,
|
||||
showOneClick = false,
|
||||
...rest
|
||||
}: DataLinksInlineEditorProps) => (
|
||||
<DataLinksInlineEditorBase<DataLink> type="link" items={links} {...rest}>
|
||||
{(item, index, onSave, onCancel) => (
|
||||
<DataLinkEditorModalContent
|
||||
@@ -19,7 +24,7 @@ export const DataLinksInlineEditor = ({ links, getSuggestions, showOneClick, ...
|
||||
onSave={onSave}
|
||||
onCancel={onCancel}
|
||||
getSuggestions={getSuggestions}
|
||||
showOneClick={showOneClick ?? true}
|
||||
showOneClick={showOneClick}
|
||||
/>
|
||||
)}
|
||||
</DataLinksInlineEditorBase>
|
||||
|
||||
@@ -3,13 +3,14 @@ import { DataLinksInlineEditor } from '@grafana/ui';
|
||||
|
||||
type Props = StandardEditorProps<DataLink[], DataLinksFieldConfigSettings>;
|
||||
|
||||
export const DataLinksValueEditor = ({ value, onChange, context }: Props) => {
|
||||
export const DataLinksValueEditor = ({ value, onChange, context, item }: Props) => {
|
||||
return (
|
||||
<DataLinksInlineEditor
|
||||
links={value}
|
||||
onChange={onChange}
|
||||
data={context.data}
|
||||
getSuggestions={() => (context.getSuggestions ? context.getSuggestions(VariableSuggestionsScope.Values) : [])}
|
||||
showOneClick={item.settings?.showOneClick}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
FieldNamePickerConfigSettings,
|
||||
booleanOverrideProcessor,
|
||||
Action,
|
||||
DataLinksFieldConfigSettings,
|
||||
} from '@grafana/data';
|
||||
import { actionsOverrideProcessor } from '@grafana/data/src/field/overrides/processors';
|
||||
import { config } from '@grafana/runtime';
|
||||
@@ -350,7 +351,7 @@ export const getAllStandardFieldConfigs = () => {
|
||||
|
||||
const dataLinksCategory = config.featureToggles.vizActions ? 'Data links and actions' : 'Data links';
|
||||
|
||||
const links: FieldConfigPropertyItem<FieldConfig, DataLink[], StringFieldConfigSettings> = {
|
||||
const links: FieldConfigPropertyItem<FieldConfig, DataLink[], DataLinksFieldConfigSettings> = {
|
||||
id: 'links',
|
||||
path: 'links',
|
||||
name: 'Data links',
|
||||
@@ -358,14 +359,14 @@ export const getAllStandardFieldConfigs = () => {
|
||||
override: standardEditorsRegistry.get('links').editor,
|
||||
process: dataLinksOverrideProcessor,
|
||||
settings: {
|
||||
placeholder: '-',
|
||||
showOneClick: false,
|
||||
},
|
||||
shouldApply: () => true,
|
||||
category: [dataLinksCategory],
|
||||
getItemsCount: (value) => (value ? value.length : 0),
|
||||
};
|
||||
|
||||
const actions: FieldConfigPropertyItem<FieldConfig, Action[], StringFieldConfigSettings> = {
|
||||
const actions: FieldConfigPropertyItem<FieldConfig, Action[], DataLinksFieldConfigSettings> = {
|
||||
id: 'actions',
|
||||
path: 'actions',
|
||||
name: 'Actions',
|
||||
@@ -373,12 +374,13 @@ export const getAllStandardFieldConfigs = () => {
|
||||
override: standardEditorsRegistry.get('actions').editor,
|
||||
process: actionsOverrideProcessor,
|
||||
settings: {
|
||||
placeholder: '-',
|
||||
showOneClick: false,
|
||||
},
|
||||
shouldApply: () => true,
|
||||
category: [dataLinksCategory],
|
||||
getItemsCount: (value) => (value ? value.length : 0),
|
||||
showIf: () => config.featureToggles.vizActions,
|
||||
hideFromDefaults: true,
|
||||
};
|
||||
|
||||
const color: FieldConfigPropertyItem<FieldConfig, FieldColor | undefined, FieldColorConfigSettings> = {
|
||||
|
||||
@@ -9,7 +9,12 @@ type DataLinksInlineEditorProps = Omit<DataLinksInlineEditorBaseProps<Action>, '
|
||||
getSuggestions: () => VariableSuggestion[];
|
||||
};
|
||||
|
||||
export const ActionsInlineEditor = ({ actions, getSuggestions, showOneClick, ...rest }: DataLinksInlineEditorProps) => (
|
||||
export const ActionsInlineEditor = ({
|
||||
actions,
|
||||
getSuggestions,
|
||||
showOneClick = false,
|
||||
...rest
|
||||
}: DataLinksInlineEditorProps) => (
|
||||
<DataLinksInlineEditorBase<Action> type="action" items={actions} {...rest}>
|
||||
{(item, index, onSave, onCancel) => (
|
||||
<ActionEditorModalContent
|
||||
@@ -19,7 +24,7 @@ export const ActionsInlineEditor = ({ actions, getSuggestions, showOneClick, ...
|
||||
onSave={onSave}
|
||||
onCancel={onCancel}
|
||||
getSuggestions={getSuggestions}
|
||||
showOneClick={showOneClick ?? false}
|
||||
showOneClick={showOneClick}
|
||||
/>
|
||||
)}
|
||||
</DataLinksInlineEditorBase>
|
||||
|
||||
@@ -32,6 +32,14 @@ export const plugin = new PanelPlugin<Options, FieldConfig>(BarChartPanel)
|
||||
mode: FieldColorModeId.PaletteClassic,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Links]: {
|
||||
settings: {
|
||||
showOneClick: true,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Actions]: {
|
||||
hideFromDefaults: false,
|
||||
},
|
||||
},
|
||||
useCustomConfig: (builder) => {
|
||||
const cfg = defaultFieldConfig;
|
||||
|
||||
@@ -20,7 +20,7 @@ export function DataLinksEditor({ value, onChange, item, context }: Props) {
|
||||
}}
|
||||
getSuggestions={() => (context.getSuggestions ? context.getSuggestions(VariableSuggestionsScope.Values) : [])}
|
||||
data={[]}
|
||||
showOneClick={false}
|
||||
showOneClick={true}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,15 @@ export const plugin = new PanelPlugin<Options>(CanvasPanel)
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Links]: {
|
||||
settings: {
|
||||
showOneClick: false,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Actions]: {
|
||||
hideFromDefaults: true,
|
||||
settings: {
|
||||
showOneClick: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -23,6 +23,13 @@ import { Options, defaultOptions, HeatmapColorMode, HeatmapColorScale } from './
|
||||
export const plugin = new PanelPlugin<Options, GraphFieldConfig>(HeatmapPanel)
|
||||
.useFieldConfig({
|
||||
disableStandardOptions: Object.values(FieldConfigProperty).filter((v) => v !== FieldConfigProperty.Links),
|
||||
standardOptions: {
|
||||
[FieldConfigProperty.Links]: {
|
||||
settings: {
|
||||
showOneClick: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
useCustomConfig: (builder) => {
|
||||
builder.addCustomEditor<void, ScaleDistributionConfig>({
|
||||
id: 'scaleDistribution',
|
||||
|
||||
@@ -81,6 +81,11 @@ export const plugin = new PanelPlugin<Options, FieldConfig>(HistogramPanel)
|
||||
mode: FieldColorModeId.PaletteClassic,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Links]: {
|
||||
settings: {
|
||||
showOneClick: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
useCustomConfig: (builder) => {
|
||||
const cfg = defaultFieldConfig;
|
||||
|
||||
@@ -29,6 +29,14 @@ export const plugin = new PanelPlugin<Options, FieldConfig>(StateTimelinePanel)
|
||||
mode: FieldColorModeId.ContinuousGrYlRd,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Links]: {
|
||||
settings: {
|
||||
showOneClick: true,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Actions]: {
|
||||
hideFromDefaults: false,
|
||||
},
|
||||
},
|
||||
useCustomConfig: (builder) => {
|
||||
builder
|
||||
|
||||
@@ -17,6 +17,14 @@ export const plugin = new PanelPlugin<Options, FieldConfig>(StatusHistoryPanel)
|
||||
mode: FieldColorModeId.Thresholds,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Links]: {
|
||||
settings: {
|
||||
showOneClick: true,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Actions]: {
|
||||
hideFromDefaults: false,
|
||||
},
|
||||
},
|
||||
useCustomConfig: (builder) => {
|
||||
builder
|
||||
|
||||
@@ -59,6 +59,14 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig, isTime = true): SetFi
|
||||
mode: FieldColorModeId.PaletteClassic,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Links]: {
|
||||
settings: {
|
||||
showOneClick: true,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Actions]: {
|
||||
hideFromDefaults: false,
|
||||
},
|
||||
},
|
||||
useCustomConfig: (builder) => {
|
||||
builder
|
||||
|
||||
@@ -35,7 +35,6 @@ export function getScatterFieldConfig(cfg: FieldConfig): SetFieldConfigOptionsAr
|
||||
[FieldConfigProperty.DisplayName]: {
|
||||
hideFromDefaults: true,
|
||||
},
|
||||
|
||||
// TODO: this still leaves Color series by: [ Last | Min | Max ]
|
||||
// because item.settings?.bySeriesSupport && colorMode.isByValue
|
||||
[FieldConfigProperty.Color]: {
|
||||
@@ -48,6 +47,14 @@ export function getScatterFieldConfig(cfg: FieldConfig): SetFieldConfigOptionsAr
|
||||
mode: FieldColorModeId.PaletteClassic,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Links]: {
|
||||
settings: {
|
||||
showOneClick: true,
|
||||
},
|
||||
},
|
||||
[FieldConfigProperty.Actions]: {
|
||||
hideFromDefaults: false,
|
||||
},
|
||||
},
|
||||
|
||||
useCustomConfig: (builder) => {
|
||||
|
||||
Reference in New Issue
Block a user