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

Show related projects (by lang code) in same org when creating project #979

Merged
merged 31 commits into from
Aug 9, 2024

Conversation

rmunn
Copy link
Contributor

@rmunn rmunn commented Jul 23, 2024

Fixes #253.
Fixes #258.

When the user selects an org in the create-project page, any projects with similar names in that org are displayed in a list of possibly-related projects, and the user is invited to choose one of them to join instead of creating a new project. If he chooses to join the project, an email is sent to that project's manager(s) to ask them to approve it. Further down the create-project form, when a language code is entered, another GraphQL query is made searching for any projects with a vernacular writing system matching that language code, and those projects are added to the related-projects list. (Ordered first, above the related-by-name results, because they're more likely to be correct).

The related-projects list replaces the project description field and the submit button, so the user is forced to interact with it, either by clicking "Yes, join project" or by clicking "No thanks, create new project" before he can move on to creating the project. If he dismisses it by clicking "No thanks", he can still change his mind and see the list of related projects again. See demo below.

Work done:

  • Add code to call the query to project creation page
    • Only if orgID not null and language code has been entered
  • UI to display results in project creation page
  • Improve UI for related-project results
    • each result is a radio button
    • can either choose one and click "Request to join (project name)"
    • or click "Don't join, just create new project"
    • Descripton and submit button are hidden while related-project results list is visible, so must dismiss before entering project description
    • Even after dismissing list, there will be a way to click on something to get the list back.
  • Deal with two-letter codes correctly
  • UI to show project managers that project-join approval worked
  • E2E test to exercise the approval flow Decided to postpone E2E test to a later PR

Screenshot of UI sketch:

image

Demo (note: location has moved since this recording was taken, now it's above the description):

feature-demo

Copy link

github-actions bot commented Jul 23, 2024

UI unit Tests

12 tests  ±0   12 ✅ ±0   0s ⏱️ ±0s
 4 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit d0a3040. ± Comparison against base commit 213269b.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 23, 2024

C# Unit Tests

53 tests   53 ✅  5s ⏱️
10 suites   0 💤
 1 files     0 ❌

Results for commit d0a3040.

♻️ This comment has been updated with latest results.

@rmunn rmunn self-assigned this Jul 23, 2024
@rmunn
Copy link
Contributor Author

rmunn commented Jul 24, 2024

Pre-emptively rebasing on top of develop since several PRs were recently merged.

@rmunn rmunn force-pushed the feat/search-projects-in-org-by-lang-tag branch from 29e0632 to f6fe512 Compare July 24, 2024 08:52
@rmunn
Copy link
Contributor Author

rmunn commented Jul 24, 2024

With commit cecdcd1, we now deal with 2-letter codes in what I believe is the correct way: convert 3-letter codes to the equivalent 2-letter code (if there is an equivalent 2-letter code) before looking it up in the FLEx metadata.

The LangTagsConstant file was produced by running the following jq command on a copy of langtags.json:

jq '.[] | select((.tag | length) == 2) | {tag: .tag, iso639_3: .iso639_3}' < langtags.json > two-letter-tags.txt

I then took the two-letter-tags.txt file and converted it to C# syntax.

@rmunn
Copy link
Contributor Author

rmunn commented Jul 24, 2024

I just checked https://ldml.api.sil.org/langtags.json and found that my local copy was a little out of date, and in particular that it was missing one two-letter code added in the past couple of years. I pushed commit 3df5b3d to fix that, but that brings up an issue for discussion: how are we going to handle this in the future?

Options include:

  • Store a copy of langtags.json in our source code, and a script to generate LangTagsConstants.cs from the JSON original. We could either:
    • Run that script during dotnet build so that LangTagsConstants.cs is (re-)generated every time. Or,
    • Run that script by hand when langtags.json is updated, and commit the result. Build LangTagsConstants.cs from the Git repo.
  • Don't have a LangTagsConstants.cs file at all, but every time the server starts up, parse langtags.json and build a lookup dictionary kept in RAM.
  • Same, but parse inside the ProjectsByLangCodeAndOrg query, using more CPU to avoid keeping that lookup table around in RAM. (I don't think this is a good option, but it's possible).

For myself, I'm inclined towards the first of these: keep a copy of langtags.json in our repo, and have a script that will check https://ldml.api.sil.org/langtags.json every so often and re-generate LangTagsConstants.cs if there is a newer version of langtags.json available on the server. (https://ldml.api.sil.org/langtags.json serves an ETag header, so we can use If-None-Match to avoid downloading a file that we already have; we'd just need to store the ETag value in langtags.json.etag alongside langtags.json.)

@rmunn rmunn requested a review from hahn-kev July 30, 2024 03:10
@rmunn rmunn marked this pull request as ready for review July 30, 2024 03:10
@rmunn
Copy link
Contributor Author

rmunn commented Jul 31, 2024

Seems to me I should have this PR fix #258 at the same time: the UI for #258 probably belongs in the project-creation page, and it doesn't really make sense to show a list of related projects and not allow clicking on them to request joining.

@rmunn rmunn linked an issue Jul 31, 2024 that may be closed by this pull request
@rmunn
Copy link
Contributor Author

rmunn commented Jul 31, 2024

