Skip to content

Commit e374360

Browse files
authored
Merge branch 'main' into update-landing-909
2 parents ae50198 + 4d000a0 commit e374360

File tree

4 files changed

+113
-65
lines changed

4 files changed

+113
-65
lines changed

cypress/integration/pages/add-org.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,14 @@ describe('Add Organization Workflow', () => {
227227
cy.get('[data-cy=org-country-input]').should('contain', 'Country');
228228
});
229229
});
230+
231+
it('should contain accessible attributes', () => {
232+
cy.get('#container-affiliated').within(() => {
233+
cy.get('#add-org-link').click();
234+
});
235+
cy.get('[class*=MuiDialog-container]').within(() => {
236+
cy.get('[class*=MuiDialog-paper]').invoke('attr', 'ariaLabel').should('eq', 'Add Organization Modal');
237+
});
238+
});
239+
230240
});

src/pages/TagGenerator/AddOrgForm/StepOne.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const StepOne = (props) => {
6464
error={!!orgNameApiErr}
6565
helperText={orgNameApiErr}
6666
label='Organization Name'
67+
inputProps={{ 'aria-label': 'Organization Name' }}
6768
onChange={(event) => {
6869
props.onOrgName(event.target.value);
6970
props.setApiErrors({ ...props.apiErrors, name: '' });

src/pages/TagGenerator/AddOrgForm/index.js

Lines changed: 96 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const AddOrgForm = React.forwardRef(({ open, onClose }, ref) => {
2626
const [websiteUrl, setWebsiteUrl] = useState('');
2727

2828
useEffect(() => {
29-
axios.get(`${process.env.REACT_APP_API_URL}/api/organizations/`)
29+
axios
30+
.get(`${process.env.REACT_APP_API_URL}/api/organizations/`)
3031
.then((response) => {
3132
setParentOrgList([{ id: '', name: '' }, ...response.data]);
3233
});
@@ -68,39 +69,64 @@ const AddOrgForm = React.forwardRef(({ open, onClose }, ref) => {
6869

6970
// eslint-disable-next-line complexity
7071
const handleSubmit = async () => {
71-
const updatedGithubUrl = githubUrl.indexOf('https://') < 0 ? 'https://' + githubUrl : githubUrl;
72-
const updatedWebsiteUrl = websiteUrl.indexOf('http://') < 0 && websiteUrl.indexOf('https://') < 0
73-
? 'https://' + websiteUrl : websiteUrl;
72+
const updatedGithubUrl =
73+
githubUrl.indexOf('https://') < 0 ? 'https://' + githubUrl : githubUrl;
74+
const updatedWebsiteUrl =
75+
websiteUrl.indexOf('http://') < 0 && websiteUrl.indexOf('https://') < 0
76+
? 'https://' + websiteUrl
77+
: websiteUrl;
7478
const orgProps = {
7579
name: orgName,
7680
github_url: updatedGithubUrl,
7781
website_url: updatedWebsiteUrl,
7882
organization_email: orgEmail,
7983
org_tag: githubTag,
8084
};
81-
if (city) { orgProps.city = city }
82-
if (stateProvCo) { orgProps.state = stateProvCo }
83-
if (country.label) { orgProps.country = country.label }
85+
if (city) {
86+
orgProps.city = city;
87+
}
88+
if (stateProvCo) {
89+
orgProps.state = stateProvCo;
90+
}
91+
if (country.label) {
92+
orgProps.country = country.label;
93+
}
8494
if (parentOrgName) {
8595
orgProps.parent_organization_name = parentOrgName;
8696
} else if (parentOrg.id) {
8797
orgProps.parent_organization = parentOrg.id;
8898
}
8999
if (facebookUrl) {
90-
orgProps.facebook_url = facebookUrl.indexOf('https://') < 0 ? 'https://' + facebookUrl : facebookUrl;
100+
orgProps.facebook_url =
101+
facebookUrl.indexOf('https://') < 0
102+
? 'https://' + facebookUrl
103+
: facebookUrl;
91104
}
92105
if (meetupUrl) {
93-
orgProps.meetup_url = meetupUrl.indexOf('https://') < 0 ? 'https://' + meetupUrl : meetupUrl;
106+
orgProps.meetup_url =
107+
meetupUrl.indexOf('https://') < 0 ? 'https://' + meetupUrl : meetupUrl;
94108
}
95109
if (twitterUrl) {
96-
orgProps.twitter_url = twitterUrl.indexOf('https://') < 0 ? 'https://' + twitterUrl : twitterUrl;
110+
orgProps.twitter_url =
111+
twitterUrl.indexOf('https://') < 0
112+
? 'https://' + twitterUrl
113+
: twitterUrl;
97114
}
98115
try {
99-
await axios.post(`${process.env.REACT_APP_API_URL}/api/organizations/`, orgProps);
116+
await axios.post(
117+
`${process.env.REACT_APP_API_URL}/api/organizations/`,
118+
orgProps
119+
);
100120
setStep(2);
101121
} catch (error) {
102122
const errors = error.response.data;
103-
if (errors.name || errors.github_url || errors.website_url || errors.organization_email || errors.org_tag) {
123+
if (
124+
errors.name ||
125+
errors.github_url ||
126+
errors.website_url ||
127+
errors.organization_email ||
128+
errors.org_tag
129+
) {
104130
setStep(0);
105131
} else {
106132
setStep(1);
@@ -116,61 +142,75 @@ const AddOrgForm = React.forwardRef(({ open, onClose }, ref) => {
116142
} else {
117143
setParentOrgName(org);
118144
}
119-
}
145+
};
120146

121147
const renderStep = () => {
122-
const stepOne = <StepOne
123-
apiErrors={apiErrors}
124-
setApiErrors={setApiErrors}
125-
orgEmail={orgEmail}
126-
onOrgEmail={setOrgEmail}
127-
orgName={orgName}
128-
onOrgName={setOrgName}
129-
websiteUrl={websiteUrl}
130-
onWebsiteUrl={setWebsiteUrl}
131-
githubUrl={githubUrl}
132-
onGithubUrl={setGithubUrl}
133-
githubTag={githubTag}
134-
onGithubTag={setGithubTag}
135-
parentOrg={parentOrg}
136-
onParentOrg={handleParentOrg}
137-
parentOrgList={parentOrgList}
138-
onCancel={handleClose}
139-
onNext={handleNext}
140-
/>;
141-
const stepTwo = <StepTwo
142-
apiErrors={apiErrors}
143-
setApiErrors={setApiErrors}
144-
facebookUrl={facebookUrl}
145-
onFacebookUrl={setFacebookUrl}
146-
twitterUrl={twitterUrl}
147-
onTwitterUrl={setTwitterUrl}
148-
meetupUrl={meetupUrl}
149-
onMeetupUrl={setMeetupUrl}
150-
city={city}
151-
onCity={setCity}
152-
stateProvCo={stateProvCo}
153-
onStateProvCo={setStateProvCo}
154-
country={country}
155-
onCountryChange={setCountry}
156-
onPrev={handlePrev}
157-
onSubmit={handleSubmit}
158-
/>;
148+
const stepOne = (
149+
<StepOne
150+
apiErrors={apiErrors}
151+
setApiErrors={setApiErrors}
152+
orgEmail={orgEmail}
153+
onOrgEmail={setOrgEmail}
154+
orgName={orgName}
155+
onOrgName={setOrgName}
156+
websiteUrl={websiteUrl}
157+
onWebsiteUrl={setWebsiteUrl}
158+
githubUrl={githubUrl}
159+
onGithubUrl={setGithubUrl}
160+
githubTag={githubTag}
161+
onGithubTag={setGithubTag}
162+
parentOrg={parentOrg}
163+
onParentOrg={handleParentOrg}
164+
parentOrgList={parentOrgList}
165+
onCancel={handleClose}
166+
onNext={handleNext}
167+
/>
168+
);
169+
const stepTwo = (
170+
<StepTwo
171+
apiErrors={apiErrors}
172+
setApiErrors={setApiErrors}
173+
facebookUrl={facebookUrl}
174+
onFacebookUrl={setFacebookUrl}
175+
twitterUrl={twitterUrl}
176+
onTwitterUrl={setTwitterUrl}
177+
meetupUrl={meetupUrl}
178+
onMeetupUrl={setMeetupUrl}
179+
city={city}
180+
onCity={setCity}
181+
stateProvCo={stateProvCo}
182+
onStateProvCo={setStateProvCo}
183+
country={country}
184+
onCountryChange={setCountry}
185+
onPrev={handlePrev}
186+
onSubmit={handleSubmit}
187+
/>
188+
);
159189
switch (step) {
160-
case 0: return stepOne;
161-
case 1: return stepTwo;
162-
case 2: return <Complete onClose={handleClose} />;
163-
default: return stepOne;
190+
case 0:
191+
return stepOne;
192+
case 1:
193+
return stepTwo;
194+
case 2:
195+
return <Complete onClose={handleClose} />;
196+
default:
197+
return stepOne;
164198
}
165199
};
166200

167201
return (
168-
<Dialog fullWidth maxWidth='sm' open={open} ref={ref}>
202+
<Dialog
203+
PaperProps={{ 'aria-label': 'Add Organization Modal' }}
204+
fullWidth
205+
maxWidth='sm'
206+
open={open}
207+
ref={ref}
208+
>
169209
{renderStep()}
170210
</Dialog>
171211
);
172212
});
173213

174-
AddOrgForm.displayName = "AddOrgForm";
214+
AddOrgForm.displayName = 'AddOrgForm';
175215

176216
export default AddOrgForm;

src/pages/TagGenerator/Organization.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export const OrganizationSelectorSection = ({
3838
return (
3939
<>
4040
<Grid item xs={12} sm={12}>
41-
<Typography variant='body1'style={{ padding: '34px 0 8px' }}>Which Organization?</Typography>
41+
<Typography variant='body1' style={{ padding: '34px 0 8px' }}>
42+
Which Organization?
43+
</Typography>
4244
<Autocomplete
4345
id='organization'
4446
style={{ width: '100%' }}
@@ -65,6 +67,7 @@ export const OrganizationSelectorSection = ({
6567
variant='outlined'
6668
InputProps={{
6769
...params.InputProps,
70+
placeholder: 'Select an Organization',
6871
endAdornment: (
6972
<React.Fragment>
7073
{loading ? (
@@ -81,10 +84,7 @@ export const OrganizationSelectorSection = ({
8184
<Grid item style={{ paddingTop: '12px' }}>
8285
<Typography variant='body1'>
8386
Don&apos;t see your organization? Click&nbsp;
84-
<Link
85-
id='add-org-link'
86-
onClick={() => setDialogOpen(true)}
87-
>
87+
<Link id='add-org-link' onClick={() => setDialogOpen(true)}>
8888
here
8989
</Link>
9090
&nbsp;to add it.
@@ -125,10 +125,7 @@ export const OrgNameSection = ({ setDisplayState, orgName, linkStyles }) => {
125125
)}
126126
<Grid item xs={2}>
127127
<Typography>
128-
<Link
129-
id='change-org'
130-
onClick={handleChangeOrg}
131-
>
128+
<Link id='change-org' onClick={handleChangeOrg}>
132129
change
133130
</Link>
134131
</Typography>

0 commit comments

Comments
 (0)