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: Public layout component #3208

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

Conversation

georgylobko
Copy link
Contributor

@georgylobko georgylobko commented Jan 21, 2025

Description

doc: tb1MA6m8ZZEt

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 98.43750% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.43%. Comparing base (d6733f7) to head (587732c).

Files with missing lines Patch % Lines
src/app-layout-toolbar/index.tsx 97.56% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3208   +/-   ##
=======================================
  Coverage   96.42%   96.43%           
=======================================
  Files         791      793    +2     
  Lines       22605    22659   +54     
  Branches     7814     7839   +25     
=======================================
+ Hits        21797    21851   +54     
  Misses        754      754           
  Partials       54       54           

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These styles were copied from pages/app-layout

…mponent

# Conflicts:
#	src/__tests__/snapshot-tests/__snapshots__/test-utils-wrappers.test.tsx.snap
@@ -0,0 +1,169 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

This content is not connected to anything in app layout, so I think it is fine to reuse it instead of copying

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 42 to 45
const isToolbar = useAppLayoutToolbarEnabled();
const isToolbarPrivate = useAppLayoutToolbarEnabled();
const isToolbarPublic = useContext(AppLayoutToolbarPublicContext) ?? false;
const isToolbar = isToolbarPublic || isToolbarPrivate;
Copy link
Member

Choose a reason for hiding this comment

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

Did you count how many times we the combined condition isToolbarPublic || isToolbarPrivate? Would it be better to have a reusable utility for this 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.

I think it's a case when keeping this condition explicit would be more helpful than abstracting it out. Do you think it's worth to do it?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it is definitely worth to have a reusable utility that gives you "we are under app layout toolbar" value with a one-line import

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +17 to +24
beforeEach(() => {
globalWithFlags[Symbol.for('awsui-visual-refresh-flag')] = () => true;
});

afterEach(() => {
delete globalWithFlags[Symbol.for('awsui-visual-refresh-flag')];
clearVisualRefreshState();
});
Copy link
Member

@just-boris just-boris Feb 13, 2025

Choose a reason for hiding this comment

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

I think these changes in src/__tests__/** files is another instance of something to extract as a separate PR and merge before the main one lands.

P.S. I think we also need to send a PSA to our team that the default behavior of these tests changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These conditions (set refresh feature flag before running the tests suites) make sense only for this PR as it checks the AppLayoutToolbar component for classic theme. What exactly would you suggest to do? Implement these feature flag via useVisualRefresh and then change it as a follow-up PR to separate concerns?

On the one hand it makes sense, on the other hand, I would go ahead as is and let our team know about this decision. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

With this change we switch tests to use VR version by default, for all components. not only app layout.

So I suggest making this switch as a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to useVisualRefresh. I'll switch it back to globalWithFlags[Symbol.for('awsui-visual-refresh-flag')] in a separate PR

Copy link
Member

Choose a reason for hiding this comment

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

Discussed offline, let's undo the change about useVisualRefresh and keep it this way until the PR is merged

@@ -7,6 +7,7 @@ import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
import { awsuiPluginsInternal } from '../../internal/plugins/api';
import { RegistrationState } from '../../internal/plugins/controllers/app-layout-widget';
import { AppLayoutProps } from '../interfaces';
import { useAppLayoutToolbarEnabled } from '../utils/feature-flags';
Copy link
Member

Choose a reason for hiding this comment

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

Let's rename these hooks

  • useAppLayoutFlagEnabled – the feature flags are active (for all advanced deduplication features)
  • useAppLayoutToolbarDesignEnabled - same as above, but also true when toolbar is used standalone

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +17 to +24
beforeEach(() => {
globalWithFlags[Symbol.for('awsui-visual-refresh-flag')] = () => true;
});

afterEach(() => {
delete globalWithFlags[Symbol.for('awsui-visual-refresh-flag')];
clearVisualRefreshState();
});
Copy link
Member

Choose a reason for hiding this comment

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

Discussed offline, let's undo the change about useVisualRefresh and keep it this way until the PR is merged

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.

3 participants