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

Migrate anonymization script to react #10654

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

danieljames-dj
Copy link
Member

Currently there are two pages of anonymization - one for anonymizing profile (in rails) and another for anonymizing account (in react). This PR merges both to a single react script.

@danieljames-dj danieljames-dj marked this pull request as draft January 19, 2025 16:24
@danieljames-dj danieljames-dj force-pushed the anonym-script branch 2 times, most recently from 854423d to 5b3fe8c Compare January 27, 2025 04:16
@danieljames-dj danieljames-dj marked this pull request as ready for review January 27, 2025 04:16
@danieljames-dj danieljames-dj force-pushed the anonym-script branch 4 times, most recently from db318a9 to 9170f04 Compare January 28, 2025 16:47
Comment on lines +8 to +11
const MODEL_NAME = {
[SEARCH_MODELS.user]: 'User',
[SEARCH_MODELS.person]: 'Person',
};
Copy link
Member

Choose a reason for hiding this comment

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

What about using the keys of this object as a separate AVAILABLE_MODELS const (name tentative)?
Would be useful in a few places further down


export default function AnonymizationScriptPage() {
const [user, setUser] = useInputState();
const [model, setModel] = useInputState(SEARCH_MODELS.user);
Copy link
Member

Choose a reason for hiding this comment

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

If you have a constant list, you can just use AVAILABLE_MODELS[0] here

model={SEARCH_MODELS.user}
<FormGroup grouped>
<div>Select where to search for</div>
{[SEARCH_MODELS.user, SEARCH_MODELS.person].map((searchModel, index) => (
Copy link
Member

Choose a reason for hiding this comment

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

Here is another place where a list of models available for anon would help.

Comment on lines +44 to +53
{model === SEARCH_MODELS.user && (
<AnonymizationTicketWorkbenchForWrt
userId={searchInput}
/>
)}
{model === SEARCH_MODELS.person && (
<AnonymizationTicketWorkbenchForWrt
wcaId={searchInput}
/>
)}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{model === SEARCH_MODELS.user && (
<AnonymizationTicketWorkbenchForWrt
userId={searchInput}
/>
)}
{model === SEARCH_MODELS.person && (
<AnonymizationTicketWorkbenchForWrt
wcaId={searchInput}
/>
)}
<AnonymizationTicketWorkbenchForWrt
userId={model === SEARCH_MODELS.user && searchInput}
wcaId={model === SEARCH_MODELS.person && searchInput}
/>

Copy link
Member

Choose a reason for hiding this comment

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

(You will need to try out whether that works as expected, though)

const [confirmOpen, setConfirmOpen] = useState(false);
const [completed, setCompleted] = useState(false);

const { save, saving } = useSaveAction();
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 you can use Tanstack mutation here

import { List, ListItem } from 'semantic-ui-react';

export default function PerformManualChecks() {
// TODO: Add necessary links in this page.
Copy link
Member

Choose a reason for hiding this comment

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

Is this TODO supposed to be here? Or did you just forget to take care of it before opening the PR?

Comment on lines +4 to +13
const anonymizationType = (data) => {
if (data.user_details && !data.person_details) {
return 'Account Only';
} if (data.person_details && !data.user_details) {
return 'Profile Only';
} if (data.user_details && data.person_details) {
return 'Account & Profile';
}
return 'Unknown';
};
Copy link
Member

Choose a reason for hiding this comment

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

Just a minor comment, because it's not my power to decide: I am confused about the terminology here. In the entry point to the script (further up, where you have a search input) you call it "User" and "Person". Here, you suddenly talk about "Profile" and "Account". Maybe this PR is a good chance to clean up some terminology?

} = useQuery({
queryKey: ['anonymizeDetails', userId, wcaId],
queryFn: () => getDetailsBeforeAnonymization(userId, wcaId),
enabled: Boolean(userId || wcaId),
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 userId || wcaId is already enough in this case, because of the || operator

Comment on lines +31 to +46
<Container>
<Header>Anonymization Dashboard</Header>

<Header as="h5">Step 1: Verify details to be anonymized</Header>
<VerifyAnonymizeDetails data={data} />

<Header as="h5">Step 2: Review system generated checks</Header>
<ReviewSystemGeneratedChecks data={data} />

<Header as="h5">Step 3: Perform manual checks</Header>
<PerformManualChecks data={data} />

<Header as="h5">Step 4: Anonymize Action</Header>
<AnonymizeAction data={data} userId={userId} wcaId={wcaId} />

</Container>
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this is something that you would be interested in, but SemUI has this lovely Step component which would improve UX here a lot: https://react.semantic-ui.com/elements/step/

Copy link
Member

Choose a reason for hiding this comment

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

(I do appreciate that this is a WRT-only panel though, which means only ~0.005% of website users end up here. So I won't block this PR just because of this. But may still be useful though!)

Copy link
Member

Choose a reason for hiding this comment

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

Can you please give me a short summary of where these methods come from, and how much (if anything) was copy/pasted from the previous anon logic?

I can see that you deleted the existing model file that held all the backend steps logic, but I don't want to compare exactly each line from the old file and this file, especially since it seems that you have changed the flow a little bit

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.

4 participants