feat: add delete button to question and news forms#4643
feat: add delete button to question and news forms#4643GMetaxakis wants to merge 13 commits intoONEARMY:masterfrom
Conversation
Add soft-delete API endpoints (DELETE method) to api.questions.$id and api.news.$id with creator/admin authorization. Add client-side delete functions, delete buttons with confirmation modals in the edit forms, and Cypress tests for both content types. Closes ONEARMY#4265
3748fb6 to
41ba2ec
Compare
onearmy-community-platform
|
||||||||||||||||||||||||||||||||||
| Project |
onearmy-community-platform
|
| Branch Review |
pull/4643
|
| Run status |
|
| Run duration | 30m 26s |
| Commit |
|
| Committer | Georgios Metaxakis |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
1
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
96
|
| View all changes introduced in this branch ↗︎ | |
Tests for review
src/integration/news/write.spec.ts • 1 failed test • ci-chrome
| Test | Artifacts | |
|---|---|---|
| [News.Write] > [Delete a news item] > [By Author] |
Test Replay
Screenshots
Video
|
|
|
The E2E test failures are caused by the new The migration ( ALTER TABLE news ADD COLUMN published_at timestamptz;
UPDATE news SET published_at = created_at WHERE (is_draft = false OR is_draft IS NULL);Once the migration is applied, the 4 failing news tests should pass. |
|
Hey @GMetaxakis, thanks for working on so many items atm. I'm confused by the branch name and some some of the changes in this branch. Are they all related to the creation date change? |
d5ea96a to
41ba2ec
Compare
|
Hey @benfurber, you're right — sorry about the confusion! I accidentally pushed the publish date changes onto this branch instead of keeping them on their own. I've now cleaned this up:
Should be much clearer now. Let me know if you have any questions! |
|
@GMetaxakis seems like both cypress tests for deleting news and questions are failing |
The delete tests for questions and news used [data-cy=confirm] but the ConfirmModal component uses data-cy="Confirm.modal: Confirm".
|
Fixed the conflicts on this branch |
|
@dalibormrska need your input here. For research appears on the item itself. With this PR questions and library will have it on the form (need to edit first): Technically it's simpler to not have it on the form, but we can do it however is best for UX. |
|
Judging now the logic decision and not necessarily the current layout, I lean towards the option of having just the edit button and the delete inside of the form. |
src/services/newsService.ts
Outdated
| }); | ||
|
|
||
| if (response.status !== 200 && response.status !== 201) { | ||
| throw new Error('Error deleting news', { cause: 500 }); |
There was a problem hiding this comment.
Should handle the error with the message sent from the api, see above.
src/services/questionService.ts
Outdated
| }); | ||
|
|
||
| if (response.status !== 200 && response.status !== 201) { | ||
| throw new Error('Error deleting question', { cause: 500 }); |
There was a problem hiding this comment.
(same as on newsService)
Should handle the error with the message sent from the api, see above.
| return; | ||
| } | ||
| setShowDeleteModal(false); | ||
| await newsService.deleteNews(id); |
There was a problem hiding this comment.
should handle the error here, maybe show an <Alert /> component
| return; | ||
| } | ||
| setShowDeleteModal(false); | ||
| await questionService.deleteQuestion(id); |
There was a problem hiding this comment.
should handle the error here, maybe show an <Alert /> component
- Read error messages from API response in newsService and questionService delete functions instead of using generic messages - Catch delete errors in NewsForm and QuestionForm and display them via the existing saveErrorMessage/FormWrapper error UI
|
@GMetaxakis the news delete test is failing |
The news listing query was missing the deleted filter, causing soft-deleted news items to still appear in the /news page.
…xakis/community-platform into feat/delete-questions-news


PR Checklist
PR Type
What is the new behavior?
api.questions.$idandapi.news.$idwith creator/admin authorization (soft-delete viadeleted: true)deleteQuestionanddeleteNewsservice functionsDoes this PR introduce a DB Schema Change or Migration?
Git Issues
Closes #4265