Skip to content

Commit

Permalink
Streamline ownership confirmation during sign-up
Browse files Browse the repository at this point in the history
  • Loading branch information
cychu42 authored and humphd committed Dec 10, 2022
1 parent abd3ca4 commit db8f43f
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 66 deletions.
6 changes: 1 addition & 5 deletions src/web/app/src/components/SignUp/Forms/BlogFeeds.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import RSSFeeds from './RSSFeeds';
import formModels from '../Schema/FormModel';

const { blogs, allBlogs, blogUrl, blogOwnership } = formModels;
const { blogs, allBlogs, blogUrl } = formModels;

const BlogFeeds = () => {
return (
Expand All @@ -19,10 +19,6 @@ const BlogFeeds = () => {
selected: blogs.name as any,
discovered: allBlogs.name as any,
}}
agreement={{
name: blogOwnership.name,
label: blogOwnership.label,
}}
input={{
name: blogUrl.name,
label: blogUrl.label,
Expand Down
6 changes: 1 addition & 5 deletions src/web/app/src/components/SignUp/Forms/ChannelFeeds.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import RSSFeeds from './RSSFeeds';
import formModels from '../Schema/FormModel';

const { channels, allChannels, channelUrl, channelOwnership } = formModels;
const { channels, allChannels, channelUrl } = formModels;

const ChannelFeeds = () => {
return (
Expand All @@ -14,10 +14,6 @@ const ChannelFeeds = () => {
selected: channels.name as any,
discovered: allChannels.name as any,
}}
agreement={{
name: channelOwnership.name,
label: channelOwnership.label,
}}
input={{
name: channelUrl.name,
label: channelUrl.label,
Expand Down
9 changes: 2 additions & 7 deletions src/web/app/src/components/SignUp/Forms/GitHubAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { connect } from 'formik';

import { SignUpForm } from '../../../interfaces';
import formModels from '../Schema/FormModel';
import { TextInput, CheckBoxInput } from '../FormFields';
import { TextInput } from '../FormFields';
import PostAvatar from '../../Posts/PostAvatar';

const { githubUsername, github, githubOwnership } = formModels;
const { githubUsername, github } = formModels;

const useStyles = makeStyles((theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -178,11 +178,6 @@ const GitHubAccount = connect<{}, SignUpForm>((props) => {
</div>
)}
</div>
<CheckBoxInput
label={githubOwnership.label}
name={githubOwnership.name}
checked={values.githubOwnership}
/>
</div>
</div>
);
Expand Down
12 changes: 1 addition & 11 deletions src/web/app/src/components/SignUp/Forms/RSSFeeds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Checkbox from '@material-ui/core/Checkbox';
import { feedDiscoveryServiceUrl } from '../../../config';
import useAuth from '../../../hooks/use-auth';
import { SignUpForm, DiscoveredFeed, DiscoveredFeeds } from '../../../interfaces';
import { TextInput, CheckBoxInput } from '../FormFields';
import { TextInput } from '../FormFields';

const useStyles = makeStyles((theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -157,10 +157,6 @@ type RSSFeedsFormProps = {
name: string;
label: string;
};
agreement: {
name: string;
label: string;
};
noFeedsSelected?: string;
};

Expand All @@ -173,7 +169,6 @@ const RSSFeeds = connect<RSSFeedsFormProps, SignUpForm>(
buttonText,
helperText,
noFeedsSelected,
agreement,
input,
formik,
}) => {
Expand Down Expand Up @@ -319,11 +314,6 @@ const RSSFeeds = connect<RSSFeedsFormProps, SignUpForm>(
</div>
</div>
</div>
<CheckBoxInput
label={agreement.label}
name={agreement.name}
checked={values[agreement.name as keyof SignUpForm] as boolean}
/>
</div>
</div>
);
Expand Down
4 changes: 4 additions & 0 deletions src/web/app/src/components/SignUp/Forms/Review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ const Review = connect<{ accountError: string | undefined }, SignUpForm>((props)
</div>
</div>
</div>
<div>
By submitting these information, you confirm you are the owner and/or maintainer of the
accounts entered.
</div>
<FormHelperText error>{props.accountError}</FormHelperText>
</div>
</div>
Expand Down
15 changes: 0 additions & 15 deletions src/web/app/src/components/SignUp/Schema/FormModel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ export default {
label: 'Github username',
requiredErrorMsg: 'Github account is required',
},
githubOwnership: {
name: 'githubOwnership',
label: 'I declare I’m the owner and the maintainer of this GitHub account',
invalidErrorMsg: 'You must be the owner of this account',
},
blogUrl: {
name: 'blogUrl',
label: 'Blog URL(s), seperated by spaces',
Expand All @@ -59,14 +54,4 @@ export default {
allChannels: {
name: 'allChannels',
},
blogOwnership: {
name: 'blogOwnership',
label: 'I declare I’m the owner and the maintainer of this blog account',
invalidErrorMsg: 'You must be the owner of this account',
},
channelOwnership: {
name: 'channelOwnership',
label: 'I declare I’m the owner and the maintainer of the channel(s) above',
invalidErrorMsg: 'You must be the owner of the channel(s)',
},
};
15 changes: 1 addition & 14 deletions src/web/app/src/components/SignUp/Schema/FormSchema.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { string, array, object, boolean } from 'yup';
import { string, array, object } from 'yup';

import formModels from './FormModel';

Expand All @@ -13,15 +13,12 @@ const {
displayName,
githubUsername,
github,
githubOwnership,
blogs,
allBlogs,
channels,
allChannels,
blogUrl,
channelUrl,
blogOwnership,
channelOwnership,
} = formModels;

// Each signup step has one validation schema
Expand All @@ -44,30 +41,20 @@ export default [
avatarUrl: string().url().required(),
})
.required(github.invalidErrorMsg),
[githubOwnership.name]: boolean().test(
'agreed',
githubOwnership.invalidErrorMsg,
(val) => !!val
),
}),

// Third step we collect the user blog and the RSSfeeds from it.
object().shape({
[blogUrl.name]: string(),
[blogs.name]: array().of(DiscoveredFeed).min(1, blogs.requiredErrorMsg),
[allBlogs.name]: array().of(DiscoveredFeed),
[blogOwnership.name]: boolean().test('agreed', blogOwnership.invalidErrorMsg, (val) => !!val),
}),

// Fourth step we collect the user YouTube/Twitch channels and the RSSfeeds from it.
object().shape({
[channelUrl.name]: string(),
[channels.name]: array().of(DiscoveredFeed),
[allChannels.name]: array().of(DiscoveredFeed),
[channelOwnership.name]: boolean().when(allChannels.name, {
is: (val: {}[]) => !!val.length,
then: (shema) => shema.test('agreed', channelOwnership.invalidErrorMsg, (val) => !!val),
}),
}),

// Reviewing step has no validation logic. We just display all data that we collected.
Expand Down
3 changes: 0 additions & 3 deletions src/web/app/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ export type SignUpForm = {
avatarUrl: string;
};
githubUsername: string;
githubOwnership: boolean;
blogUrl: string;
channelUrl: string;
blogs: DiscoveredFeed[];
allBlogs: DiscoveredFeed[];
channels: DiscoveredFeed[];
allChannels: DiscoveredFeed[];
blogOwnership: boolean;
channelOwnership: boolean;
};

export type ThemeName = 'light-default' | 'light-high-contrast' | 'dark-default' | 'dark-dim';
Expand Down
6 changes: 0 additions & 6 deletions src/web/app/src/pages/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,12 @@ const {
displayName,
githubUsername,
github,
githubOwnership,
blogUrl,
blogs,
channels,
allBlogs,
allChannels,
email,
blogOwnership,
channelOwnership,
} = formModels;

const useStyles = makeStyles((theme: Theme) =>
Expand Down Expand Up @@ -324,7 +321,6 @@ const SignUpPage = () => {
[displayName.name]: user?.name,
[email.name]: user?.email,
[githubUsername.name]: '',
[githubOwnership.name]: false,
[github.name]: {
username: '',
avatarUrl: '',
Expand All @@ -334,8 +330,6 @@ const SignUpPage = () => {
[allBlogs.name]: [] as SignUpForm['allBlogs'],
[channels.name]: [] as SignUpForm['channels'],
[allChannels.name]: [] as SignUpForm['allChannels'],
[blogOwnership.name]: false,
[channelOwnership.name]: false,
} as SignUpForm
}
>
Expand Down

0 comments on commit db8f43f

Please sign in to comment.