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

[core/public/banners] migrate ui/notify/banners #23215

Closed

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Sep 15, 2018

Part of #19992, in order for the banners to be rendered above the navigation when we move the chrome out of the legacy platform the banners need to also be rendered by the new platform. The API hasn't changed at all.

@spalger spalger added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform v7.0.0 v6.5.0 labels Sep 15, 2018
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@spalger spalger requested a review from azasypkin September 15, 2018 21:37
@spalger spalger added the review label Sep 15, 2018
@spalger spalger requested a review from epixa September 15, 2018 21:37
@azasypkin
Copy link
Member

ack: on community duty today, will take a look today or tomorrow at the latest.

Copy link
Contributor

@epixa epixa left a comment

Choose a reason for hiding this comment

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

Code looks good. I did a pass on the implementation and found some things that I left comments on. I haven't tested it locally yet.

src/core/public/notifications/banners/banners_service.tsx Outdated Show resolved Hide resolved
return (
<div className="globalBanner__list">
{banners.map(({ id, component, priority, ...rest }) => (
<div key={id} className="globalBanner__item" {...rest}>
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Is there a plan to add this stuff to EUI?

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 think so, the banners themselves are really what I think we should focus on moving to EUI, but as you see here they are passed in fully styled. I tried moving the divs here to use <EuiFlexGroup />, but since we need refs we have issues there, so I didn't think it was worth the effort right now.

@spalger spalger force-pushed the migrate-new-platform/global-banners branch from 9956a17 to fc52d56 Compare September 18, 2018 12:12
@spalger spalger force-pushed the migrate-new-platform/global-banners branch from 7b9f49b to d90a6e7 Compare September 18, 2018 12:15
@elasticmachine
Copy link
Contributor

💔 Build Failed

@azasypkin
Copy link
Member

azasypkin commented Sep 18, 2018

CI is failing because of failed i18n check that is caused by the outdated @babel/parser beta package (see this 🙈), bumping it up solves the problem. @maryia-lapata created #23268 for that.

@elasticmachine
Copy link
Contributor

💔 Build Failed


export const banners = {
/**
* Add a new banner.
*
* @param {Object} component The React component to display.
Copy link
Member

Choose a reason for hiding this comment

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

optional nit: JSDoc here and in set is completely invalid, there is a banner argument with component property, optional priority argument, no need in JSDoc types etc., but since it was here before feel free to keep it as is.

@@ -1,360 +0,0 @@
# Banners
Copy link
Member

Choose a reason for hiding this comment

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

question: is this README completely irrelevant now so that we remove it?

notifications.start();
notifications.stop();

expect(BannersService.prototype.stop).toHaveBeenCalledTimes(1);
Copy link
Member

Choose a reason for hiding this comment

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

question: what is the value in these two toHaveBeenCalled.... asserts? It seems what you want to check will be enforced by the expect.assertions(...); anyway?

export { Banners, Banner, BannersService, BannersStartContract } from './banners_service';
Copy link
Member

Choose a reason for hiding this comment

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

question: do you really need to re-export anything except for BannersService and BannersStartContract?

private unrenderBanner?: () => void;

public componentDidMount() {
if (!this.ref.current) {
Copy link
Member

Choose a reason for hiding this comment

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

optional nit: we repeat very similar piece of code twice, would it make sense to move some logic into, let's say, renderBanner and reuse it in both componentDidMount and componentDidUpdate?

private renderBanner() {
	if (this.unrenderBanner) {
	  this.unrenderBanner();
	}

	if (!this.ref.current) {
	  throw new Error('<GlobalBanner /> mounted without ref');
	}

	this.unrenderBanner = this.props.banner.render(this.ref.current) || undefined;
}

.globalBanner__list {
padding: 16px;
}

.globalBanner__item + .globalBanner__item {
Copy link
Member

Choose a reason for hiding this comment

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

note: wondering how bad is just .globalBanner__item { margin-botton: 16px; } so that we resort to +...


import { Banners } from '../banners_service';
import { GlobalBannerList } from '../components/global_banner_list';
import './global_banner_list.css';

This comment was marked as resolved.

This comment was marked as resolved.

const component = shallow(<GlobalBannerList banners={[]} />);
expect(component).toMatchInlineSnapshot(`
<div
className="globalBanner__list"
Copy link
Member

Choose a reason for hiding this comment

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

question: className looks weird, should it be class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Huh, thanks for the link!

@azasypkin
Copy link
Member

Code looks good, I want to test it locally though. Also CI failures look legit this time, could you please check?

@elasticmachine
Copy link
Contributor

💔 Build Failed

@spalger
Copy link
Contributor Author

spalger commented Sep 19, 2018

Okay, I was totally wrong about the need to do this right now. Banners are actually shown inside the app container (not outside the chrome) so we can't even do this until we start rendering the chrome via the new platform. Because of that I'm going to close this for now so I'm closing this until later.

@spalger spalger closed this Sep 19, 2018
@spalger spalger deleted the migrate-new-platform/global-banners branch August 18, 2020 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform review Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v6.5.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants