mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* Chore: adds tests to reducer * Refactor: rewrite state * Refactor: adds library panels to export * wip * Refactor: adds import library panels * Refactor: changes UI * Chore: pushing drone * Update public/app/features/manage-dashboards/components/ImportDashboardForm.tsx Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update public/app/features/manage-dashboards/components/ImportDashboardForm.tsx Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Chore: reverted unknown merge changes Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import React, { ReactElement } from 'react';
|
|
import { Field, useStyles2 } from '@grafana/ui';
|
|
|
|
import { LibraryPanelInput, LibraryPanelInputState } from '../state/reducers';
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { css } from '@emotion/css';
|
|
import { LibraryPanelCard } from '../../library-panels/components/LibraryPanelCard/LibraryPanelCard';
|
|
|
|
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)};
|
|
`,
|
|
};
|
|
}
|