Merge branch 'master' of https://github.com/spotify/backstage into lintMod

This commit is contained in:
Debajyoti Halder
2021-02-02 17:02:33 +05:30
294 changed files with 5833 additions and 1341 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
"dependencies": {
"@backstage/catalog-model": "^0.7.0",
"@backstage/core": "^0.5.0",
"@backstage/plugin-catalog": "^0.2.14",
"@backstage/plugin-catalog-react": "^0.0.1",
"@backstage/theme": "^0.2.2",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
@@ -21,7 +21,7 @@ import {
RELATION_PARENT_OF,
} from '@backstage/catalog-model';
import { Avatar, InfoCard } from '@backstage/core';
import { entityRouteParams } from '@backstage/plugin-catalog';
import { entityRouteParams } from '@backstage/plugin-catalog-react';
import { Box, Grid, Link, Tooltip, Typography } from '@material-ui/core';
import AccountTreeIcon from '@material-ui/icons/AccountTree';
import EmailIcon from '@material-ui/icons/Email';
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { Entity, GroupEntity } from '@backstage/catalog-model';
import { ApiProvider, ApiRegistry } from '@backstage/core';
import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog-react';
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import React from 'react';
import { ApiProvider, ApiRegistry } from '@backstage/core';
import { CatalogApi, catalogApiRef } from '@backstage/plugin-catalog';
import { Entity, GroupEntity } from '@backstage/catalog-model';
import { MembersListCard } from './MembersListCard';
describe('MemberTab Test', () => {
@@ -20,7 +20,10 @@ import {
UserEntity,
} from '@backstage/catalog-model';
import { Avatar, InfoCard, Progress, useApi } from '@backstage/core';
import { catalogApiRef, entityRouteParams } from '@backstage/plugin-catalog';
import {
catalogApiRef,
entityRouteParams,
} from '@backstage/plugin-catalog-react';
import {
Box,
createStyles,
@@ -14,12 +14,10 @@
* limitations under the License.
*/
import React from 'react';
import { InfoCard, useApi, Progress } from '@backstage/core';
import { Entity } from '@backstage/catalog-model';
import { catalogApiRef } from '@backstage/plugin-catalog';
import { useAsync } from 'react-use';
import Alert from '@material-ui/lab/Alert';
import { InfoCard, Progress, useApi } from '@backstage/core';
import { catalogApiRef, isOwnerOf } from '@backstage/plugin-catalog-react';
import { pageTheme } from '@backstage/theme';
import {
Box,
createStyles,
@@ -28,8 +26,9 @@ import {
Theme,
Typography,
} from '@material-ui/core';
import { pageTheme } from '@backstage/theme';
import { isOwnerOf } from '../../isOwnerOf';
import Alert from '@material-ui/lab/Alert';
import React from 'react';
import { useAsync } from 'react-use';
type EntitiesKinds = 'Component' | 'API';
type EntitiesTypes =
@@ -19,7 +19,7 @@ import {
UserEntity,
} from '@backstage/catalog-model';
import { Avatar, InfoCard } from '@backstage/core';
import { entityRouteParams } from '@backstage/plugin-catalog';
import { entityRouteParams } from '@backstage/plugin-catalog-react';
import { Box, Grid, Link, Tooltip, Typography } from '@material-ui/core';
import EmailIcon from '@material-ui/icons/Email';
import GroupIcon from '@material-ui/icons/Group';
@@ -1,42 +0,0 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Entity, EntityName } from '@backstage/catalog-model';
// TODO: this file is copied from /packages/app/catalog/src/components/getEntityRelations.ts and
// should be replaced once common relation-functions are introduced.
/**
* Get the related entity references.
*/
export function getEntityRelations(
entity: Entity | undefined,
relationType: string,
filter?: { kind: string },
): EntityName[] {
let entityNames =
entity?.relations
?.filter(r => r.type === relationType)
?.map(r => r.target) || [];
if (filter?.kind) {
entityNames = entityNames?.filter(
e => e.kind.toLowerCase() === filter.kind.toLowerCase(),
);
}
return entityNames;
}
-55
View File
@@ -1,55 +0,0 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
Entity,
EntityName,
getEntityName,
RELATION_MEMBER_OF,
RELATION_OWNED_BY,
} from '@backstage/catalog-model';
import { getEntityRelations } from './getEntityRelations';
// TODO: this file is copied from /packages/app/catalog/src/components/isOwnerOf.ts and
// should be replaced once common relation-functions are introduced.
/**
* Check if one entity is owned by another. Returns true, if the entity is owned by the
* owner directly, or if the entity is owned by a group that the owner is a member of.
*/
export function isOwnerOf(owner: Entity, owned: Entity) {
const possibleOwners: EntityName[] = [
...getEntityRelations(owner, RELATION_MEMBER_OF, { kind: 'group' }),
...(owner ? [getEntityName(owner)] : []),
];
const owners = getEntityRelations(owned, RELATION_OWNED_BY);
for (const ownerItem of owners) {
if (
possibleOwners.find(
o =>
ownerItem.kind.toLowerCase() === o.kind.toLowerCase() &&
ownerItem.namespace.toLowerCase() === o.namespace.toLowerCase() &&
ownerItem.name.toLowerCase() === o.name.toLowerCase(),
) !== undefined
) {
return true;
}
}
return false;
}