Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAGE] add delete user option #1577

Merged
merged 4 commits into from
Nov 23, 2023
Merged

[MAGE] add delete user option #1577

merged 4 commits into from
Nov 23, 2023

Conversation

vincanger
Copy link
Contributor

Description

Adds delete account functionality to the UserPage, and another couple small improvements

Select what type of change this PR introduces:

  1. Just code/docs improvement (no functional change).
  2. Bug fix (non-breaking change which fixes an issue).
  3. New feature (non-breaking change which adds functionality).
  4. Breaking change (fix or feature that would cause existing functionality to not work as expected).

Update Waspc ChangeLog and version if needed

If you did a bug fix, new feature, or breaking change, that affects waspc, make sure you satisfy the following:

  1. I updated ChangeLog.md with description of the change this PR introduces.
  2. I bumped waspc version in waspc.cabal to reflect changes I introduced, with regards to the version of the latest wasp release, if the bump was needed.

Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vincanger nice! Looks great, couple of small comments and we can merge!

wasp-ai/.prettierrc Outdated Show resolved Hide resolved
@@ -154,7 +159,7 @@ entity SocialLogin {=psl
providerId String

userId Int
user User @relation(fields: [userId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: once projects are deleted, we will never know they existed, so our number of created projects will become smaller. Would be cool if they only thing that is left is this idea of "there was a project that was deleted". But to be honest I am not sure myself how to implement that simply, so probably best to just ignore it, doesn't matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isnt for projects. when the user is deleted it deletes the social login entity, but leaves their projects in the DB.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to leave the generated apps in the database in case they've been shared. there is no connection whatsoever to the user that created it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would still be good if they can delete their projects, since they were authored by them.

I would suggest on of the following:

  1. Delete all the project they created, and that is it, simple.
  2. Give them choice -> they can delete also the projects, or they can leave them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I've gone ahead and deleted all user-relevant info leaving just the project shell :)

wasp-ai/src/client/pages/ResultPage.jsx Outdated Show resolved Hide resolved
wasp-ai/src/client/pages/UserPage.jsx Show resolved Hide resolved
wasp-ai/src/client/pages/UserPage.jsx Show resolved Hide resolved
wasp-ai/src/server/operations.ts Outdated Show resolved Hide resolved
Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vincanger looking good! I approved, but just wanted to check, what does it look like if somebody tries to open a project of deleted user via its URL? Is it broken, or does it look somewhat reasonable? Would be good if it isn't a total mess, but instead it said something like This project was deleted.
Also,

@Martinsos
Copy link
Member

@vincanger looking good! I approved, but just wanted to check, what does it look like if somebody tries to open a project of deleted user via its URL? Is it broken, or does it look somewhat reasonable? Would be good if it isn't a total mess, but instead it said something like This project was deleted. Also,

Aha, ok it will have Deleted project title and description.

Might be better if we set title and description to NULL or some value like that, so it is clear they are empty, and then in that UI we detect they are set to NULL and then show one big "Deleted project". But we don't have to bother with this if current solution looks relatively reasonable, your call.

@vincanger
Copy link
Contributor Author

@vincanger looking good! I approved, but just wanted to check, what does it look like if somebody tries to open a project of deleted user via its URL? Is it broken, or does it look somewhat reasonable? Would be good if it isn't a total mess, but instead it said something like This project was deleted. Also,

Aha, ok it will have Deleted project title and description.

Might be better if we set title and description to NULL or some value like that, so it is clear they are empty, and then in that UI we detect they are set to NULL and then show one big "Deleted project". But we don't have to bother with this if current solution looks relatively reasonable, your call.

Good catch!

I didn't want to change the name and description properties to optional. so I just made the delete function update the status to "deleted", and then check for that on the client and show:
image

Copy link
Member

@Martinsos Martinsos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM: I left a small note regarding how "delete" could be more "clean cody", but since we dropped the ball anyway for statuses regarding that, then we don't need to fix it now, we can fix it all later, so all good.

NOTE: It is a bit tricky when formatting is all mixed up with changes, it makes it really hard for me to figure out which are actual changes.
Ways to go about this, when we have a codebase like this where files are not yet formatted, is to e.g. turn of formatting in your editor and do it without, and then do separate PR which does the formatting. Or, maybe at least a separate commit (although that is also tricky to review if there is more than one non-formatting commit).
Or you could maybe do formatting, but then comment in the PR on the changes that are relevant, so I know what to focus on.

@@ -244,7 +252,16 @@ export const ResultPage = () => {
</>
)}

<Logs logs={logs} status={currentStatus.status} onRetry={retry} />
{appGenerationResult?.project.status.includes("deleted") ? (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "deleted" here, would be great to have it imported from somewhere, so we don't have duplication. But this project in general is not very careful about this, so if all the other statuses are handled badly like this then we can postpone this refactoring to be refactored all together.

@Martinsos Martinsos merged commit 3825ef9 into wasp-ai Nov 23, 2023
4 checks passed
@Martinsos Martinsos deleted the vince-mage-delete-user branch November 23, 2023 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants