Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ key | required | description
y: 0
```

## Project Description

> Show GitLab project info with the description and different layout.

![Gitlab project](preview/project_description.png)

### parameters

key | required | description
----------|----------|--------------------------
`project` | yes | *ID or NAMESPACE/PROJECT_NAME of a project*

### usage

``` yaml
- extension: gitlab
widget: ProjectDescription
project: gitlab-org/gitlab-ce
columns: 1
rows: 2
x: 0
y: 0
```

## Project Members

> Show GitLab project members.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"lint-staged": "^7.2.0",
"nivo": "^0.12.0",
"nock": "^9.0.14",
"prettier": "^1.14.0",
"prettier": "1.18.2",
"react": "^16.4.0",
"react-dom": "^16.4.0",
"react-test-renderer": "^16.4.0",
Expand Down
Binary file added preview/project_description.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions src/components/ProjectDescription.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import {
TrapApiError,
Widget,
WidgetBody,
WidgetLoader,
typography,
WidgetAvatar,
} from '@mozaik/ui'

const AVATAR_SIZE = '12vmin'

const Container = styled.div`
display: flex;
flex-direction: column;
height: 100%;
`

const Header = styled.div`
flex: 1;
display: flex;
align-items: center;
justify-content: center;
`

const AvatarPlaceholder = styled.span`
width: ${AVATAR_SIZE};
height: ${AVATAR_SIZE};
display: flex;
align-items: center;
justify-content: center;
text-transform: uppercase;
color: ${props => props.theme.colors.textHighlight};
background: ${props => props.theme.colors.unknown};
${props => typography(props.theme, 'display')} font-size: 6vmin;
`

const Description = styled.div`
display: flex;
align-items: center;
justify-content: center;
white-space: pre;
color: ${props => props.theme.colors.textHighlight};
margin: 1vmin 0 3vmin;
${props => typography(props.theme, 'default', 'strong')};
`

export default class Project extends Component {
static propTypes = {
project: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
apiData: PropTypes.shape({
name: PropTypes.string.isRequired,
description: PropTypes.string.isRequired,
name_with_namespace: PropTypes.string.isRequired,
visibility: PropTypes.string.isRequired,
avatar_url: PropTypes.string,
}),
apiError: PropTypes.object,
theme: PropTypes.object.isRequired,
}

static getApiRequest({ project }) {
return {
id: `gitlab.project.${project}`,
params: { project },
}
}

render() {
const { apiData: project, apiError } = this.props

let body = <WidgetLoader />
if (project) {
let avatar
if (project.avatar_url !== null) {
avatar = <img src={project.avatar_url} alt={project.name_with_namespace} />
} else {
avatar = <AvatarPlaceholder>{project.name[0]}</AvatarPlaceholder>
}

body = (
<Container>
<Header>
<WidgetAvatar size={AVATAR_SIZE}>{avatar}</WidgetAvatar>
</Header>
<Description>{project.description}</Description>
</Container>
)
}

return (
<Widget>
<WidgetBody isHeaderless={true}>
<TrapApiError error={apiError}>{body}</TrapApiError>
</WidgetBody>
</Widget>
)
}
}
2 changes: 2 additions & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Project from './Project'
import ProjectDescription from './ProjectDescription'
import ProjectMembers from './ProjectMembers'
import ProjectContributors from './ProjectContributors'
import JobHistory from './JobHistory'
Expand All @@ -11,6 +12,7 @@ import * as labels from './labels'

export default {
Project,
ProjectDescription,
ProjectMembers,
ProjectContributors,
JobHistory,
Expand Down
38 changes: 19 additions & 19 deletions test/components/__snapshots__/Branches.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

3 years ago
4 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -244,7 +244,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

3 years ago
4 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -333,7 +333,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

2 years ago
3 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -422,7 +422,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

2 years ago
3 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -511,7 +511,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

a year ago
2 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -600,7 +600,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

a year ago
2 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -689,7 +689,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

2 years ago
3 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -778,7 +778,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

2 years ago
3 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -867,7 +867,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

2 years ago
3 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -956,7 +956,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

2 years ago
3 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -1045,7 +1045,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

2 years ago
3 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -1223,7 +1223,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

a year ago
2 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -1312,7 +1312,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

a year ago
2 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -1401,7 +1401,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

10 months ago
2 years ago
</span>
</div>
</div>
Expand Down Expand Up @@ -1490,7 +1490,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

6 months ago
a year ago
</span>
</div>
</div>
Expand Down Expand Up @@ -1579,7 +1579,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

6 months ago
a year ago
</span>
</div>
</div>
Expand Down Expand Up @@ -1668,7 +1668,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

6 months ago
a year ago
</span>
</div>
</div>
Expand Down Expand Up @@ -1757,7 +1757,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

6 months ago
a year ago
</span>
</div>
</div>
Expand Down Expand Up @@ -1846,7 +1846,7 @@ exports[`should render as expected 1`] = `
/>
</svg>

5 months ago
a year ago
</span>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4761,9 +4761,10 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"

prettier@^1.14.0:
version "1.14.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.14.0.tgz#847c235522035fd988100f1f43cf20a7d24f9372"
prettier@1.18.2:
version "1.18.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==

pretty-format@^23.2.0:
version "23.2.0"
Expand Down