Skip to content

Commit

Permalink
Sync docker stars client
Browse files Browse the repository at this point in the history
  • Loading branch information
pradel committed Oct 27, 2016
1 parent 313937c commit 7804165
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
15 changes: 12 additions & 3 deletions client/settings/components/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ class Settings extends Component {
.catch(err => this.setState({ error: err.message }));
}

handleSyncUserDockerStars = (e) => {
e.preventDefault();
const { syncUserDockerStars } = this.props;
this.setState({ success: '', error: '' });
syncUserDockerStars()
.then(() => this.setState({ success: 'Docker stars synced' }))
.catch(err => this.setState({ error: err.message }));
}

handleDeleteAccount = () => {
// TODO make a clean material modal
const { deleteUserAccount } = this.props;
Expand Down Expand Up @@ -145,9 +154,8 @@ class Settings extends Component {
<Button type="submit">Submit</Button>
</form>
<Text className="content">
Last star sync:
{user.docker && user.docker.lastSync ? <TimeAgo datetime={new Date(user.docker.lastSync)} /> : ' No sync yet'}
<Button onClick={this.handleToggleShowMore}>Sync docker stars</Button>
Last star sync: {user.docker && user.docker.lastSync ? <TimeAgo datetime={new Date(user.docker.lastSync)} /> : ' No sync yet'}
<Button onClick={this.handleSyncUserDockerStars}>Sync docker stars</Button>
</Text>
<div className="content show-more">
{showMore ?
Expand All @@ -166,6 +174,7 @@ Settings.propTypes = {
editUserEmail: PropTypes.func.isRequired,
addDockerAccount: PropTypes.func.isRequired,
syncUserGithubStars: PropTypes.func.isRequired,
syncUserDockerStars: PropTypes.func.isRequired,
deleteUserAccount: PropTypes.func.isRequired,
};

Expand Down
23 changes: 23 additions & 0 deletions client/settings/containers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const syncUserGithubStarsMutation = gql`
github {
lastSync
}
docker {
lastSync
}
}
}
`;
Expand All @@ -82,6 +85,26 @@ SettingsWithMutation = graphql(syncUserGithubStarsMutation, {
}),
})(SettingsWithMutation);

const syncUserDockerStarsMutation = gql`
mutation syncUserDockerStars {
syncUserDockerStars {
id
github {
lastSync
}
docker {
lastSync
}
}
}
`;

SettingsWithMutation = graphql(syncUserDockerStarsMutation, {
props: ({ mutate }) => ({
syncUserDockerStars: () => mutate({}),
}),
})(SettingsWithMutation);

const deleteUserAccountMutation = gql`
mutation deleteUserAccount {
deleteUserAccount
Expand Down

0 comments on commit 7804165

Please sign in to comment.