mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import React, { ReactElement } from 'react';
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { Field, useStyles2 } from '@grafana/ui';
|
|
|
|
import { LibraryPanelCard } from '../../library-panels/components/LibraryPanelCard/LibraryPanelCard';
|
|
import { LibraryPanelInput, LibraryPanelInputState } from '../state/reducers';
|
|
|
|
interface ImportDashboardLibraryPanelsListProps {
|
|
inputs: LibraryPanelInput[];
|
|
label: string;
|
|
description: string;
|
|
folderName?: string;
|
|
}
|
|
|
|
export function ImportDashboardLibraryPanelsList({
|
|
inputs,
|
|
label,
|
|
description,
|
|
folderName,
|
|
}: ImportDashboardLibraryPanelsListProps): ReactElement | null {
|
|
const styles = useStyles2(getStyles);
|
|
|
|
if (!Boolean(inputs?.length)) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className={styles.spacer}>
|
|
<Field label={label} description={description}>
|
|
<>
|
|
{inputs.map((input, index) => {
|
|
const libraryPanelIndex = `elements[${index}]`;
|
|
const libraryPanel =
|
|
input.state === LibraryPanelInputState.New
|
|
? { ...input.model, meta: { ...input.model.meta, folderName: folderName ?? 'General' } }
|
|
: { ...input.model };
|
|
return (
|
|
<div className={styles.item} key={libraryPanelIndex}>
|
|
<LibraryPanelCard libraryPanel={libraryPanel} onClick={() => undefined} />
|
|
</div>
|
|
);
|
|
})}
|
|
</>
|
|
</Field>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function getStyles(theme: GrafanaTheme2) {
|
|
return {
|
|
spacer: css`
|
|
margin-bottom: ${theme.spacing(2)};
|
|
`,
|
|
item: css`
|
|
margin-bottom: ${theme.spacing(1)};
|
|
`,
|
|
};
|
|
}
|