feat: Created intial display components for PullRequestsPage.
Signed-off-by: Marley Powell <Marley.Powell@exclaimer.com>
This commit is contained in:
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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 { Card, CardContent, CardHeader, Link } from '@material-ui/core';
|
||||
|
||||
import { Avatar } from '@backstage/core-components';
|
||||
import { PullRequest } from '../../../../api/types';
|
||||
import React from 'react';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
|
||||
const useStyles = makeStyles(
|
||||
theme => ({
|
||||
card: {
|
||||
backgroundColor:
|
||||
theme.palette.type === 'dark'
|
||||
? theme.palette.grey[700]
|
||||
: theme.palette.common.white,
|
||||
},
|
||||
cardHeaderSimplified: {
|
||||
paddingBottom: theme.spacing(2),
|
||||
},
|
||||
content: {
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
},
|
||||
}),
|
||||
{ name: 'PullRequestCard' },
|
||||
);
|
||||
|
||||
type PullRequestCardProps = {
|
||||
pullRequest: PullRequest;
|
||||
simplified?: boolean;
|
||||
};
|
||||
|
||||
export const PullRequestCard = ({
|
||||
pullRequest,
|
||||
simplified,
|
||||
}: PullRequestCardProps) => {
|
||||
const title = (
|
||||
<Link
|
||||
href={pullRequest.link}
|
||||
title={pullRequest.description}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{pullRequest.title}
|
||||
</Link>
|
||||
);
|
||||
|
||||
const avatar = (
|
||||
<Avatar
|
||||
displayName={pullRequest.createdBy.displayName}
|
||||
picture={pullRequest.createdBy.imageUrl}
|
||||
customStyles={{ width: '2.5rem', height: '2.5rem', fontSize: '1rem' }}
|
||||
/>
|
||||
);
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
return (
|
||||
<Card classes={{ root: classes.card }}>
|
||||
<CardHeader
|
||||
avatar={avatar}
|
||||
title={title}
|
||||
classes={{
|
||||
...(simplified && { root: classes.cardHeaderSimplified }),
|
||||
}}
|
||||
/>
|
||||
|
||||
{!simplified && <CardContent className={classes.content} />}
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@@ -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 { PullRequestCard } from './PullRequestCard';
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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 { PullRequestGridColumn } from '../PullRequestGridColumn';
|
||||
import { PullRequestGroup } from '../types';
|
||||
import React from 'react';
|
||||
import { styled } from '@material-ui/core';
|
||||
|
||||
const GridDiv = styled('div')(({ theme }) => ({
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
'& > *': {
|
||||
marginRight: theme.spacing(2),
|
||||
},
|
||||
'& > :last-of-type': {
|
||||
marginRight: 0,
|
||||
},
|
||||
}));
|
||||
|
||||
type PullRequestGridProps = {
|
||||
pullRequestGroups: PullRequestGroup[];
|
||||
};
|
||||
|
||||
export const PullRequestGrid = ({
|
||||
pullRequestGroups,
|
||||
}: PullRequestGridProps) => {
|
||||
return (
|
||||
<GridDiv>
|
||||
{pullRequestGroups.map(pullRequestGroup => (
|
||||
<PullRequestGridColumn pullRequestGroup={pullRequestGroup} />
|
||||
))}
|
||||
</GridDiv>
|
||||
);
|
||||
};
|
||||
@@ -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 { PullRequestGrid } from './PullRequestGrid';
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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 { Paper, Typography, styled, withStyles } from '@material-ui/core';
|
||||
|
||||
import { PullRequestCard } from '../PullRequestCard';
|
||||
import { PullRequestGroup } from '../types';
|
||||
import React from 'react';
|
||||
|
||||
const ColumnPaper = withStyles(theme => ({
|
||||
root: {
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
flex: 1,
|
||||
padding: theme.spacing(2),
|
||||
backgroundColor:
|
||||
theme.palette.type === 'dark'
|
||||
? theme.palette.grey[800]
|
||||
: theme.palette.grey[300],
|
||||
height: '100%',
|
||||
},
|
||||
}))(Paper);
|
||||
|
||||
const ColumnTitleDiv = styled('div')(({ theme }) => ({
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
marginBottom: theme.spacing(2),
|
||||
}));
|
||||
|
||||
export const PullRequestCardContainer = styled('div')(({ theme }) => ({
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
'& > *': {
|
||||
marginBottom: theme.spacing(2),
|
||||
},
|
||||
'& > :last-of-type': {
|
||||
marginBottom: 0,
|
||||
},
|
||||
}));
|
||||
|
||||
type PullRequestGridColumnProps = {
|
||||
pullRequestGroup: PullRequestGroup;
|
||||
};
|
||||
|
||||
export const PullRequestGridColumn = ({
|
||||
pullRequestGroup,
|
||||
}: PullRequestGridColumnProps) => {
|
||||
const columnTitle = (
|
||||
<ColumnTitleDiv>
|
||||
<Typography variant="h5">{pullRequestGroup.title}</Typography>
|
||||
</ColumnTitleDiv>
|
||||
);
|
||||
|
||||
const pullRequests = (
|
||||
<PullRequestCardContainer>
|
||||
{pullRequestGroup.pullRequests.map(pullRequest => (
|
||||
<PullRequestCard
|
||||
pullRequest={pullRequest}
|
||||
simplified={pullRequestGroup.simplified}
|
||||
/>
|
||||
))}
|
||||
</PullRequestCardContainer>
|
||||
);
|
||||
|
||||
return (
|
||||
<ColumnPaper>
|
||||
{columnTitle}
|
||||
{pullRequests}
|
||||
</ColumnPaper>
|
||||
);
|
||||
};
|
||||
+17
@@ -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 { PullRequestGridColumn } from './PullRequestGridColumn';
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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 { PullRequest } from '../../../api/types';
|
||||
|
||||
export interface PullRequestGroup {
|
||||
title: string;
|
||||
pullRequests: PullRequest[];
|
||||
simplified?: boolean;
|
||||
}
|
||||
@@ -13,8 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export {
|
||||
azureDevOpsPlugin,
|
||||
EntityAzurePipelinesContent,
|
||||
isAzureDevOpsAvailable,
|
||||
AzurePullRequestsPage,
|
||||
} from './plugin';
|
||||
|
||||
export * from './components/AzurePullRequestsIcon';
|
||||
|
||||
Reference in New Issue
Block a user