Merge pull request #6994 from backstage/erikengervall/add-keys-to-custom-feature-list

[GRM plugin] Add keys to custom features list
This commit is contained in:
Fredrik Adelöw
2021-08-30 17:14:31 +02:00
committed by GitHub
3 changed files with 25 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-git-release-manager': patch
---
Wrap each feature in custom feature arrays with an element containing a 'key' to avoid missing-key-warnings
@@ -41,6 +41,10 @@ describe('Features', () => {
createRc: { omit: true },
promoteRc: { omit: true },
patch: { omit: true },
custom: {
// shouldn't trigger "missing key" warning in console
factory: () => [<div>Custom 1</div>, <div>Custom 2</div>],
},
}}
/>,
);
@@ -89,6 +89,21 @@ export function Features({
);
}
let CustomFeatures =
features?.custom?.factory({
latestRelease: gitBatchInfo.value.latestRelease,
project,
releaseBranch: gitBatchInfo.value.releaseBranch,
repository: gitBatchInfo.value.repository,
}) ?? null;
if (Array.isArray(CustomFeatures)) {
CustomFeatures = CustomFeatures.map((CustomFeature, index) => (
<React.Fragment key={`grm--custom-feature--${index}`}>
{CustomFeature}
</React.Fragment>
));
}
return (
<RefetchContext.Provider value={{ fetchGitBatchInfo }}>
<ErrorBoundary>
@@ -143,13 +158,7 @@ export function Features({
/>
)}
{features?.custom?.factory &&
features.custom.factory({
latestRelease: gitBatchInfo.value.latestRelease,
project,
releaseBranch: gitBatchInfo.value.releaseBranch,
repository: gitBatchInfo.value.repository,
})}
{CustomFeatures}
</ErrorBoundary>
</RefetchContext.Provider>
);