Commit 159c1a2 is a start at a request-approval flow where project managers can approve a join request. It still needs a few things, which I'll work on tomorrow:

  • UI to give feedback to managers that their approving the project-join request was successful
    • Should probably redirect to project page with a notification
    • This means I'll want the project code, rather than ID, in the approval URL, to make that redirect easy
    • So I'll probably want the backend API to take the code instead of the ID
  • E2E tests exercising the request-join workflow (org member requests joining, project manager gets emailed)
  • Edit the project-create UI so that the list of similar projects now includes "Request to join" buttons

Perhaps I'll make the list of similar projects into a list of radio buttons, where the user can click on one and then click "Request to join" below. Then beside "Request to join" is "No, create project" which will dismiss the list of similar projects. (When the list is visible, the project description field and submit buttons are hidden, so you're forced to interact with the list of similar projects before you can click the submit button.)

@rmunn
Copy link
Contributor Author

rmunn commented Aug 1, 2024

Marking as draft again, because the design we ended up with will want to use the mechanism from #986 to auto-fill in the invitation modal with user ID and name values from URL query params. So I want to put this on hold until #986 is merged, then build off of #986 for the frontend part of this.

There's still more work that can be done on this PR while #986 isn't merged yet, so it's not blocked yet. At some point if #986 takes a long time to get merged, I'll mark this one as blocked and move on to something else.

@rmunn rmunn marked this pull request as draft August 1, 2024 05:22
@rmunn rmunn force-pushed the feat/search-projects-in-org-by-lang-tag branch from 6539a7a to 1bb2662 Compare August 5, 2024 06:07
rmunn added 13 commits August 6, 2024 14:26
If the org dropdown has a selected org, and there is a valid language
code (2 or 3 characters), then a search will be made for any projects
belonging to the selected org that have that language code in their list
of currently active vernacular writing systems.
If someone types the language tag "eng", we want to search for "en"
because that's how FLEx will have stored it as a writing system.
The langtags.json file I used initially was a couple years out of date,
and there was one new 2-letter code assignment since then. Updating the
LangTagConstants.cs file accordingly.
Could put it below the description instead, but we might want to save
the user some typing in case they decide not to create the project after
all, so we'll put the related projects list above the description so
they'll see it before starting to type.
New GraphQL mutation allowing users to request joining any project in
their org, which will send an email to project managers who can then
approve the request. (Currently no email is sent to the user when their
request is approved; we may add that later.)
This allows the frontend to show a success notification and redirect
to the project page.
Instead of a new API endpoint in ProjectController, we'll just populate
the AddProjectMember modal with the user's name and ID (once it acquires
the ability to have a user ID), and then the flow will pass through the
existing GraphQL mutations. That way we won't need to do any special
work to update the GraphQL cache. It means one extra click for the admin
to approve the project join request, but it also means that admins can
choose to have the joining user join as a manager if they want, which
will come in handy sometime.
Will eventually allow selecting one then clicking on a "request joining
project" button below, or clicking a "No, I want a new project" button
to get the description field and the submit button to become visible.
UI now requires either asking to join a related project, or clicking "No
thanks, create a new project" in order to get access to the rest of the
form including the submit button.
rmunn added 6 commits August 6, 2024 14:26
Also moved backend mutation back to using project ID now that it's easy
If the user clicks on the "Ask to join" button, they are trying to
abandon the form so we don't want to ask them if they want to preserve
the data previously entered.
If the "Ask to join" request failed for any reason, we don't want to
navigate away from the form.
rmunn added 3 commits August 6, 2024 15:18
Also rename it to ProjectsInMyOrg since it's now a lot more generic.
Related search by name often turns up the same projects that the search
by language code is turning up, so we'll ensure that we only add one
copy of each project to the related-projects list.
@rmunn rmunn marked this pull request as ready for review August 6, 2024 09:47
By simply creating a flattedNestedStore helper function with appropriate
types, we can get rid of a lot of the unnecessary complexity we had
ended up with in the related-projects stores.
Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

I'm getting this error when I try to go to the project create page:
image

@rmunn rmunn requested a review from hahn-kev August 7, 2024 05:38
@rmunn
Copy link
Contributor Author

rmunn commented Aug 7, 2024

Whoops, left out one single ? operator when I created the helper function. Commit 4ed1ec9 should fix that.

Let me know if you need any other changes, @hahn-kev.

Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

looks good nice job!

there's a couple edge cases to clean up, as well as a suggestion for code clarity.

I created #1014 to track creating e2e tests for the join workflow.

rmunn added 3 commits August 8, 2024 10:32
We don't need to use the queryStore functions here because there's no
need to subscribe to store updates to catch values updated on the
server. This allows us to get rid of the store-inside-a-store nesting
and simplify the consuming code.
@rmunn rmunn requested a review from hahn-kev August 8, 2024 04:52
Copy link
Collaborator

@hahn-kev hahn-kev left a comment

Choose a reason for hiding this comment

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

great work Robin, it looks good to me!

@rmunn
Copy link
Contributor Author

rmunn commented Aug 9, 2024

Closing and reopening to kick CodeQL into working right.

@rmunn rmunn closed this Aug 9, 2024
@rmunn rmunn reopened this Aug 9, 2024
@rmunn rmunn merged commit 7630ed0 into develop Aug 9, 2024
24 checks passed
@rmunn rmunn deleted the feat/search-projects-in-org-by-lang-tag branch August 9, 2024 02: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
2 participants