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

Add ability to customize feature detail fields with configuration expressions #1987

Closed
wants to merge 3 commits into from

Conversation

cmdcolin
Copy link
Collaborator

This is a way to provide customization to the feature detail panels without making a plugin+ making a custom display type + making a custom widget panel

It allows a jexl expression instead in the config so that you can have something like this

jexl:{hello:'world'}

This would add a field called hello with value world to the feature details

You can also stitch together multiple attributes, or rewrite existing fields. It uses object spread which will overwrite fields or create new ones. This can be used to make links

Example here

jexl:{civicdb:'<a target=\"_blank\" href=https://civicdb.org/events/genes/'+feature.gene_id+'/summary/variants/'+feature.id+'/summary>Link to CIVIC</a>'}

This is possibly a bit verbose if you want to provide multiple customization, as it is all contained in one field and possibly on a single line in json. Users facing this issue could make a plugin that adds some custom jexl expressions and then possibly it could look just like this

 jexl:{civicdb: generateCivicLink(feature), otherfield: generateOtherField(feature)}

@cmdcolin cmdcolin marked this pull request as draft May 18, 2021 15:38
@github-actions github-actions bot added the needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) label May 18, 2021
@codecov
Copy link

codecov bot commented May 18, 2021

Codecov Report

Merging #1987 (b90586e) into main (d690c35) will increase coverage by 0.50%.
The diff coverage is 77.77%.

❗ Current head b90586e differs from pull request most recent head 0c4db06. Consider uploading reports for the commit 0c4db06 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1987      +/-   ##
==========================================
+ Coverage   60.87%   61.38%   +0.50%     
==========================================
  Files         473      470       -3     
  Lines       22549    22228     -321     
  Branches     5244     5109     -135     
==========================================
- Hits        13727    13644      -83     
+ Misses       8539     8309     -230     
+ Partials      283      275       -8     
Impacted Files Coverage Δ
packages/core/BaseFeatureWidget/index.ts 75.00% <ø> (ø)
...re/pluggableElementTypes/models/baseTrackConfig.ts 58.33% <ø> (ø)
...aseLinearDisplay/models/BaseLinearDisplayModel.tsx 79.52% <ø> (ø)
products/jbrowse-web/src/jbrowseModel.js 56.84% <ø> (ø)
...kages/core/BaseFeatureWidget/BaseFeatureDetail.tsx 77.02% <77.77%> (-0.28%) ⬇️
products/jbrowse-web/src/SessionWarningDialog.tsx 0.00% <0.00%> (-55.56%) ⬇️
packages/core/PluginLoader.ts 25.64% <0.00%> (-28.21%) ⬇️
products/jbrowse-web/src/Loader.tsx 56.00% <0.00%> (-5.65%) ⬇️
...gnments/src/CramAdapter/CramSlightlyLazyFeature.ts 79.89% <0.00%> (-5.53%) ⬇️
packages/core/rpc/BaseRpcDriver.ts 79.79% <0.00%> (-5.36%) ⬇️
... and 58 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d690c35...0c4db06. Read the comment docs.

@rbuels rbuels added discuss in meeting enhancement New feature or request and removed needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) labels May 19, 2021
@rbuels rbuels marked this pull request as ready for review May 26, 2021 17:22
@rbuels
Copy link
Contributor

rbuels commented May 26, 2021

grooming just now: how bout we add a little bit of doc in the config guide and then merge

@cmdcolin
Copy link
Collaborator Author

some possible considerations that are not necessarily addressed by this

  1. modifying subfeature detail fields, it may be possible but difficult to do with the current method proposed here, would probably require a custom jexl.addFunction

  2. if you want to modify e.g. the name field, then this literally mutates the feature data and so for something like this:

    "extraFields": "jexl:{name:'<a target="_blank" href=http://google.com/?q='+feature.name+'>Search '+feature.name+' on Google'}"

then it looks like this

localhost_3000__config=test_data%2Fvolvox%2Fconfig json session=local-vb-K00cGO (1)

not sure how to solve gracefully, could hack in a workaround like keeping track of core details on a separate object but sort of tricky to make a nice elegant solution

@rbuels rbuels marked this pull request as draft June 2, 2021 17:37
@cmdcolin
Copy link
Collaborator Author

this one appears to have been frozen following discussions and will be rebooted in some separate way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants