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

NAS-132667 / 25.04 / Come up with a reusable component for master-detail view #11096

Merged
merged 10 commits into from
Nov 26, 2024

Conversation

AlexKarpov98
Copy link
Contributor

@AlexKarpov98 AlexKarpov98 commented Nov 25, 2024

Testing:
see ticket.

I used slots for presentational logic:

<ng-content select="[header]"></ng-content>

<div class="container">
  <div class="table-container">
    <ng-content select="[master]"></ng-content>
  </div>

  <div
    ixDetailsHeight
    class="details-container"
    [class.details-container-mobile]="showMobileDetails()"
  >
    <ng-content select="[detail]"></ng-content>
  </div>
</div>

So in instances we need to define expected slots:

<ix-master-detail-view
  #masterDetailView="masterDetailViewContext"
>
  <ix-page-header header>
    <ix-all-instances-header></ix-all-instances-header>
  </ix-page-header>

  <ix-instance-list
    master
    [isMobileView]="masterDetailView.isMobileView()"
    [showMobileDetails]="masterDetailView.showMobileDetails()"
    (toggleShowMobileDetails)="masterDetailView.toggleShowMobileDetails($event)"
  ></ix-instance-list>

  <ng-container detail>
    @if (selectedInstance()) {
      <ix-instance-details
        [instance]="selectedInstance()"
        (onCloseMobileDetails)="masterDetailView.toggleShowMobileDetails(false)"
      ></ix-instance-details>
    }
  </ng-container>
</ix-master-detail-view>

Additional fixes/improvements:


-- fixed [ixDetailsHeight] directive. (I noticed it was jumpy. Visually it was pretty glitchy because scrollbar was added to the main wrapper container and after a fraction of a second it was removed because details container received height which instead put the scrollbar on the details container itself)

-- Fixed Instances selection (previously we double clicked the table row to view instance details)

@AlexKarpov98 AlexKarpov98 self-assigned this Nov 25, 2024
@AlexKarpov98 AlexKarpov98 requested a review from a team as a code owner November 25, 2024 11:41
@AlexKarpov98 AlexKarpov98 requested review from bvasilenko and removed request for a team November 25, 2024 11:41
@bugclerk
Copy link
Contributor

@bugclerk bugclerk changed the title NAS-132667: Come up with a reusable component for master-detail view NAS-132667 / 25.04 / Come up with a reusable component for master-detail view Nov 25, 2024
Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.34%. Comparing base (7ad0021) to head (1fd209c).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #11096   +/-   ##
=======================================
  Coverage   82.34%   82.34%           
=======================================
  Files        1643     1644    +1     
  Lines       57484    57530   +46     
  Branches     5930     5936    +6     
=======================================
+ Hits        47333    47373   +40     
- Misses      10151    10157    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@undsoft undsoft left a comment

Choose a reason for hiding this comment

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

Looks nice and works well.

When I wrote about having a tag for a header, I meant the header in details view. The idea was to try to hide the whole mobile business, so that developer that consumes this component does not have to care about mobile back button.

E.g. something similar to this:

<ix-page-header header>
  <ix-all-instances-header></ix-all-instances-header>
</ix-page-header>

<ix-master-detail-view
  #masterDetailView="masterDetailViewContext"
>

  <ix-instance-list master></ix-instance-list>

  <ng-container detail>
    @if (selectedInstance()) {
      <div detailHeader>
        <!-- detailHeader renders mobile-back-button and wires communication with masterDetailView -->
        <!-- custom html is also possible for icons on Datasets page -->
        {{ 'Details for {name}' | translate: { name: selectedInstance().name } }}
      </div>

      <ix-instance-details
        [instance]="selectedInstance()"
      ></ix-instance-details>
    }
  </ng-container>
</ix-master-detail-view>

<ix-master-detail-view
#masterDetailView="masterDetailViewContext"
>
<ix-page-header header>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think page header needs to be part of this directive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, yeah, I got you.
Thanks, I'll fix that.

@AlexKarpov98 AlexKarpov98 merged commit 95d6d15 into master Nov 26, 2024
11 checks passed
@AlexKarpov98 AlexKarpov98 deleted the NAS-132667 branch November 26, 2024 22:06
@bugclerk
Copy link
Contributor

This PR has been merged and conversations have been locked.
If you would like to discuss more about this issue please use our forums or raise a Jira ticket.

@truenas truenas locked as resolved and limited conversation to collaborators Nov 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants