Skip to content

Commit

Permalink
fix extract and inject
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Oct 7, 2024
1 parent 92e2d34 commit 17b38e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import {
} from '../../lib/dashboard_panel_converters';
import { DashboardAttributesAndReferences, ParsedDashboardAttributesWithType } from '../../types';
import { DashboardAttributes, SavedDashboardPanel } from '../../content_management';
import {
createExtract,
createInject,
} from '../../dashboard_container/persistable_state/dashboard_container_references';

export interface InjectExtractDeps {
embeddablePersistableStateService: EmbeddablePersistableStateService;
Expand Down Expand Up @@ -45,10 +49,8 @@ export function injectReferences(
const parsedAttributes = parseDashboardAttributesWithType(attributes);

// inject references back into panels via the Embeddable persistable state service.
const injectedState = deps.embeddablePersistableStateService.inject(
parsedAttributes,
references
) as ParsedDashboardAttributesWithType;
const inject = createInject(deps.embeddablePersistableStateService);
const injectedState = inject(parsedAttributes, references) as ParsedDashboardAttributesWithType;
const injectedPanels = convertPanelMapToSavedPanels(injectedState.panels);

const newAttributes = {
Expand All @@ -74,11 +76,11 @@ export function extractReferences(
);
}

const { references: extractedReferences, state: extractedState } =
deps.embeddablePersistableStateService.extract(parsedAttributes) as {
references: Reference[];
state: ParsedDashboardAttributesWithType;
};
const extract = createExtract(deps.embeddablePersistableStateService);
const { references: extractedReferences, state: extractedState } = extract(parsedAttributes) as {
references: Reference[];
state: ParsedDashboardAttributesWithType;
};
const extractedPanels = convertPanelMapToSavedPanels(extractedState.panels);

const newAttributes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function DashboardRenderer({

const dashboardFactory = useMemo(() => {
return new DashboardContainerFactoryDefinition(embeddableService);
}, [embeddableService])
}, []);

useEffect(() => {
/* In case the locator prop changes, we need to reassign the value in the container */
Expand Down Expand Up @@ -193,4 +193,4 @@ const ParentClassController = ({
}
}, [maximizedPanelId, viewportRef.parentElement]);
return null;
};
};
2 changes: 1 addition & 1 deletion src/plugins/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,4 @@ export class DashboardPlugin
this.stopUrlTracking();
}
}
}
}

0 comments on commit 17b38e8

Please sign in to comment.