update to use short form group entity references

This commit is contained in:
Andrew Thauer
2021-02-20 11:18:32 -05:00
parent a8953a9c92
commit 8b5f8f84cb
4 changed files with 12 additions and 7 deletions
+2 -1
View File
@@ -2,4 +2,5 @@
'@backstage/plugin-catalog-import': patch
---
Omits the entity namespace from a generated entity when it has not be explicitly defined in the analyze-location result.
This updates the `catalog-import` plugin to omit the default metadata namespace
field and also use the short form entity reference format for selected group owners.
@@ -230,7 +230,7 @@ export function defaultGenerateStepper(
errorHelperText="required value"
textFieldProps={{
label: 'Entity Owner',
placeholder: 'Group:default/my-group',
placeholder: 'my-group',
}}
rules={{ required: true }}
required
@@ -286,7 +286,7 @@ spec:
renderFormFieldsFn.mock.calls[
renderFormFieldsFn.mock.calls.length - 1
][0],
).toMatchObject({ groups: ['Group:my-group'], groupsLoading: false });
).toMatchObject({ groups: ['my-group'], groupsLoading: false });
});
describe('generateEntities', () => {
@@ -14,9 +14,12 @@
* limitations under the License.
*/
import { Entity, serializeEntityRef } from '@backstage/catalog-model';
import { Entity } from '@backstage/catalog-model';
import { useApi } from '@backstage/core';
import { catalogApiRef } from '@backstage/plugin-catalog-react';
import {
catalogApiRef,
formatEntityRefTitle,
} from '@backstage/plugin-catalog-react';
import { Box, FormHelperText, Grid, Typography } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import React, { useCallback, useState } from 'react';
@@ -106,8 +109,9 @@ export const StepPrepareCreatePullRequest = ({
filter: { kind: 'group' },
});
// TODO: defaultKind (=group), defaultNamespace (=same as entity)
return groupEntities.items.map(e => serializeEntityRef(e) as string).sort();
return groupEntities.items
.map(e => formatEntityRefTitle(e, { defaultKind: 'group' }))
.sort();
});
const handleResult = useCallback(