Skip to content

Commit c12f0cd

Browse files
committed
[#915] Update copy on Settings page
1 parent 5edee7e commit c12f0cd

File tree

4 files changed

+50
-7
lines changed

4 files changed

+50
-7
lines changed

client/modules/User/components/SocialAuthButton.jsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ const labels = {
1717
google: 'Login with Google'
1818
};
1919

20+
const linkLabels = {
21+
github: {
22+
connect: 'Connect GitHub Account',
23+
connected: 'Re-link GitHub Account'
24+
},
25+
google: {
26+
connect: 'Connect Google Account',
27+
connected: 'Re-link Google Account'
28+
}
29+
};
30+
2031
const icons = {
2132
github: GithubIcon,
2233
google: GoogleIcon
@@ -31,22 +42,35 @@ const StyledButton = styled(Button)`
3142
width: ${remSize(300)};
3243
`;
3344

34-
function SocialAuthButton({ service }) {
45+
function SocialAuthButton({ service, link, connected }) {
3546
const ServiceIcon = icons[service];
47+
let label;
48+
if (link) {
49+
label = connected ? linkLabels[service].connected : linkLabels[service].connect;
50+
} else {
51+
label = labels[service];
52+
}
3653
return (
3754
<StyledButton
3855
iconBefore={<ServiceIcon aria-label={`${service} logo`} />}
3956
href={authUrls[service]}
4057
>
41-
{labels[service]}
58+
{label}
4259
</StyledButton>
4360
);
4461
}
4562

4663
SocialAuthButton.services = services;
4764

4865
SocialAuthButton.propTypes = {
49-
service: PropTypes.oneOf(['github', 'google']).isRequired
66+
service: PropTypes.oneOf(['github', 'google']).isRequired,
67+
link: PropTypes.bool,
68+
connected: PropTypes.bool
69+
};
70+
71+
SocialAuthButton.defaultProps = {
72+
link: false,
73+
connected: false
5074
};
5175

5276
export default SocialAuthButton;

client/modules/User/pages/AccountView.jsx

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,37 @@ import APIKeyForm from '../components/APIKeyForm';
1313
import Nav from '../../../components/Nav';
1414

1515
function SocialLoginPanel(props) {
16+
const { user } = props;
1617
return (
1718
<React.Fragment>
1819
<AccountForm {...props} />
1920
<h2 className="form-container__divider">Social Login</h2>
2021
<p className="account__social-text">
21-
Use your GitHub or Google account to log into the p5.js Web Editor.
22+
Use your GitHub or Google account to login to the p5.js Web Editor.
2223
</p>
2324
<div className="account__social-stack">
24-
<SocialAuthButton service={SocialAuthButton.services.github} />
25-
<SocialAuthButton service={SocialAuthButton.services.google} />
25+
<SocialAuthButton
26+
service={SocialAuthButton.services.github}
27+
link
28+
connected={!!user.github}
29+
/>
30+
<SocialAuthButton
31+
service={SocialAuthButton.services.google}
32+
link
33+
connected={!!user.google}
34+
/>
2635
</div>
2736
</React.Fragment>
2837
);
2938
}
3039

40+
SocialLoginPanel.propTypes = {
41+
user: PropTypes.shape({
42+
github: PropTypes.string,
43+
google: PropTypes.string
44+
}).isRequired
45+
};
46+
3147
class AccountView extends React.Component {
3248
componentDidMount() {
3349
document.body.className = this.props.theme;

server/controllers/user.controller.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export function userResponse(user) {
1818
apiKeys: user.apiKeys,
1919
verified: user.verified,
2020
id: user._id,
21-
totalSize: user.totalSize
21+
totalSize: user.totalSize,
22+
github: user.github,
23+
google: user.google
2224
};
2325
}
2426

server/models/user.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const userSchema = new Schema({
5050
verifiedToken: String,
5151
verifiedTokenExpires: Date,
5252
github: { type: String },
53+
google: { type: String },
5354
email: { type: String, unique: true },
5455
tokens: Array,
5556
apiKeys: { type: [apiKeySchema] },

0 commit comments

Comments
 (0)