README updated and comments fixed

Signed-off-by: Deepankumar Loganathan <deepan0433@gmail.com>
This commit is contained in:
Deepankumar Loganathan
2024-02-03 18:31:59 +01:00
parent 2bfd8ac15b
commit bfd63c99f6
6 changed files with 67 additions and 35 deletions
@@ -131,7 +131,7 @@ export async function createRouter(
const host = req.query.host?.toString();
const org = req.query.org?.toString();
const entityRef = req.query.entityRef?.toString();
const entityRef = req.query.entityRef;
if (typeof entityRef !== 'string') {
throw new InputError('Invalid entityRef, not a string');
}
@@ -181,7 +181,7 @@ export async function createRouter(
status: status,
};
const entityRef = req.query.entityRef?.toString();
const entityRef = req.query.entityRef;
if (typeof entityRef !== 'string') {
throw new InputError('Invalid entityRef, not a string');
}
@@ -290,7 +290,7 @@ export async function createRouter(
const host = req.query.host?.toString();
const org = req.query.org?.toString();
const entityRef = req.query.entityRef?.toString();
const entityRef = req.query.entityRef;
if (typeof entityRef !== 'string') {
throw new InputError('Invalid entityRef, not a string');
}
@@ -355,7 +355,7 @@ export async function createRouter(
const { projectName, repoName } = req.params;
const entityRef = req.query.entityRef?.toString();
const entityRef = req.query.entityRef;
if (typeof entityRef !== 'string') {
throw new InputError('Invalid entityRef, not a string');
}
+59
View File
@@ -319,3 +319,62 @@ To get the README component working you'll need to do the following two steps:
- You'll need to add the `EntitySwitch.Case` above from step 2 to all the entity sections you want to see Readme in. For example if you wanted to see Readme when looking at Website entities then you would need to add this to the `websiteEntityPage` section.
- The `if` prop is optional on the `EntitySwitch.Case`, you can remove it if you always want to see the tab even if the entity being viewed does not have the needed annotation
- The `maxHeight` property on the `EntityAzureReadmeCard` will set the maximum screen size you would like to see, if not set it will default to 100%
## Permission Framework
Azure DevOps plugin is now supporting the permission framework for PRs, GitTags, Pipelines & ReadMe.
To enable the permission on the legacy backend system add the below config in `packages/backend/src/plugins/azure-devops.ts`.
```diff
export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return createRouter({
logger: env.logger,
config: env.config,
reader: env.reader,
+ permissions: env.permissions,
});
}
```
### Configure Permission
To apply the permission rule add the following in `packages/backend/src/plugins/permissions.ts`.
> Note this is example only `azureDevOpsPullRequestDashboardReadPermission` is Basic permission rest all Resource Permission. As an adopter you can configure how you wanted.
```diff
+ import {
+ azureDevOpsPullRequestReadPermission,
+ azureDevOpsPipelineReadPermission,
+ azureDevOpsGitTagReadPermission,
+ azureDevOpsReadmeReadPermission,
+ azureDevOpsPullRequestDashboardReadPermission } from '@backstage/azure-devops-common';
...
async handle(
request: PolicyQuery,
user?: BackstageIdentityResponse,
): Promise<PolicyDecision> {
+ if ( isPermission(request.permission, azureDevOpsPullRequestReadPermission) ||
+ isPermission(request.permission, azureDevOpsPipelineReadPermission) ||
+ isPermission(request.permission, azureDevOpsGitTagReadPermission) ||
+ isPermission(request.permission, azureDevOpsReadmeReadPermission)) {
+ return createTodoListConditionalDecision(
+ request.permission,
+ catalogConditions.isEntityOwner({
+ claims: user?.identity.ownershipEntityRefs ?? [],
+ }),
+ );
+ }
+ if ( isPermission(request.permission, azureDevOpsPullRequestDashboardReadPermission) {
+ result: AuthorizeResult.ALLOW,
+ }
return {
result: AuthorizeResult.ALLOW,
};
}
```
@@ -20,7 +20,6 @@ import React from 'react';
import { stringifyEntityRef } from '@backstage/catalog-model';
import { useEntity } from '@backstage/plugin-catalog-react';
import { RequirePermission } from '@backstage/plugin-permission-react';
import { EmptyState } from '@backstage/core-components';
export const EntityPageAzureGitTags = () => {
const { entity } = useEntity();
@@ -28,13 +27,7 @@ export const EntityPageAzureGitTags = () => {
<RequirePermission
permission={azureDevOpsGitTagReadPermission}
resourceRef={stringifyEntityRef(entity)}
errorPage={
<EmptyState
missing="data"
title="No Tags to show"
description="You are not authorized!"
/>
}
errorPage={null}
>
<GitTagTable />
</RequirePermission>
@@ -21,7 +21,6 @@ import { useEntity } from '@backstage/plugin-catalog-react';
import { azureDevOpsPipelineReadPermission } from '@backstage/plugin-azure-devops-common';
import { stringifyEntityRef } from '@backstage/catalog-model';
import { RequirePermission } from '@backstage/plugin-permission-react';
import { EmptyState } from '@backstage/core-components';
export const EntityPageAzurePipelines = (props: { defaultLimit?: number }) => {
const { entity } = useEntity();
@@ -32,13 +31,7 @@ export const EntityPageAzurePipelines = (props: { defaultLimit?: number }) => {
<RequirePermission
permission={azureDevOpsPipelineReadPermission}
resourceRef={stringifyEntityRef(entity)}
errorPage={
<EmptyState
missing="data"
title="No Buils to show"
description="You are not authorized!"
/>
}
errorPage={null}
>
<BuildTable items={items} loading={loading} error={error} />
</RequirePermission>
@@ -20,7 +20,6 @@ import React from 'react';
import { RequirePermission } from '@backstage/plugin-permission-react';
import { useEntity } from '@backstage/plugin-catalog-react';
import { stringifyEntityRef } from '@backstage/catalog-model';
import { EmptyState } from '@backstage/core-components';
export const EntityPageAzurePullRequests = (props: {
defaultLimit?: number;
@@ -30,13 +29,7 @@ export const EntityPageAzurePullRequests = (props: {
<RequirePermission
permission={azureDevOpsPullRequestReadPermission}
resourceRef={stringifyEntityRef(entity)}
errorPage={
<EmptyState
missing="data"
title="No Pull Requests to show"
description="You are not authorized!"
/>
}
errorPage={null}
>
<PullRequestTable defaultLimit={props.defaultLimit} />
</RequirePermission>
@@ -103,13 +103,7 @@ export const ReadmeCard = (props: Props) => {
<RequirePermission
permission={azureDevOpsReadmeReadPermission}
resourceRef={stringifyEntityRef(entity)}
errorPage={
<EmptyState
title="No README available for this entity"
missing="field"
description="You are not authorized!"
/>
}
errorPage={null}
>
<InfoCard
title="Readme"