hacking from pullrequests

Signed-off-by: mo <mcassidy@hchb.com>
This commit is contained in:
mo
2022-04-28 07:53:08 -05:00
parent 271bb4cea0
commit 6392fbe3c0
8 changed files with 229 additions and 0 deletions
@@ -0,0 +1,26 @@
/*
* Copyright 2021 The Backstage Authors
*
* 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 { GitTagTable } from '../GitTagTable/GitTagTable';
import React from 'react';
export const EntityPageAzureGitTags = ({
defaultLimit,
}: {
defaultLimit?: number;
}) => {
return <GitTagTable defaultLimit={defaultLimit} />;
};
@@ -0,0 +1,17 @@
/*
* Copyright 2021 The Backstage Authors
*
* 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.
*/
export { EntityPageAzureGitTags } from './EntityPageAzureGitTags';
@@ -0,0 +1,139 @@
/*
* Copyright 2021 The Backstage Authors
*
* 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 { Box, Chip } from '@material-ui/core';
import {
Link,
ResponseErrorPanel,
Table,
TableColumn,
} from '@backstage/core-components';
import {
PullRequest,
PullRequestStatus,
} from '@backstage/plugin-azure-devops-common';
import React, { useState } from 'react';
import { AzurePullRequestsIcon } from '../AzurePullRequestsIcon';
import { DateTime } from 'luxon';
import { PullRequestStatusButtonGroup } from '../PullRequestStatusButtonGroup';
import { useEntity } from '@backstage/plugin-catalog-react';
import { usePullRequests } from '../../hooks/usePullRequests';
const columns: TableColumn[] = [
{
title: 'ID',
field: 'pullRequestId',
highlight: false,
width: 'auto',
},
{
title: 'Title',
field: 'title',
width: 'auto',
render: (row: Partial<PullRequest>) => (
<Box display="flex" alignItems="center">
<Link to={row.link ?? ''}>{row.title}</Link>
{row.isDraft && (
<Box paddingLeft={1}>
<Chip
label="Draft"
variant="outlined"
color="secondary"
size="small"
/>
</Box>
)}
</Box>
),
},
{
title: 'Source',
field: 'sourceRefName',
width: 'auto',
},
{
title: 'Target',
field: 'targetRefName',
width: 'auto',
},
{
title: 'Created By',
field: 'createdBy',
width: 'auto',
},
{
title: 'Created',
field: 'creationDate',
width: 'auto',
render: (row: Partial<PullRequest>) =>
(row.creationDate
? DateTime.fromISO(row.creationDate)
: DateTime.now()
).toRelative(),
},
];
type PullRequestTableProps = {
defaultLimit?: number;
};
export const GitTagTable = ({ defaultLimit }: PullRequestTableProps) => {
const [pullRequestStatusState, setPullRequestStatusState] =
useState<PullRequestStatus>(PullRequestStatus.Active);
const { entity } = useEntity();
const { items, loading, error } = usePullRequests(
entity,
defaultLimit,
pullRequestStatusState,
);
if (error) {
return (
<div>
<ResponseErrorPanel error={error} />
</div>
);
}
return (
<Table
isLoading={loading}
columns={columns}
options={{
search: true,
paging: true,
pageSize: 5,
showEmptyDataSourceMessage: !loading,
}}
title={
<Box display="flex" alignItems="center">
<AzurePullRequestsIcon style={{ fontSize: 30 }} />
<Box mr={1} />
Azure Repos - Pull Requests ({items ? items.length : 0})
<Box position="absolute" right={320} top={20}>
<PullRequestStatusButtonGroup
status={pullRequestStatusState}
setStatus={setPullRequestStatusState}
/>
</Box>
</Box>
}
data={items ?? []}
/>
);
};
@@ -0,0 +1,17 @@
/*
* Copyright 2021 The Backstage Authors
*
* 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.
*/
export { GitTagTable } from './GitTagTable';
+1
View File
@@ -17,6 +17,7 @@
export {
azureDevOpsPlugin,
EntityAzurePipelinesContent,
EntityAzureGitTagsContent,
EntityAzurePullRequestsContent,
isAzureDevOpsAvailable,
isAzurePipelinesAvailable,
+12
View File
@@ -22,6 +22,7 @@ import {
import {
azurePipelinesEntityContentRouteRef,
azurePullRequestDashboardRouteRef,
azureGitTagsEntityContentRouteRef,
azurePullRequestsEntityContentRouteRef,
} from './routes';
import {
@@ -78,6 +79,17 @@ export const EntityAzurePipelinesContent = azureDevOpsPlugin.provide(
}),
);
export const EntityAzureGitTagsContent = azureDevOpsPlugin.provide(
createRoutableExtension({
name: 'EntityAzureGitTagsContent',
component: () =>
import('./components/EntityPageAzureGitTags').then(
m => m.EntityPageAzureGitTags,
),
mountPoint: azureGitTagsEntityContentRouteRef,
}),
);
export const EntityAzurePullRequestsContent = azureDevOpsPlugin.provide(
createRoutableExtension({
name: 'EntityAzurePullRequestsContent',
+4
View File
@@ -24,6 +24,10 @@ export const azurePipelinesEntityContentRouteRef = createRouteRef({
id: 'azure-pipelines-entity-content',
});
export const azureGitTagsEntityContentRouteRef = createRouteRef({
id: 'azure-git-tags-entity-content',
});
export const azurePullRequestsEntityContentRouteRef = createRouteRef({
id: 'azure-pull-requests-entity-content',
});