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(dialog): inital framework for md-dialog #761

Merged
merged 5 commits into from
Jul 14, 2016

Conversation

jelbourn
Copy link
Member

@jelbourn jelbourn commented Jun 24, 2016

R: @hansl @kara @robertmesserle
CC: @iveysaur

  • Adds the ability to pass a custom injector with ComponentPortal
  • Adds MdDialog service that can open a dialog (and literally nothing else). Additional APIs will come in subsequent PRs. Dialog is also yet unstyled.

The setTimeout hack in the dialog tests is an unfortunate consequence of an issue with either zones or (more likely) the testing infrastructure built on top of it. I'm going to sit down with Misko when he gets back from vacation to get to the root of it.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 24, 2016
import {Component, ComponentRef, ViewChild, AfterViewInit} from '@angular/core';
import {BasePortalHost, ComponentPortal, TemplatePortal} from '../../core/portal/portal';
import {PortalHostDirective} from '../../core/portal/portal-directives';
import {PromiseCompleter} from '../../core/async/promise-completer';
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't those imports use the NPM scope package instead?

As @hansl did in 9e308a6?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I just forgot to correct what WebStorm auto-imported. Fixed.

@@ -0,0 +1 @@
<template portalHost></template>
Copy link
Contributor

Choose a reason for hiding this comment

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

1 liner should probably be inlined.

Copy link
Member Author

Choose a reason for hiding this comment

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

There will be more; this is just the first PR

@robertmesserle
Copy link
Contributor

LGTM aside from the imports that @iveysaur pointed out (which happens in a few files).

* @returns A promise resolving to the MdDialogRef that should be returned to the user.
*/
private _attachDialogContent<T>(
component: {new (): T},
Copy link
Contributor

@hansl hansl Jun 28, 2016

Choose a reason for hiding this comment

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

This type differs than the component declaration above.

You should abstract this to:

export interface GenericType<T> {
  new (...args: any[]): T;
}
export type Type = GenericType<any>;

I tested it in your PR and it works as expected. Having a reusable interface for this will make it way more readable and avoid questions with this "weird" syntax.

@Lavan
Copy link

Lavan commented Jul 2, 2016

I think it could be useful to split this PR into two parts; one for the generic portal implentation and one for the dialog implementation that uses it. The reason for this split is simple to enable injection into portal objects as soon as possible without waiting for the dialog implementation which could take a while.

@jelbourn jelbourn force-pushed the dialog-concept branch 4 times, most recently from 9b551f5 to e71b56b Compare July 7, 2016 21:25
@jelbourn
Copy link
Member Author

jelbourn commented Jul 7, 2016

@robertmesserle @hansl addressed comments

// If there was an attempted call to `attachComponentPortal` before this lifecycle stage,
// we actually perform the attachment now that the `@ViewChild` is resolved.
if (this._deferredAttachCompleter) {
this.attachComponentPortal(this._deferredAttachPortal).then(componentRef => {
Copy link
Contributor

Choose a reason for hiding this comment

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

catch and reject?

@hansl
Copy link
Contributor

hansl commented Jul 7, 2016

Outside of the assertion and good citizenry regarding promises, LGTM.


/** Runs the necessary detectChanges for a dialog to complete its opening. */
function detectChangesForDialogOpen(fixture: ComponentFixture<ComponentWithChildViewContainer>) {
// TODO(jelbourn): figure out why the test zone is "stable" when where are still pending
Copy link
Contributor

Choose a reason for hiding this comment

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

where => there

@jelbourn
Copy link
Member Author

Comments addressed. Needs LGTM label so that caretaker knows to merge it.

@jelbourn jelbourn mentioned this pull request Jul 14, 2016

this._deferredAttachPortal = null;
this._deferredAttachCompleter = null;
}, () => this._deferredAttachCompleter.reject());
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: set to null?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@hansl
Copy link
Contributor

hansl commented Jul 14, 2016

LGTM.

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Jul 14, 2016
@kara kara merged commit 9552ed5 into angular:master Jul 14, 2016
@jonathan-casarrubias
Copy link

wahoo!!! 🎉

@jelbourn jelbourn deleted the dialog-concept branch September 13, 2017 04:33
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants