Updated to use deep merge instead of shallow merge.

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2022-05-10 12:03:29 +02:00
parent a79c6f427f
commit 9a64f4a54a
3 changed files with 13 additions and 2 deletions
+1
View File
@@ -37,6 +37,7 @@
"@backstage/types": "^1.0.0",
"@backstage/version-bridge": "^1.0.1",
"history": "^5.0.0",
"lodash": "^4.17.21",
"prop-types": "^15.7.2",
"react-router-dom": "6.0.0-beta.0",
"zen-observable": "^0.8.15"
@@ -44,6 +44,9 @@ const customPlugin = createPlugin({
id: 'custom-plugin',
metadata: {
pluginLabel: 'initial label',
table: {
tableHeader: 'table header',
},
},
});
@@ -178,7 +181,7 @@ describe('extensions', () => {
it('should allow for the plugin to redefine default labels', async () => {
customPlugin.reconfigure({
pluginLabel: 'new label',
});
} as any);
const CustomPluginExtension = customPlugin.provide(
createReactExtension({
@@ -189,6 +192,9 @@ describe('extensions', () => {
<>
<div data-testid="plugin-label">
{props.metadata?.pluginLabel}
<div data-testid="plugin-table-summary">
<h3>{props.metadata?.table.tableHeader}</h3>
</div>
</div>
</>
);
@@ -201,5 +207,8 @@ describe('extensions', () => {
expect(updatedComponent.getByTestId('plugin-label')).toHaveTextContent(
'new label',
);
expect(
updatedComponent.getByTestId('plugin-table-summary'),
).toHaveTextContent('table header');
});
});
@@ -23,6 +23,7 @@ import {
AnyMetadata,
PluginFeatureFlagConfig,
} from './types';
import { merge } from 'lodash';
import { AnyApiFactory } from '../apis';
/**
@@ -71,7 +72,7 @@ export class PluginImpl<
}
reconfigure(metadata: PluginMetadata): BackstagePlugin {
this.config.metadata = { ...this.config.metadata, ...metadata };
this.config.metadata = merge(this.config.metadata, metadata);
return this;
}