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

Go cam viz #823

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

Go cam viz #823

wants to merge 84 commits into from

Conversation

dlrice
Copy link
Contributor

@dlrice dlrice commented Oct 24, 2024

Note

  • Delay merge until start of February when new wc-gocam-viz released which addresses many issues.
  • Once merged delete this out of date manual file: gene_ontology

Purpose

Add wc-gocam-viz to uniprotkb entry page.

Approach

  • Request gocam ids from api.geneontology.org
  • If we have some then show a tab with Go-Cam viz
  • Use TreeSelect for user selection of go-cam id
  • Also use TreeSelect for Complex Viewer ui

Testing

Updated existing test.

Checklist

  • My PR is scoped properly, and “does one thing only”
  • I have reviewed my own code
  • I have checked that linting checks pass and type safety is respected
  • I have checked that tests pass and coverage has at least improved, and if not explained the reasons why

Copy link
Contributor

@aurel-l aurel-l left a comment

Choose a reason for hiding this comment

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

Maybe some things to check regarding nesting of components and lazy-loading of logic, and to keep it consistent with the ComplexViewer in the interaction section.

@dlrice
Copy link
Contributor Author

dlrice commented Nov 1, 2024

I've fixed the lazy loading/duplicate tabs issues and also pushed as go ribbon and go-cam sharing tabs for now. The tabs changes are all in one commit so easy to revert if needed.

Comment on lines +13 to +16
useEffect(() => {
goCamVizLoader.defineCustomElements();
customElements.whenDefined('wc-gocam-viz').then(() => {
setDefined(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Async state-setting logic within a useEffect is something to watch out for. Their could be the case of the promise resolving after the component has unmounted, and then it'll try to set a state for a component that doesn't exist anymore.
Maybe use useSafeState instead of useState.
Have a look at the logic in useCustomElement, which internally uses useSafeState to do similar things that you're doing here. useSafeState is basically a wrapper to make sure that there is no set state when the component is unmounted.

Comment on lines 64 to 83
async function fetchGoCamModels() {
if (goCamIdToItem.size) {
const mapper = (id: string) =>
fetchData<GoCamModelInfo>(
externalUrls.GeneOntologyModelInfo(id)
).then((response) => ({
id,
data: response.data,
}));
const results = await pMap(Array.from(goCamIdToItem.keys()), mapper, {
concurrency: heuristic.concurrency,
});
setUniprotGoCamIds(
results
.filter(({ data }) => isUniprotCurated(data))
.map(({ id }) => id)
);
}
}
fetchGoCamModels();
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as in GoCamViz.tsx regarding state setting in async logic. use useSafeState.

Also use one single AbortController both for each fetch and for p-map (look for signal in the documentation https://www.npmjs.com/package/p-map ). Look in the codebase for controller.abort() to see example usage.
This will also to stop current and subsequent fetches if the user changes page or switch the tab back

@aurel-l
Copy link
Contributor

aurel-l commented Feb 18, 2025

Playing with the UI I've just realised that most of the content in the panel on the right is links, and most of those links are to other websites. I don't really like that we have a fairly big section of UI that behaves completely differently than the rest of the website

Mouse cursor but no UI indicator of a link make the user think it might be a button with an action on the current page. It would be better that all link use the bold/blue style that we use for links elsewhere. That would probably require a change of style for the clicked section otherwise the links would blend into the selected background (change background colour? Just have a border to show selection?).

Also, external links not marked as such is a big problem, especially when some of the concepts links do already exist in UniProt (e.g. "part of" or "occurs in" values that look like they could be UniProt subcell locations or keywords).
We do use mask-image to inject the external link image in some places, so maybe that could be reused here?

I'm not entirely sure what is doable or not though, given that it's all within custom elements that will be a bit more complicated to style.

const cancelTokenSource = axios.CancelToken.source();
const abortController = new AbortController();
const { signal } = abortController;
signal.addEventListener('abort', () => {
Copy link
Contributor

@aurel-l aurel-l Feb 20, 2025

Choose a reason for hiding this comment

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

I was wondering why that was needed, but I see the axios cancel token logic above. It's one of these cases where using plain fetch would be easier as AbortController fits well into the native fetch logic.
No need to change here, just a comment from me now

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.

2 participants