mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 20:59:35 +08:00
Revert "Variables: Show description instead of definition in table" (#70043)
This commit is contained in:
@ -59,7 +59,7 @@ export function VariableEditorList({
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Variable</th>
|
||||
<th>Description</th>
|
||||
<th>Definition</th>
|
||||
<th colSpan={5} />
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -7,7 +7,7 @@ import { selectors } from '@grafana/e2e-selectors';
|
||||
import { reportInteraction } from '@grafana/runtime';
|
||||
import { Button, Icon, IconButton, useStyles2, useTheme2 } from '@grafana/ui';
|
||||
|
||||
import { isAdHoc } from '../guard';
|
||||
import { hasOptions, isAdHoc, isQuery } from '../guard';
|
||||
import { VariableUsagesButton } from '../inspect/VariableUsagesButton';
|
||||
import { getVariableUsages, UsagesToNetwork, VariableUsageTree } from '../inspect/utils';
|
||||
import { KeyedVariableIdentifier } from '../state/types';
|
||||
@ -35,6 +35,7 @@ export function VariableEditorListRow({
|
||||
}: VariableEditorListRowProps): ReactElement {
|
||||
const theme = useTheme2();
|
||||
const styles = useStyles2(getStyles);
|
||||
const definition = getDefinition(variable);
|
||||
const usages = getVariableUsages(variable.id, usageTree);
|
||||
const passed = usages > 0 || isAdHoc(variable);
|
||||
const identifier = toKeyedVariableIdentifier(variable);
|
||||
@ -67,14 +68,14 @@ export function VariableEditorListRow({
|
||||
</td>
|
||||
<td
|
||||
role="gridcell"
|
||||
className={styles.descriptionColumn}
|
||||
className={styles.definitionColumn}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
propsOnEdit(identifier);
|
||||
}}
|
||||
aria-label={selectors.pages.Dashboard.Settings.Variables.List.tableRowDescriptionFields(variable.name)}
|
||||
aria-label={selectors.pages.Dashboard.Settings.Variables.List.tableRowDefinitionFields(variable.name)}
|
||||
>
|
||||
{variable.description}
|
||||
{definition}
|
||||
</td>
|
||||
|
||||
<td role="gridcell" className={styles.column}>
|
||||
@ -121,6 +122,21 @@ export function VariableEditorListRow({
|
||||
);
|
||||
}
|
||||
|
||||
function getDefinition(model: VariableModel): string {
|
||||
let definition = '';
|
||||
if (isQuery(model)) {
|
||||
if (model.definition) {
|
||||
definition = model.definition;
|
||||
} else if (typeof model.query === 'string') {
|
||||
definition = model.query;
|
||||
}
|
||||
} else if (hasOptions(model)) {
|
||||
definition = model.query;
|
||||
}
|
||||
|
||||
return definition;
|
||||
}
|
||||
|
||||
interface VariableCheckIndicatorProps {
|
||||
passed: boolean;
|
||||
}
|
||||
@ -158,7 +174,7 @@ function getStyles(theme: GrafanaTheme2) {
|
||||
cursor: pointer;
|
||||
color: ${theme.colors.primary.text};
|
||||
`,
|
||||
descriptionColumn: css`
|
||||
definitionColumn: css`
|
||||
width: 100%;
|
||||
max-width: 200px;
|
||||
cursor: pointer;
|
||||
|
Reference in New Issue
Block a user