Skip to content

Commit 29296a6

Browse files
committed
Merge branch 'release-2.20.1' into release
2 parents f96cd7b + 5e16d69 commit 29296a6

File tree

5 files changed

+164
-248
lines changed

5 files changed

+164
-248
lines changed

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/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/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,

0 commit comments

Comments
 (0)