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

feature(Mode): Ability to overwrite mode configuration and small improvements #3580

Merged
merged 11 commits into from Aug 8, 2023

Conversation

igoroctaviano
Copy link
Contributor

@igoroctaviano igoroctaviano commented Aug 7, 2023

Context

Allowing the override of mode's configuration through viewer config and small improvements.

Changes & Results

  • [Feature] Ability to override module configuration
  • [Improvement] Hardening of patientName util
  • [Improvement] Hardening default layout header's return click handler (validating dataSource before appending query params)
  • [Improvement] Only render display name button in the worklist if defined in the mode configuration
  • [Improvement] Pass appConfig to onModeExit and onModeEnter hooks

What are the effects of this change?

  • Before vs After
  • Screenshots / GIFs / Videos
    -->

Testing

Checklist

PR

  • [] My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • [] My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • [] The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • [] OS:
  • [] Node version:
  • [] Browser:

@netlify
Copy link

netlify bot commented Aug 7, 2023

Deploy Preview for ohif-dev ready!

Name Link
🔨 Latest commit
🔍 Latest deploy log https://app.netlify.com/sites/ohif-dev/deploys/650ba069752dff797ebc04b9
😎 Deploy Preview https://deploy-preview-3580--ohif-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Aug 7, 2023

Deploy Preview for ohif-platform-docs ready!

Name Link
🔨 Latest commit 1ca97e6
🔍 Latest deploy log https://app.netlify.com/sites/ohif-platform-docs/deploys/64d246147d71db0008edfe88
😎 Deploy Preview https://deploy-preview-3580--ohif-platform-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Merging #3580 (1ca97e6) into master (72207e6) will decrease coverage by 0.06%.
Report is 2 commits behind head on master.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3580      +/-   ##
==========================================
- Coverage   42.93%   42.87%   -0.06%     
==========================================
  Files          80       80              
  Lines        1444     1446       +2     
  Branches      338      339       +1     
==========================================
  Hits          620      620              
- Misses        661      662       +1     
- Partials      163      164       +1     
Files Changed Coverage Δ
platform/core/src/utils/formatPN.js 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

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

@cypress
Copy link

cypress bot commented Aug 7, 2023

Passing run #3417 ↗︎

0 36 0 0 Flakiness 0

Details:

Add note to doc
Project: Viewers Commit: 1ca97e61e0
Status: Passed Duration: 03:08 💡
Started: Aug 8, 2023 1:48 PM Ended: Aug 8, 2023 1:51 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

- Example config:
```js
modesConfiguration: {
['@ohif/mode-longitudinal']: {
Copy link
Member

Choose a reason for hiding this comment

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

why it is an array here?

Copy link
Member

Choose a reason for hiding this comment

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

It would be great if you can add an example of changing the mode path too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The array is just to define a property with special characters like the mode id (just a map).
I'll add more examples 👍

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why you can't say [{ '@ohif/mode-longitudinal': {...}, { '@ohif/mode-segmentation':{...}]

and you need to say ['@ohif/mode-longitudinal']

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand why you can't say [{ '@ohif/mode-longitudinal': {...}, { '@ohif/mode-segmentation':{...}]

and you need to say ['@ohif/mode-longitudinal']

I can use array but I think its a lot easier to use a map instead? so later I can just const config = modesConfiguration[modeId] instead of iterating the array looking for the config.

Copy link
Contributor

Choose a reason for hiding this comment

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

Furthermore, I am trying to test this PR and when I go to save the configuration js file, the ['@ohif/mode-longitudinal']: automatically changes to '@ohif/mode-longitudinal':.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not required to use the brackets, this is just an explicit way of doing it. I'll update the docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth mentioning in the docs that although the modeConfiguration is passed to the mode factory it is up to the particular mode itself if and how it applies the configuration? That is, for example, basic-dev-mode and basic-test-mode do not currently use this modeConfiguration. Just a thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, updated.

Copy link
Member

@sedghi sedghi left a comment

Choose a reason for hiding this comment

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

see my comments

@igoroctaviano
Copy link
Contributor Author

see my comments

Updated, is this what you meant?

// Todo: Handle parameters in a better way.
const query = new URLSearchParams(window.location.search);
const configUrl = query.get('configUrl');

const dataSourceName = pathname.substring(dataSourceIdx + 1);
const existingDataSource = extensionManager.getDataSources(dataSourceName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we anticipating a data source to be in the URL that is NOT an actual, configured data source? If so, under what circumstances would this occur? I am a bit confused as to why we need this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might have a mode that does not use /${mode.routeName}/${dataSourceName}. This means that my mode can rely on the defaultDataSource from the viewer config to define its dataSource. This way I don't need to add the datasources query param and change the defaultDataSource of the worklist coming from a random mode URL e.g. /myModeURL/otherParamWhichIsNotNecessarilyADataSourceName (no dataSource being used)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok cool. Thanks.

Copy link
Contributor

@jbocce jbocce 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. Approved.

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