Simplify export by allowing only one resource export based on dashboard schema version

This commit is contained in:
Haris Rozajac
2025-11-25 22:37:34 -07:00
parent e0f210d8c4
commit 4a5530c32f
2 changed files with 4 additions and 31 deletions
@@ -40,7 +40,6 @@ export function ResourceExport({
onViewYAML,
}: Props) {
const hasLibraryPanels = dashboardJson.value?.hasLibraryPanels;
const initialSaveModelVersion = dashboardJson.value?.initialSaveModelVersion;
const isV2Dashboard =
dashboardJson.value?.json && 'spec' in dashboardJson.value.json && 'elements' in dashboardJson.value.json.spec;
const showV2LibPanelAlert = isV2Dashboard && isSharingExternally && hasLibraryPanels;
@@ -55,34 +54,14 @@ export function ResourceExport({
return (
<Stack gap={2} direction="column">
<Stack gap={1} direction="column">
{initialSaveModelVersion === 'v1' && (
<Stack alignItems="center">
<Label>{switchExportModeLabel}</Label>
<RadioButtonGroup
options={[
{ label: t('dashboard-scene.resource-export.label.classic', 'Classic'), value: ExportMode.Classic },
{
label: t('dashboard-scene.resource-export.label.v1-resource', 'V1 Resource'),
value: ExportMode.V1Resource,
},
{
label: t('dashboard-scene.resource-export.label.v2-resource', 'V2 Resource'),
value: ExportMode.V2Resource,
},
]}
value={exportMode}
onChange={(value) => onExportModeChange(value)}
/>
</Stack>
)}
{initialSaveModelVersion === 'v2' && (
{!isV2Dashboard && (
<Stack alignItems="center">
<Label>{switchExportModeLabel}</Label>
<RadioButtonGroup
options={[
{
label: t('dashboard-scene.resource-export.label.v2-resource', 'V2 Resource'),
value: ExportMode.V2Resource,
label: t('dashboard-scene.resource-export.label.classic', 'Classic'),
value: ExportMode.Classic,
},
{
label: t('dashboard-scene.resource-export.label.v1-resource', 'V1 Resource'),
@@ -107,9 +86,7 @@ export function ResourceExport({
/>
</Stack>
)}
{(isV2Dashboard ||
exportMode === ExportMode.Classic ||
(initialSaveModelVersion === 'v2' && exportMode === ExportMode.V1Resource)) && (
{exportMode !== ExportMode.V1Resource && (
<Stack gap={1} alignItems="start">
<Label>{switchExportLabel}</Label>
<Switch
@@ -112,10 +112,6 @@ export class ShareExportTab extends SceneObjectBase<ShareExportTabState> impleme
const metadata = getMetadata(scene, Boolean(isSharingExternally));
if (isDashboardV2Spec(origDashboard) && 'elements' in exportable && exportMode !== ExportMode.V1Resource) {
this.setState({
exportMode: ExportMode.V2Resource,
});
// For automatic V2 path, also process library panels when sharing externally
let finalSpec = exportable;
if (isSharingExternally && isDashboardV2Spec(exportable)) {