Merge pull request #3022 from spotify/mob/owner

catalog: use the ownedBy relation to display owners
This commit is contained in:
Patrik Oldsberg
2020-10-22 18:48:15 +02:00
committed by GitHub
@@ -14,7 +14,12 @@
* limitations under the License.
*/
import { Entity, ENTITY_DEFAULT_NAMESPACE } from '@backstage/catalog-model';
import {
Entity,
ENTITY_DEFAULT_NAMESPACE,
RELATION_OWNED_BY,
serializeEntityRef,
} from '@backstage/catalog-model';
import {
Card,
CardContent,
@@ -139,7 +144,20 @@ export function AboutCard({ entity, variant }: AboutCardProps) {
</AboutField>
<AboutField
label="Owner"
value={entity?.spec?.owner as string}
value={entity?.relations
?.filter(r => r.type === RELATION_OWNED_BY)
.map(({ target: { kind, name, namespace } }) =>
// TODO(Rugvip): we want to provide some utils for this
serializeEntityRef({
kind,
name,
namespace:
namespace === ENTITY_DEFAULT_NAMESPACE
? undefined
: namespace,
}),
)
.join(', ')}
gridSizes={{ xs: 12, sm: 6, lg: 4 }}
/>
<AboutField