chore: clarify entity aggregation type
Signed-off-by: Carl-Erik Bergström <cbergstrom@spotify.com>
This commit is contained in:
@@ -10,12 +10,6 @@ import { ExternalRouteRef } from '@backstage/core-plugin-api';
|
||||
import { IconComponent } from '@backstage/core-plugin-api';
|
||||
import { InfoCardVariants } from '@backstage/core-components';
|
||||
|
||||
// @public (undocumented)
|
||||
export const DefaultRelationType: {
|
||||
readonly Direct: 'direct';
|
||||
readonly Aggregated: 'aggregated';
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export const EntityGroupProfileCard: (props: {
|
||||
variant?: InfoCardVariants | undefined;
|
||||
@@ -34,10 +28,13 @@ export const EntityOwnershipCard: (props: {
|
||||
variant?: InfoCardVariants | undefined;
|
||||
entityFilterKind?: string[] | undefined;
|
||||
hideRelationsToggle?: boolean | undefined;
|
||||
relationsType?: RelationType | undefined;
|
||||
relationsType?: EntityRelationAggregation | undefined;
|
||||
entityLimit?: number | undefined;
|
||||
}) => JSX.Element;
|
||||
|
||||
// @public (undocumented)
|
||||
export type EntityRelationAggregation = 'direct' | 'aggregated';
|
||||
|
||||
// @public (undocumented)
|
||||
export const EntityUserProfileCard: (props: {
|
||||
variant?: InfoCardVariants | undefined;
|
||||
@@ -81,14 +78,10 @@ export const OwnershipCard: (props: {
|
||||
variant?: InfoCardVariants;
|
||||
entityFilterKind?: string[];
|
||||
hideRelationsToggle?: boolean;
|
||||
relationsType?: RelationType;
|
||||
relationsType?: EntityRelationAggregation;
|
||||
entityLimit?: number;
|
||||
}) => JSX.Element;
|
||||
|
||||
// @public (undocumented)
|
||||
export type RelationType =
|
||||
(typeof DefaultRelationType)[keyof typeof DefaultRelationType];
|
||||
|
||||
// @public (undocumented)
|
||||
export const UserProfileCard: (props: {
|
||||
variant?: InfoCardVariants;
|
||||
|
||||
@@ -34,7 +34,7 @@ import React from 'react';
|
||||
import pluralize from 'pluralize';
|
||||
import { catalogIndexRouteRef } from '../../../routes';
|
||||
import { useGetEntities } from './useGetEntities';
|
||||
import { RelationType } from './types';
|
||||
import { EntityRelationAggregation } from './types';
|
||||
|
||||
const useStyles = makeStyles((theme: BackstageTheme) =>
|
||||
createStyles({
|
||||
@@ -114,7 +114,7 @@ export const ComponentsGrid = ({
|
||||
entityLimit = 6,
|
||||
}: {
|
||||
entity: Entity;
|
||||
relationsType: RelationType;
|
||||
relationsType: EntityRelationAggregation;
|
||||
entityFilterKind?: string[];
|
||||
entityLimit?: number;
|
||||
}) => {
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
} from '@material-ui/core';
|
||||
import React, { useState } from 'react';
|
||||
import { ComponentsGrid } from './ComponentsGrid';
|
||||
import { DefaultRelationType, RelationType } from './types';
|
||||
import { EntityRelationAggregation } from './types';
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
list: {
|
||||
@@ -57,7 +57,7 @@ export const OwnershipCard = (props: {
|
||||
variant?: InfoCardVariants;
|
||||
entityFilterKind?: string[];
|
||||
hideRelationsToggle?: boolean;
|
||||
relationsType?: RelationType;
|
||||
relationsType?: EntityRelationAggregation;
|
||||
entityLimit?: number;
|
||||
}) => {
|
||||
const {
|
||||
@@ -72,7 +72,7 @@ export const OwnershipCard = (props: {
|
||||
const classes = useStyles();
|
||||
const { entity } = useEntity();
|
||||
const [getRelationsType, setRelationsType] = useState(
|
||||
relationsType || DefaultRelationType.Direct,
|
||||
relationsType || 'direct',
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -15,11 +15,4 @@
|
||||
*/
|
||||
|
||||
/** @public */
|
||||
export const DefaultRelationType = {
|
||||
Direct: 'direct',
|
||||
Aggregated: 'aggregated',
|
||||
} as const;
|
||||
|
||||
/** @public */
|
||||
export type RelationType =
|
||||
(typeof DefaultRelationType)[keyof typeof DefaultRelationType];
|
||||
export type EntityRelationAggregation = 'direct' | 'aggregated';
|
||||
|
||||
@@ -31,7 +31,7 @@ import limiterFactory from 'p-limit';
|
||||
import { useApi } from '@backstage/core-plugin-api';
|
||||
import useAsync from 'react-use/lib/useAsync';
|
||||
import qs from 'qs';
|
||||
import { RelationType } from './types';
|
||||
import { EntityRelationAggregation as EntityRelationsAggregation } from './types';
|
||||
|
||||
const limiter = limiterFactory(10);
|
||||
|
||||
@@ -124,11 +124,11 @@ const getChildOwnershipEntityRefs = async (
|
||||
|
||||
const getOwners = async (
|
||||
entity: Entity,
|
||||
relationsType: RelationType,
|
||||
relations: EntityRelationsAggregation,
|
||||
catalogApi: CatalogApi,
|
||||
): Promise<string[]> => {
|
||||
const isGroup = entity.kind === 'Group';
|
||||
const isAggregated = relationsType === 'aggregated';
|
||||
const isAggregated = relations === 'aggregated';
|
||||
const isUserEntity = entity.kind === 'User';
|
||||
|
||||
const owners: string[] = [];
|
||||
@@ -173,7 +173,7 @@ const getOwnedEntitiesByOwners = (
|
||||
|
||||
export function useGetEntities(
|
||||
entity: Entity,
|
||||
relationsType: RelationType,
|
||||
relations: EntityRelationsAggregation,
|
||||
entityFilterKind?: string[],
|
||||
entityLimit = 6,
|
||||
): {
|
||||
@@ -196,7 +196,7 @@ export function useGetEntities(
|
||||
error,
|
||||
value: componentsWithCounters,
|
||||
} = useAsync(async () => {
|
||||
const owners = await getOwners(entity, relationsType, catalogApi);
|
||||
const owners = await getOwners(entity, relations, catalogApi);
|
||||
|
||||
const ownedEntitiesList = await getOwnedEntitiesByOwners(
|
||||
owners,
|
||||
@@ -237,7 +237,7 @@ export function useGetEntities(
|
||||
kind: string;
|
||||
queryParams: string;
|
||||
}>;
|
||||
}, [catalogApi, entity, relationsType]);
|
||||
}, [catalogApi, entity, relations]);
|
||||
|
||||
return {
|
||||
componentsWithCounters,
|
||||
|
||||
Reference in New Issue
Block a user