Skip to content

Commit

Permalink
Merge branch 'develop' into fix/reviewers-list
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridrikhson committed Sep 13, 2019
2 parents 058d3d2 + 034fc55 commit 6535f32
Show file tree
Hide file tree
Showing 24 changed files with 289 additions and 111 deletions.
9 changes: 8 additions & 1 deletion client/src/components/IssueComments/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ IssueComments.propTypes = {
repositoryId: PropTypes.string.isRequired,
userImg: PropTypes.string,
userName: PropTypes.string.isRequired,
owner: PropTypes.string.isRequired,
reponame: PropTypes.string.isRequired,
fetchCurrentRepo: PropTypes.func.isRequired,
history: PropTypes.shape({
push: PropTypes.func.isRequired
}).isRequired
Expand All @@ -415,7 +418,11 @@ const mapStateToProps = ({
},
currentRepo: {
repository: {
currentRepoInfo: { id: repositoryId, name: reponame, user: { username: owner } }
currentRepoInfo: {
id: repositoryId,
name: reponame,
user: { username: owner }
}
}
}
}) => ({
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/RepositoryHeader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const RepositoryHeader = ({
activePage,
baseUrl,
history,
isPublic
isPublic,
branch
}) => {
const [isStar, setIsStar] = useState(Boolean(stars.find(star => star.user.id === userId)));
const [starCount, setStarCount] = useState(starsCount);
Expand Down Expand Up @@ -121,7 +122,7 @@ const RepositoryHeader = ({
</div>
<div className="ui top attached tabular menu">
<div className={`${activeTab === 'code' && 'active'} item`}>
<Link to={baseUrl}>
<Link to={`${baseUrl}/tree/${branch}`}>
<Icon name="code" /> Code
</Link>
</div>
Expand Down Expand Up @@ -173,6 +174,7 @@ RepositoryHeader.propTypes = {
})
})
}).isRequired,
branch: PropTypes.string,
match: PropTypes.exact({
params: PropTypes.object.isRequired,
isExact: PropTypes.bool.isRequired,
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/RepositoryItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ class RepositoryItem extends React.Component {
<h3>
{this.getRepoLink({ username, name, type })}
{this.renderOrignalRepoLink()}
{this.getDescription()}
{!isPublic && <span className={styles.repoTypeLabel}>{repoType}</span>}
{this.getDescription()}
</h3>
<div className="repo-info">
{language && (
Expand Down
5 changes: 3 additions & 2 deletions client/src/components/StatusModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { setStatus, getStatus } from '../../services/userService';
import styles from './styles.module.scss';

const StatusModal = ({ showStatusModal, hideModal, username }) => {
const defaultStatus = 'defaultValue';
const [status, setStatusText] = useState('');
const [prevStatus, setPrevStatusText] = useState('0');
if (prevStatus && username) {
const [prevStatus, setPrevStatusText] = useState(defaultStatus);
if (prevStatus === defaultStatus && username) {
getStatus(username).then(({ status }) => setPrevStatusText(status));
}

Expand Down
6 changes: 5 additions & 1 deletion client/src/containers/CreateIssuePage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ const mapStateToProps = ({
issuesData: { issues },
currentRepo: {
repository: {
currentRepoInfo: { id, name, user: { username: owner } }
currentRepoInfo: {
id,
name,
user: { username: owner }
}
}
}
}) => ({
Expand Down
25 changes: 17 additions & 8 deletions client/src/containers/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ const SearchInp = () => {
const [isLoading, setLoading] = useState(false);
const [timeout, changeTimeout] = useState(null);

const getIcon = (type) => {
const getIcon = type => {
switch (type.toLowerCase()) {
case 'repo': return Repo;
case 'user': return Person;
case 'org': return Organization;
default: return null;
case 'repo':
return Repo;
case 'user':
return Person;
case 'org':
return Organization;
default:
return null;
}
};

Expand All @@ -42,7 +46,7 @@ const SearchInp = () => {
onClick={() => {
setText('');
setResults([]);
window.location.href = `${window.location.origin}${endpoint}`;
window.location.href = `${window.location.origin}${endpoint}`;
}}
>
<p className={styles.searchItem}>
Expand All @@ -51,7 +55,7 @@ const SearchInp = () => {
</p>
</div>
);
};
};

const handleSearchChange = async (e, { value }) => {
if (!value) {
Expand All @@ -64,9 +68,10 @@ const SearchInp = () => {
clearTimeout(timeout);
changeTimeout(null);
}
const [user, repo] = value.split('/');
changeTimeout(
setTimeout(async () => {
const results = (await searchService.find(value)).map(({ type, username, reponame }) => ({
const results = (await searchService.find(user, repo)).map(({ type, username, reponame }) => ({
content: [type, username, reponame]
}));
setResults(results);
Expand Down Expand Up @@ -320,6 +325,10 @@ HeaderDesktopAuth.propTypes = {
})
};

SearchInp.propTypes = {
content: PropTypes.array.isRequired
};

const Header = ({ isAuthorized, username, imgUrl, status, fetchCurrentUser }) => {
return isAuthorized
? WithSidebar(HeaderDesktopAuth, { username, imgUrl, status, fetchCurrentUser })
Expand Down
12 changes: 0 additions & 12 deletions client/src/containers/SettingsProfile/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,6 @@ class SettingsProfile extends Component {
<div>Your name may appear around Depot where you contribute or are mentioned. You can remove it at any time.</div>
),
email: <div>You cannot change your email at this time.</div>,
bio: (
<div>
You can @<strong>mention</strong> other users and organizations to link to them.
</div>
),
company: (
<div>
You can @<strong>mention</strong> your company’s Depot organization to link it.
</div>
),
disclaimer: (
<div>
All of the fields on this page are optional and can be deleted at any time, and by filling them out, you're
Expand Down Expand Up @@ -204,7 +194,6 @@ class SettingsProfile extends Component {
<Header as="h4">Bio</Header>
<Field name="bio" render={this.renderTextArea} />
<InputError name="bio" />
<div className={styles.note}>{this.NOTES.bio}</div>

<Header as="h4">URL</Header>
<Field type="text" name="url" render={this.renderField} />
Expand All @@ -213,7 +202,6 @@ class SettingsProfile extends Component {
<Header as="h4">Company</Header>
<Field type="text" name="company" render={this.renderField} />
<InputError name="company" />
<div className={styles.note}>{this.NOTES.company}</div>

<Divider />

Expand Down
129 changes: 82 additions & 47 deletions client/src/containers/StargazersPage/index.jsx
Original file line number Diff line number Diff line change
@@ -1,66 +1,101 @@
import React from 'react';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
import moment from 'moment';

import Octicon, { getIconByName } from '@primer/octicons-react';
import { Segment, Header, Image, Loader } from 'semantic-ui-react';
import { Segment, Header, Image, Loader, Container, Divider } from 'semantic-ui-react';
import { getUserImgLink } from '../../helpers/imageHelper';
import { getStargazersList } from '../../services/repositoryService';

import styles from './styles.module.scss';

const StargazersPage = ({ stars, loading }) => {
return loading ? (
<div>
<Loader />
</div>
) : (
<Segment basic>
<Header as="h2" className={styles.stargazerHeader}>
Stargazers
</Header>
<div className={styles.stargazersGrid}>
{stars.map(({ user: { username, imgUrl, location, createdAt } }, index) => (
<div key={index} className={styles.stargazerBox}>
<Image src={imgUrl} width="75" height="75" className={styles.stargazerImage} />
<div className={styles.stargazerInfo}>
<Link className={styles.profileLink} to={`/${username}`}>
{username}
</Link>
{location ? (
<>
<Octicon className={styles.icon} icon={getIconByName('location')} />
<span className={styles.stargazerDate}>{location}</span>
</>
) : (
<>
<Octicon className={styles.icon} icon={getIconByName('clock')} />
<span className={styles.stargazerDate}>Joined on {moment(createdAt).format('MMM DD, YYYY')}</span>
</>
)}
</div>
</div>
))}
class StargazersPage extends Component {
constructor(props) {
super(props);
this.state = {
stars: {},
loading: true
};
}

componentDidMount() {
this.getStargazersList();
}

getStargazersList() {
const { repositoryId } = this.props;
getStargazersList(repositoryId).then(stars => {
this.setState({ stars, loading: false });
});
}

render() {
const { loading, stars } = this.state;

return loading ? (
<div>
<Loader />
</div>
</Segment>
);
};
) : (
<Segment basic>
{stars.length ? (
<>
<Header as="h2" className={styles.stargazerHeader}>
Stargazers
</Header>
<div className={styles.stargazersGrid}>
{stars.map(({ user: { username, imgUrl, location, createdAt } }, id) => (
<div key={id} className={styles.stargazerBox}>
<Image src={getUserImgLink(imgUrl)} width="75" height="75" className={styles.stargazerImage} />
<div className={styles.stargazerInfo}>
<Link className={styles.profileLink} to={`/${username}`}>
{username}
</Link>
{location ? (
<>
<Octicon className={styles.icon} icon={getIconByName('location')} />
<span className={styles.stargazerDate}>{location}</span>
</>
) : (
<>
<Octicon className={styles.icon} icon={getIconByName('clock')} />
<span className={styles.stargazerDate}>
Joined on {moment(createdAt).format('MMM DD, YYYY')}
</span>
</>
)}
</div>
</div>
))}
</div>
</>
) : (
<Container textAlign="center">
<Octicon className={styles.icon} icon={getIconByName('star')} />
<Divider hidden />
<Header as="h2">Be the first to star this repository.</Header>
<Segment basic>
<a href="https://help.github.com/articles/about-stars">Learn more </a>about how starring works on Depot.
</Segment>
</Container>
)}
</Segment>
);
}
}

StargazersPage.propTypes = {
repoId: PropTypes.string.isRequired,
stars: PropTypes.array.isRequired,
loading: PropTypes.bool.isRequired
repositoryId: PropTypes.string.isRequired
};

const mapStateToProps = ({
currentRepo: {
repository: {
currentRepoInfo: { stars }
},
loading
currentRepoInfo: { id }
}
}
}) => ({
stars,
loading
});
}) => ({ repositoryId: id });

export default connect(mapStateToProps)(StargazersPage);
Loading

0 comments on commit 6535f32

Please sign in to comment.