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

feat(#7394): Incorporate Status Indicators into the main Vue app #7395

Merged
merged 21 commits into from
Jan 23, 2024

Conversation

ozyx
Copy link
Contributor

@ozyx ozyx commented Jan 21, 2024

Closes #7394

Describe your changes:

This is a bit of a refactor in order to support incorporating our Status Indicators into the main Vue app (AppLayout). This includes non-breaking changes to the IndicatorAPI which allow it to support directly rendering Vue components provided to the API either as Component objects themselves, or as HTMLElements (the original behavior, to be framework-agnostic). It introduces a new utility function vueWrapHtmlElement() that takes an HTMLElement and uses a render function to create an Anonymous Vue component to be dynamically rendered in the StatusIndicator bar.

This means:

  • We no longer create a new Vue app for each Indicator (slight perf boost, memory reduction)
  • All StatusIndicators are incorporated into the main Vue app (reactivity benefits)

This is an enhancement to support the VIPER S.A. work.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Is this change backwards compatible? For example, developers won't need to change how they are calling the API or how they've extended core plugins such as Tables or Plots.

Author Checklist

  • Changes address original issue?
  • Tests included and/or updated with changes?
  • Has this been smoke tested?
  • Have you associated this PR with a type: label? Note: this is not necessarily the same as the original issue.
  • Have you associated a milestone with this PR? Note: leave blank if unsure.
  • Is this a breaking change to be called out in the release notes?
  • Testing instructions included in associated issue OR is this a dependency/testcase change?

Reviewer Checklist

  • Changes appear to address issue?
  • Reviewer has tested changes by following the provided instructions?
  • Changes appear not to be breaking changes?
  • Appropriate automated tests included?
  • Code style and in-line documentation are appropriate?

- Adds a new property to Indicators, `component`, which is a synchronous or asynchronous Vue component.
- Adds `wrapHtmlElement` utility function to create anonymous Vue components out of `HTMLElement`s (for backwards compatibility)
- Refactors StatusIndicators.vue to use dynamic components, allowing us to dynamically render indicators (and keep it all within Vue's ecosystem).
- Refactors some indicators to use Vue components directly as async components
@ozyx ozyx added type:enhancement performance impacts or improves performance labels Jan 21, 2024
@ozyx ozyx added this to the Target:3.3.0 milestone Jan 21, 2024
Copy link

codecov bot commented Jan 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4cf6306) 55.88% compared to head (9a7eb7d) 55.98%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7395      +/-   ##
==========================================
+ Coverage   55.88%   55.98%   +0.09%     
==========================================
  Files         659      660       +1     
  Lines       26277    26282       +5     
  Branches     2549     2550       +1     
==========================================
+ Hits        14686    14715      +29     
+ Misses      10885    10857      -28     
- Partials      706      710       +4     
Flag Coverage Δ *Carryforward flag
e2e-full 41.03% <ø> (-0.05%) ⬇️ Carriedforward from 7178135
e2e-stable 60.14% <100.00%> (+0.07%) ⬆️
unit 48.93% <100.00%> (+0.10%) ⬆️

*This pull request uses carry forward flags. Click here to find out more.

Files Coverage Δ
src/api/indicators/IndicatorAPI.js 100.00% <100.00%> (ø)
...gins/clearData/components/GlobalClearIndicator.vue 100.00% <ø> (ø)
src/plugins/clearData/plugin.js 100.00% <ø> (ø)
src/plugins/clock/components/ClockIndicator.vue 75.00% <ø> (+3.57%) ⬆️
src/plugins/clock/plugin.js 61.11% <100.00%> (-7.08%) ⬇️
.../notebook/components/NotebookSnapshotIndicator.vue 75.00% <100.00%> (+0.92%) ⬆️
src/plugins/notebook/plugin.js 97.29% <ø> (-0.14%) ⬇️
...tionIndicator/components/NotificationIndicator.vue 84.61% <ø> (+15.38%) ⬆️
src/plugins/notificationIndicator/plugin.js 100.00% <ø> (ø)
src/ui/layout/AppLayout.vue 20.40% <100.00%> (ø)
... and 2 more

... and 5 files with indirect coverage changes


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 4cf6306...9a7eb7d. Read the comment docs.

Copy link
Collaborator

@unlikelyzero unlikelyzero left a comment

Choose a reason for hiding this comment

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

Great!

@@ -53,6 +53,9 @@ test.describe('LAD Table Sets', () => {

await page.goto(ladTableSet.url);

// Wait for the initial value to show after mount
await expect(page.getByLabel('lad value').first()).not.toContainText('---');
Copy link
Collaborator

Choose a reason for hiding this comment

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

We will need to factor out the use of first at some point

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 think it's ok if we're accessing a value in a table?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, seems rational here

@akhenry
Copy link
Contributor

akhenry commented Jan 23, 2024

Changes look good to me, thanks. Just needs some testing instructions. I tested this by verifying:

  • That the Notifications, Snapshots, Clear Data, and Clock indicators appear correctly, and still function as expected,
  • Verified that legacy HTML-based indicators still function as expected. I tested this by installing the performance indicator and verifying that it renders correctly when installed, and FPS values are updating and changing as expected.

The Performance Indicator can be installed like so:

openmct.install(openmct.plugins.PerformanceIndicator());

@unlikelyzero unlikelyzero modified the milestones: Target:3.3.0, Target:4.0.0 Jan 23, 2024
*/
add(indicator) {
if (!indicator.priority) {
indicator.priority = this.openmct.priority.DEFAULT;
}
if (!indicator.vueComponent) {
indicator.vueComponent = vueWrapHtmlElement(indicator.element);
Copy link
Contributor

@shefalijoshi shefalijoshi Jan 23, 2024

Choose a reason for hiding this comment

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

Does the element property for indicator objects still exist after removing the mount utility? See here: https://github.com/nasa/openmct/blob/vue-indicators/src/plugins/clearData/plugin.js#L34

Perhaps you need to create the indicator.element node here as well?

Copy link
Contributor Author

@ozyx ozyx Jan 23, 2024

Choose a reason for hiding this comment

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

@shefalijoshi Not for most of our default indicators. The idea is that if the vueComponent is provided to the indicator API, it will mount the component directly. Otherwise, it will look for the element property and wrap it in an anonymous Vue component, and then mount that. So one or the other is required here. If both vueComponent and element are missing, then we fail fast.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. Add some documentation around this in the API change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

are the existing docs ok? this just explains how to use the API, the implementation details shouldn't be important to the average user?

Copy link
Contributor

@scottbell scottbell left a comment

Choose a reason for hiding this comment

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

Looks great @ozyx - and much simpler! I had one question about the of -> on change that needs checking, but otherwise looks good.

Here are the new indicators in action:

Screen.Recording.2024-01-23.at.10.05.12.AM.mov

@@ -53,6 +53,9 @@ test.describe('LAD Table Sets', () => {

await page.goto(ladTableSet.url);

// Wait for the initial value to show after mount
await expect(page.getByLabel('lad value').first()).not.toContainText('---');
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, seems rational here

src/ui/layout/status-bar/StatusIndicators.vue Show resolved Hide resolved
src/utils/vueWrapHtmlElement.js Show resolved Hide resolved
@ozyx ozyx requested a review from scottbell January 23, 2024 16:04
@ozyx
Copy link
Contributor Author

ozyx commented Jan 23, 2024

Changes look good to me, thanks. Just needs some testing instructions.

Added testing instructions

Copy link
Contributor

@scottbell scottbell left a comment

Choose a reason for hiding this comment

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

LGTM

@ozyx ozyx added Target: VISTA R4.6 pr:e2e:couchdb npm run test:e2e:couchdb and removed Target: VISTA R4.6 labels Jan 23, 2024
@ozyx ozyx enabled auto-merge (squash) January 23, 2024 16:59
@github-actions github-actions bot removed the pr:e2e:couchdb npm run test:e2e:couchdb label Jan 23, 2024
@ozyx ozyx added the pr:e2e:couchdb npm run test:e2e:couchdb label Jan 23, 2024
@github-actions github-actions bot removed the pr:e2e:couchdb npm run test:e2e:couchdb label Jan 23, 2024
@ozyx ozyx disabled auto-merge January 23, 2024 18:10
@ozyx ozyx added the pr:e2e:couchdb npm run test:e2e:couchdb label Jan 23, 2024
@ozyx ozyx enabled auto-merge (squash) January 23, 2024 23:10
@github-actions github-actions bot removed the pr:e2e:couchdb npm run test:e2e:couchdb label Jan 23, 2024
@ozyx ozyx merged commit 1148644 into master Jan 23, 2024
21 checks passed
@ozyx ozyx deleted the vue-indicators branch January 23, 2024 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance impacts or improves performance type:enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorporate IndicatorAPI into the Vue reactivity system
5 participants