diff --git a/.changeset/grumpy-parents-prove.md b/.changeset/grumpy-parents-prove.md
new file mode 100644
index 0000000000..ff01fe13f0
--- /dev/null
+++ b/.changeset/grumpy-parents-prove.md
@@ -0,0 +1,25 @@
+---
+'@backstage/plugin-org': patch
+---
+
+Provides the ability to hide the relations toggle on the `OwnershipCard` as well as setting a default relation type.
+
+To hide the toggle simply include the `hideRelationsToggle` prop like this:
+
+```tsx
+
+```
+
+To set the default relation type, add the `relationsType` prop with a value of direct or aggregated, the default if not provided is direct. Here is an example:
+
+```tsx
+
+```
diff --git a/plugins/org/api-report.md b/plugins/org/api-report.md
index 60d0b20ffc..5f71be44bc 100644
--- a/plugins/org/api-report.md
+++ b/plugins/org/api-report.md
@@ -25,6 +25,8 @@ export const EntityMembersListCard: (props: {
export const EntityOwnershipCard: (props: {
variant?: InfoCardVariants | undefined;
entityFilterKind?: string[] | undefined;
+ hideRelationsToggle?: boolean | undefined;
+ relationsType?: string | undefined;
}) => JSX.Element;
// @public (undocumented)
@@ -64,6 +66,8 @@ export { orgPlugin as plugin };
export const OwnershipCard: (props: {
variant?: InfoCardVariants;
entityFilterKind?: string[];
+ hideRelationsToggle?: boolean;
+ relationsType?: string;
}) => JSX.Element;
// @public (undocumented)
diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx
index dcaae2d4bf..298c921069 100644
--- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx
+++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.test.tsx
@@ -291,4 +291,74 @@ describe('OwnershipCard', () => {
'/create/?filters%5Bkind%5D=API&filters%5Btype%5D=openapi&filters%5Bowners%5D%5B0%5D=the-user&filters%5Bowners%5D%5B1%5D=my-team&filters%5Buser%5D=all',
);
});
+
+ describe('OwnershipCard relations', () => {
+ it('shows relations toggle', async () => {
+ const catalogApi: jest.Mocked = {
+ getEntities: jest.fn(),
+ } as any;
+
+ catalogApi.getEntities.mockImplementation(getEntitiesMock);
+
+ const { getByTitle } = await renderInTestApp(
+
+
+
+
+ ,
+ {
+ mountedRoutes: {
+ '/create': catalogIndexRouteRef,
+ },
+ },
+ );
+
+ expect(getByTitle('Direct Relations')).toBeInTheDocument();
+ });
+
+ it('hides relations toggle', async () => {
+ const catalogApi: jest.Mocked = {
+ getEntities: jest.fn(),
+ } as any;
+
+ catalogApi.getEntities.mockImplementation(getEntitiesMock);
+
+ const rendered = await renderInTestApp(
+
+
+
+
+ ,
+ {
+ mountedRoutes: {
+ '/create': catalogIndexRouteRef,
+ },
+ },
+ );
+
+ expect(rendered.queryByText('Direct Relations')).toBeNull();
+ });
+ it('overrides relation type', async () => {
+ const catalogApi: jest.Mocked = {
+ getEntities: jest.fn(),
+ } as any;
+
+ catalogApi.getEntities.mockImplementation(getEntitiesMock);
+
+ const { getByTitle } = await renderInTestApp(
+
+
+
+
+ ,
+ {
+ mountedRoutes: {
+ '/create': catalogIndexRouteRef,
+ },
+ },
+ );
+
+ expect(getByTitle('Aggregated Relations')).toBeInTheDocument();
+ });
+ });
});
diff --git a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx
index d29298e1a8..1cb52a4762 100644
--- a/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx
+++ b/plugins/org/src/components/Cards/OwnershipCard/OwnershipCard.tsx
@@ -55,48 +55,58 @@ const useStyles = makeStyles(theme => ({
export const OwnershipCard = (props: {
variant?: InfoCardVariants;
entityFilterKind?: string[];
+ hideRelationsToggle?: boolean;
+ relationsType?: string;
}) => {
- const { variant, entityFilterKind } = props;
-
+ const { variant, entityFilterKind, hideRelationsToggle, relationsType } =
+ props;
+ const relationsToggle =
+ hideRelationsToggle === undefined ? false : hideRelationsToggle;
const classes = useStyles();
const { entity } = useEntity();
const isGroup = entity.kind === 'Group';
- const [relationsType, setRelationsType] = useState('direct');
+ const [getRelationsType, setRelationsType] = useState(
+ relationsType || 'direct',
+ );
return (
-
-
-
-
- Direct Relations
-
+
+
+
-
- relationsType === 'direct'
- ? setRelationsType('aggregated')
- : setRelationsType('direct')
- }
- name="pin"
- inputProps={{ 'aria-label': 'Ownership Type Switch' }}
- disabled={!isGroup}
- />
-
- Aggregated Relations
-
-
-
+ Direct Relations
+
+
+ getRelationsType === 'direct'
+ ? setRelationsType('aggregated')
+ : setRelationsType('direct')
+ }
+ name="pin"
+ inputProps={{ 'aria-label': 'Ownership Type Switch' }}
+ disabled={!isGroup}
+ />
+
+ Aggregated Relations
+
+
+
+ )}