Allow group owner to delete Placeholder Users that are Awaiting Reassignment via CSV
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
About
With user mapping, imports generate Placeholder Users that will appear in the top-level group's Manage > Members > Placeholders (tab) section.
Problem
There is currently no way for a group owner to delete these entries.
The results of any test imports, for example, will appear in this section permanently.
Proposal
Allow group owners to delete entries in their Manage > Members > Placeholders (tab) section if their reassignment status is "not started".
This issue will provide CSV support. #537340 will add support for UI separately.
Add an extra column to the CSV mapping file that would allow a person to signal per user/row whether to "delete placeholders".
e.g.
<existing columns...>,Delete placeholder
<existing columns...>,yes
When parsing the CSV, if a row has GitLab username,GitLab public email
completed, or has Keep as placeholder
set to true (feature being added in #535229), we should skip processing that line and add to our list of errors.
Because people may enter anything into this new column, we should parse its content using Gitlab::Utils.to_boolean
- so people could enter any of the following values to signal "true" for the column: true
, t
, yes
, y
, 1
, on
.
We should write a new service to do the deletion as we will reuse the service in #537340. The service would be called from BulkReassignFromCsvService#process_line
when processing the CSV data.
The service would:
- Validate that the current user can delete the
Import::SourceUser
record - Validate that the
Import::SourceUser
record is inpending_reassignment
status. - Delete the placeholder
User
record (using#delete_async
in the same was as we do here). -
Import::SourceUser
record for that placeholder user would be deleted (this would delete the related placeholder user reference data inimport_placeholder_memberships
andimport_source_user_placeholder_references
due toON CASCADE DELETE
foreign keys, and so could in a small way contribute to &17248). - Return
ServiceResponse
objects for success or failure
We should add documentation of the new CSV capabilities. The documentation should include full warnings of what the effects on imported data would need to be given. Roughly the effects would be 1) certain records associated with the placeholder user would be associated with the GitLab ghost user and 2) certain other records may continue to exist and would be unable to be reassigned.
Note: As pointed out here, users can already upload the CSV 3x times, with the 3 scenarios broken down into 3 CSV files. Perhaps it's not obvious to user that they can do it, so we can consider if we should document it or not. I think we say already that not all CSV rows need to be completed to upload the CSV.
Question
Should we only allow this to happen if the placeholder User
has no associations with other data (like this check) - returning a failure message for this action if there are. Group owners should ideally delete relevant projects and groups before deleting the associated placeholder.