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

Pages Editor: implement Associated Subject Sets & fetch more data #7048

Merged
merged 15 commits into from
Mar 1, 2024

Conversation

shaunanoordin
Copy link
Member

@shaunanoordin shaunanoordin commented Feb 23, 2024

PR Overview

Part of: Pages Editor MVP project and FEM Lab super-project
Follows #7046
Staging branch URL: https://pr-7048.pfe-preview.zooniverse.org/lab/1982/workflows/editor/3711?env=staging

This PR implements the "Associated Subject Sets" feature on the Workflow Settings sub-page.

  • New component: AssociatedSubjectSets.
  • New behaviour/feature: on Pages Editor (for any Workflow) -> Workflow Settings...
    • The Associated Subject Sets feature should list all Subject Sets available to the Project (caveat: up to a max of 250. Paging may be a future problem to solve.)
    • The Associated Subject Sets feature (and no, I will not shorten it to an acronym) should show which Subject Sets are linked to the Workflow via ticked checkboxes.
    • Clicking on the checkboxes should link/unlink Subject Sets to/from the Workflow.

Also, some background work was required to fetch the Subject Sets, so the DataManager was updated as well.

  • Updated behaviour: DataManager now fetches the project resource.
  • Misc update: the Preview Workflow link now works as intended.

Screenshot: example workflow with 3 available subject sets, 2 of which are linked.

image

Testing

  • Open the staging URL. You should be looking at a test workflow (e.g. staging wf 3711)
  • Click on the Workflow Settings tab/button to view the sub-page.
  • Look for the Associated Subject Sets feature.
    • It should list all available subject sets, and show which ones are already linked.
    • Click on a subject set to link/unlink them
    • Reload the page to confirm
    • Expectation: you should be able to link or unlink as many sets as you want. Changes should be committed to Panoptes.

Status

Ready for review!

This PR is currently targeting pages-editor-pt14 for review purposes. Do not merge until 6974 is ready and this branch's merge is re-targeted to master.

@shaunanoordin shaunanoordin requested a review from a team February 23, 2024 18:14
@kieftrav kieftrav requested review from kieftrav and removed request for a team February 27, 2024 13:55
Copy link
Contributor

@kieftrav kieftrav left a comment

Choose a reason for hiding this comment

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

LGTM with only a couple comments. One thing I wanted to surface is that I expected refreshing the page to keep me on the same tab "workflow settings".. Is this a bug? Or desired behavior? Personally, when a tab changes 50%+ of the page I assume refreshing the page / pushing the back button will take me back to the previous state. In this case, the back button also doesn't take me back to the "workflow settings" tab. This also might be future work so take this comment as is helpful!

workflow: null,
status: 'error'
});
}
}

fetchWorkflow();
fetchProjectAndWorkflow();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want an await here?

Copy link
Member Author

Choose a reason for hiding this comment

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

An await is not needed here, as we want the fetch action to run asynchronously in the background; the state.apiData.status is set to fetching so users get to see a loading message while the data fetch occurs. 👌

@@ -140,7 +140,8 @@ export default function TasksPage() {
update({ tasks: newTasks });
}

const previewUrl = 'https://frontend.preview.zooniverse.org/projects/darkeshard/example-1982/classify/workflow/3711?env=staging';
const previewEnv = getPreviewEnv();
const previewUrl = `https://frontend.preview.zooniverse.org/projects/${project?.slug}/classify/workflow/${workflow?.id}${previewEnv}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we maybe do something different here if there isn't a project slug and workflow id? Because if its missing and it gets clicked on I would rather it send them somewhere predictable/debuggable instead of a default weird url with null/undefined/ect in it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me think about this. 🤔

You're right that a URL like https://frontend.preview.zooniverse.org/projects/undefined/classify/workflow/undefined would be pretty wonky. But it's a fairly safe assumption every project has a slug and every workflow has an ID. But but it's still good to have a safety for when those assumptions bork.

@@ -230,3 +231,21 @@ export default function TasksPage() {
</div>
);
}

function getPreviewEnv() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function feels too important to bury in a file... I'd personally want something like this (with clear exceptions / responsive to our development URL schema) surfaced a bit higher. I'ts own file, part of a helper, or something that makes its purpose more surfaceable.

});

} catch (err) {
console.error('AssosicatedSubjectSets: ', err);
Copy link
Contributor

Choose a reason for hiding this comment

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

Misspelling and would be useful to indicate its an error in the console.log(). I personally like using the following format:

console.log("AssociatedSubjectSets() fetchSubjectSets() error", err);

That way you have a guide in the console on how to find that console log (my future self really appreciates these guideposts). Only a suggestion though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Derp! I definitely need to fix that misspelling, thank you.

And thank you for the suggestion, I might also need to revise how I write our error messages. (At the moment I'm making the standards up as I go.)

Base automatically changed from pages-editor-pt14 to master February 29, 2024 16:04
@shaunanoordin
Copy link
Member Author

Thanks Travis! I'm going to rebase, then address some of the smaller feedback in this PR, before merging. 👍

To respond to the point you raised:

I expected refreshing the page to keep me on the same tab "workflow settings".

Good point. Perhaps ideally, each "tab" should be its own sub-page with a URL, like https://local.zooniverse.org:3735/lab/1982/workflows/editor/3711/workflow-settings. However, at the moment the constraint I've imposed on myself is that the PagesEditor should be as self-contained as possible, so using a single path (/lab/PROJECT_ID/workflows/editor/WORKFLOW_ID) for all the PagesEditor tabs/sub-pages/features allows me to side step adding router dependencies inside the PagesEditor (which would've been somewhat annoying should we plan to port this to FEM.)

EDIT: Wait, a thought occurs: ?tab=workflowSettings param instead of /workflow-settings subpath to circumvent having to use react-router? Worth experimenting with later.

@coveralls
Copy link

coveralls commented Feb 29, 2024

Coverage Status

coverage: 56.98%. remained the same
when pulling 8dc7206 on pages-editor-pt15
into a8bcd3d on master.

@shaunanoordin shaunanoordin enabled auto-merge (squash) March 1, 2024 12:21
@shaunanoordin shaunanoordin merged commit 6742908 into master Mar 1, 2024
5 checks passed
@shaunanoordin shaunanoordin deleted the pages-editor-pt15 branch March 1, 2024 12:23
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.

None yet

3 participants