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

Edit workflow request when queried depending on role or project setting #3648

Merged
merged 4 commits into from
Mar 27, 2017

Conversation

mcbouslog
Copy link
Contributor

@mcbouslog mcbouslog commented Mar 24, 2017

Temporary Alternative: see branch disable-test-workflow

Fixes broken Test Workflow button from workflow editor in lab.

If a workflow query in url and admin/owner/collaborator remove active: true from workflow request to allow viewing of inactive workflow, i.e. via Test Workflow button from lab.

If a workflow query in url and project settings allow workflow queries, try to get requested workflow, but if inactive then remove query and proceed through other workflow determining steps.

Review Checklist

Optional

  • If it's a new component, is it in ES6? Is it clear of warnings from ESLint?
  • Have you replaced any ChangeListener or PromiseRenderer components with code that updates component state?
  • If changes are made to the classifier, does the dev classifier still work?
  • Have you added in flow type annotations?

@mcbouslog
Copy link
Contributor Author

mcbouslog commented Mar 24, 2017

On staging:
as collaborator, admin mode off or on: Test Workflow button in inactive workflow works

On production (https://test-workflow-fix.pfe-preview.zooniverse.org/projects/zooniverse/notes-from-nature/classify?env=production&workflow=3758):
with admin mode on: Test Workflow button in inactive workflow works
with admin mode off, just as collaborator: Test Workflow button in inactive workflow doesn't work, unsure why (issue with staging branch pointing to production, or maybe checkUserRoles is returning false before properly completing)

if @props.location.query?.workflow? and @checkUserRoles(project, @props.user)
selectedWorkflowID = @props.location.query.workflow
activeFilter = false
unless preferences?.preferences.selected_workflow is selectedWorkflowID
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally wouldn't update user workflow preference if accessing workflow vie workflow query and admin/owner/collab, but if I remove this I think an infinite loop is triggered in componentWillUpdate because the preferences don't match, that keeps requesting the same workflow from API.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we still want this behavior even if admin/owner/collab because that user might just be wanting to classify on their own project and storing the workflow id in the prefs means it'll load up the correctly selected workflow if they browse between talk and back, etc. If they revisit w/o the query param for the workflow, the behavior will clear out the workflow from their prefs if inactive.

@srallen
Copy link
Contributor

srallen commented Mar 24, 2017

I'm not seeing an issue with the workflow query param for a project that I'm a collab on in production. What's the specific error you're seeing?

@@ -230,7 +240,7 @@ ProjectPageController = React.createClass

checkUserRoles: (project, user) ->
currentUserRoleSets = @state.projectRoles.filter((roleSet) => roleSet.links.owner.id is user.id)
Copy link
Contributor

Choose a reason for hiding this comment

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

This line will still need an existential check on the user: user?.id. Trying the workflow query param when logged out is broken otherwise.

@mcbouslog
Copy link
Contributor Author

mcbouslog commented Mar 24, 2017

Just as a collaborator when I try https://test-workflow-fix.pfe-preview.zooniverse.org/projects/zooniverse/notes-from-nature/classify?env=production&workflow=3758 it goes through the second getSelectedWorkflow condition, like I'm a regular user, expectedly can't find the workflow (because it's only looking for active: true ones), then truncates the url and loads a random workflow.

I tried (Test Workflow button on inactive workflow as a collaborator) on a different production project and it did work though, so it must be NfN related, though not sure it's due to related project setting or size of NfN.

@mcbouslog
Copy link
Contributor Author

Turns out it was that there are more than 20, the default page_size, project roles for NfN, and mine was not in ones returned, so thought I was regular volunteer and putting me in second conditional. I think I've updated with a fix.

@camallen
Copy link
Contributor

should we just allow filtering of the project roles with the user_id instead of fetching pages of data and looking through it? Possibly related to zooniverse/panoptes#1575

@mcbouslog
Copy link
Contributor Author

mcbouslog commented Mar 25, 2017

Removed unnecessary page_size increase. By including user_id in the request an increased page_size isn't necessary.

If user_id is undefined all project roles are returned, which in NfN's case would be 20 roles out of 30 without a change to the default page_size, but that's fine because this is a situation where the user isn't signed in, so whether there are 20 or all roles returned there will never be a matching role to no user.

@camallen - let me know if I've misinterpreted, but I think this addresses your comment?

@mcbouslog
Copy link
Contributor Author

I plan to add a conditional to check if user is defined before even requesting projectRoles, so if there's no user the request is never made, and see how that works, or if there are any other requests that could be refactored similarly, but unsure if that will work, thinking about it from memory not actually looking at the code at the moment.

@srallen
Copy link
Contributor

srallen commented Mar 25, 2017

@mcbouslog having the project roles in the project controller state is useful whether there is a logged in user or not. My intention of requesting it as an include with the project was to eventually eliminate a few places where it is redundantly called on other project pages, such as the team listing on the about pages.

Most projects probably don't have more than 20 roles on them. NfN is again probably unique in this. Increasing the page size is a sufficient interim fix. We can refactor once improvements are made, like querying with user id or project role name to determine if the logged in user is a collab.

@mcbouslog
Copy link
Contributor Author

mcbouslog commented Mar 26, 2017

@srallen - makes sense and sounds good to me, I added back the page_size: 50 and removed the user_id from the request. I left the project_roles in the project request include, as that sounds like part of the long-term intent.

I'm sure intentional, but thought I'd note the project.links for subject_sets and workflows appear to have all related resource IDs, but project_roles only has the usual API default size of 20. If project.links.project_roles also had all, I think the project_roles request as currently written which requests an array of project role IDs would work as well, without the page_size: 50.

@camallen
Copy link
Contributor

Understood @srallen - page_size limit increase works (for a while) if you need the resources elsewhere. The lab page could access check could use the specific filter query for the logged in user but that can come later.

@mcbouslog mcbouslog changed the title [WIP] edit workflow request when queried depending on role or project setting Edit workflow request when queried depending on role or project setting Mar 27, 2017
@srallen srallen merged commit 4f22764 into master Mar 27, 2017
@srallen srallen deleted the test-workflow-fix branch March 31, 2017 14:54
rogerhutchings pushed a commit that referenced this pull request Apr 3, 2017
…ng (#3648)

* add activeFilter, separate workflow query by role vs project setting

* edit project_roles request page_size

* remove page_size increase

* edit project_roles request - increase page_size, remove user_id
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.

3 participants