Skip to content

Commit a62d9a9

Browse files
authored
Merge branch 'develop' into test-files-delete
2 parents 2e8bb2d + 71e272e commit a62d9a9

42 files changed

Lines changed: 19390 additions & 25723 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
Fixes #issue-number
1+
### Issue:
2+
Fixes #
3+
<!-- Please add the issue this relates to, and a provide a brief description of the current state of the codebase and what this PR attempts to fix. -->
24

3-
Changes:
5+
### Demo:
6+
<!-- Please add a screenshot for UI related changes -->
47

5-
I have verified that this pull request:
8+
### Changes:
9+
<!-- Summarise your changes -->
10+
11+
### I have verified that this pull request:
612

713
* [ ] has no linting errors (`npm run lint`)
814
* [ ] has no test errors (`npm run test`)

client/modules/IDE/actions/project.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export function changeProjectName(id, newName) {
386386
}
387387

388388
export function deleteProject(id) {
389-
return (dispatch, getState) => {
389+
return (dispatch, getState) =>
390390
apiClient
391391
.delete(`/projects/${id}`)
392392
.then(() => {
@@ -411,7 +411,6 @@ export function deleteProject(id) {
411411
});
412412
}
413413
});
414-
};
415414
}
416415
export function changeVisibility(projectId, projectName, visibility, t) {
417416
return (dispatch, getState) => {

client/modules/IDE/components/AddToCollectionSketchList.unit.test.jsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ describe('<AddToCollectionSketchList />', () => {
119119

120120
const before = requestCount;
121121

122-
fireEvent.click(screen.getByRole('button', { name: 'Next Page' }));
122+
fireEvent.click(
123+
screen.getByRole('button', { name: 'Pagination.NextPageARIA' })
124+
);
123125

124126
await waitFor(() => {
125127
expect(requestCount).toBeGreaterThan(before);
@@ -134,7 +136,7 @@ describe('<AddToCollectionSketchList />', () => {
134136
await screen.findByText('page1-sketch-1');
135137

136138
expect(
137-
screen.getByRole('button', { name: 'Previous Page' })
139+
screen.getByRole('button', { name: 'Pagination.PreviousPageARIA' })
138140
).toBeDisabled();
139141
});
140142

@@ -165,7 +167,7 @@ describe('<AddToCollectionSketchList />', () => {
165167
await screen.findByText('AddToCollectionSketchList.NoCollections');
166168

167169
expect(
168-
screen.queryByRole('button', { name: 'Next Page' })
170+
screen.queryByRole('button', { name: 'Pagination.NextPageARIA' })
169171
).not.toBeInTheDocument();
170172
});
171173

@@ -253,13 +255,17 @@ describe('<AddToCollectionSketchList />', () => {
253255
let info = document.querySelector('.pagination-info');
254256
expect(info.textContent.replace(/\s+/g, ' ').trim()).toContain('1 - 10');
255257

256-
fireEvent.click(screen.getByRole('button', { name: 'Next Page' }));
258+
fireEvent.click(
259+
screen.getByRole('button', { name: 'Pagination.NextPageARIA' })
260+
);
257261
await screen.findByText('page2-sketch-1');
258262

259263
info = document.querySelector('.pagination-info');
260264
expect(info.textContent.replace(/\s+/g, ' ').trim()).toContain('11 - 20');
261265

262-
fireEvent.click(screen.getByRole('button', { name: 'Next Page' }));
266+
fireEvent.click(
267+
screen.getByRole('button', { name: 'Pagination.NextPageARIA' })
268+
);
263269
await screen.findByText('page3-sketch-1');
264270

265271
info = document.querySelector('.pagination-info');

client/modules/IDE/components/Pagination.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const Pagination = ({
2626
className="page-link"
2727
onClick={() => onPageChange(page - 1)}
2828
disabled={page === 1}
29-
aria-label="Previous Page"
29+
aria-label={t('Pagination.PreviousPageARIA')}
3030
>
3131
{t('Pagination.Previous')}
3232
</button>
@@ -51,7 +51,7 @@ const Pagination = ({
5151
onPageChange(page + 1);
5252
}}
5353
disabled={page === totalPages}
54-
aria-label="Next Page"
54+
aria-label={t('Pagination.NextPageARIA')}
5555
>
5656
{t('Pagination.Next')}
5757
</button>

client/modules/IDE/components/QuickAddList/Icons.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import { useTranslation } from 'react-i18next';
34
import CloseIcon from '../../../../images/close.svg';
45
import CheckIcon from '../../../../images/check_encircled.svg';
56

67
const Icons = ({ isAdded }) => {
8+
const { t } = useTranslation();
79
const classes = [
810
'quick-add__icon',
911
isAdded
@@ -16,13 +18,13 @@ const Icons = ({ isAdded }) => {
1618
<CloseIcon
1719
className="quick-add__remove-icon"
1820
role="img"
19-
aria-label="Descending"
21+
aria-label={t('QuickAddList.ButtonRemoveARIA')}
2022
focusable="false"
2123
/>
2224
<CheckIcon
2325
className="quick-add__add-icon"
2426
role="img"
25-
aria-label="Descending"
27+
aria-label={t('QuickAddList.ButtonAddToCollectionARIA')}
2628
focusable="false"
2729
/>
2830
</div>

client/modules/IDE/components/SketchList.jsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,30 @@ const SketchList = ({
7373
[username, user.username, t]
7474
);
7575

76+
const handleDeletedProject = useCallback(() => {
77+
// sketches table refetches projects post-project deletion for server-side pagination
78+
if (sketches.length === 1 && page > 1) {
79+
setPage((p) => p - 1);
80+
} else {
81+
getProjects(username, {
82+
page,
83+
limit,
84+
sortField,
85+
sortDir,
86+
q: search
87+
});
88+
}
89+
}, [
90+
sketches.length,
91+
page,
92+
getProjects,
93+
username,
94+
limit,
95+
sortField,
96+
sortDir,
97+
search
98+
]);
99+
76100
const isLoading = () => loading && isInitialDataLoad;
77101

78102
const hasSketches = () => !isLoading() && sketches.length > 0;
@@ -184,6 +208,7 @@ const SketchList = ({
184208
user={user}
185209
username={username}
186210
onAddToCollection={() => setSketchToAddToCollection(sketch)}
211+
onDeletedProject={handleDeletedProject}
187212
t={t}
188213
/>
189214
))}

client/modules/IDE/components/SketchList.unit.test.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe('<SketchList />', () => {
134134

135135
expect(screen.queryByRole('table')).not.toBeInTheDocument();
136136
expect(
137-
screen.queryByRole('button', { name: 'Next Page' })
137+
screen.queryByRole('button', { name: 'Pagination.NextPageARIA' })
138138
).not.toBeInTheDocument();
139139
});
140140

@@ -195,7 +195,9 @@ describe('<SketchList />', () => {
195195

196196
const before = requestCount;
197197

198-
fireEvent.click(screen.getByRole('button', { name: 'Next Page' }));
198+
fireEvent.click(
199+
screen.getByRole('button', { name: 'Pagination.NextPageARIA' })
200+
);
199201

200202
await waitFor(() => {
201203
expect(requestCount).toBeGreaterThan(before);
@@ -209,7 +211,9 @@ describe('<SketchList />', () => {
209211
subject();
210212
await screen.findByText('page1-sketch-1');
211213

212-
const prev = screen.getByRole('button', { name: 'Previous Page' });
214+
const prev = screen.getByRole('button', {
215+
name: 'Pagination.PreviousPageARIA'
216+
});
213217
expect(prev).toBeDisabled();
214218
});
215219

@@ -245,10 +249,10 @@ describe('<SketchList />', () => {
245249
await screen.findByText('singlePage-sketch-1');
246250

247251
expect(
248-
screen.queryByRole('button', { name: 'Previous Page' })
252+
screen.queryByRole('button', { name: 'Pagination.PreviousPageARIA' })
249253
).not.toBeInTheDocument();
250254
expect(
251-
screen.queryByRole('button', { name: 'Next Page' })
255+
screen.queryByRole('button', { name: 'Pagination.NextPageARIA' })
252256
).not.toBeInTheDocument();
253257
});
254258
});

client/modules/IDE/components/SketchListRowBase.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const SketchListRowBase = ({
2424
changeProjectName,
2525
cloneProject,
2626
deleteProject,
27+
onDeletedProject,
2728
showShareModal,
2829
changeVisibility,
2930
t,
@@ -85,7 +86,9 @@ const SketchListRowBase = ({
8586

8687
const handleSketchDelete = () => {
8788
if (window.confirm(t('Common.DeleteConfirmation', { name: sketch.name }))) {
88-
deleteProject(sketch.id);
89+
deleteProject(sketch.id).finally(() => {
90+
onDeletedProject();
91+
});
8992
}
9093
};
9194

@@ -174,6 +177,7 @@ SketchListRowBase.propTypes = {
174177
authenticated: PropTypes.bool.isRequired
175178
}).isRequired,
176179
deleteProject: PropTypes.func.isRequired,
180+
onDeletedProject: PropTypes.func.isRequired,
177181
cloneProject: PropTypes.func.isRequired,
178182
changeProjectName: PropTypes.func.isRequired,
179183
showShareModal: PropTypes.func.isRequired,

client/modules/IDE/components/TextArea.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function TextArea({ src, className }) {
3232
<TextAreaWrapper>
3333
<textarea className={className}>{src}</textarea>
3434
<CornerButton onClick={copyTextToClipboard}>
35-
<CopyIcon aria-label="Copy" />
35+
<CopyIcon aria-label={t('TextArea.CopyARIA')} />
3636
</CornerButton>
3737
</TextAreaWrapper>
3838
);

client/modules/IDE/components/Toast.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default function Toast() {
1818
<button
1919
className="toast__close"
2020
onClick={() => dispatch(hideToast())}
21-
aria-label="Close Alert"
21+
aria-label={t('Toast.CloseAlertARIA')}
2222
>
2323
<ExitIcon focusable="false" aria-hidden="true" />
2424
</button>

0 commit comments

Comments
 (0)