Giter Club home page Giter Club logo

ember-cli-flash's Introduction

ember-cli-flash

Download count all time npm version Ember Observer Score

Simple, highly configurable flash messages for ember.

This ember addon adds a flash message service and component to your app.

Table of Contents

Installation

ember install ember-cli-flash

Compatibility

This addon is tested against the Ember release, beta and canary channels, back to Ember v3.28.

Usage

Usage is very simple. First, add one of the template examples to your app. Then, inject the flashMessages service and use one of its convenience methods:

import Component from '@glimmer/component';
import { inject as service } from '@ember/service';

export default class MyComponent extends Component {
  @service flashMessages;
}

Convenience methods (Bootstrap / Foundation alerts)

You can quickly add flash messages using these methods from the service:

Bootstrap

  • .success
  • .warning
  • .info
  • .danger

Foundation

  • .success
  • .warning
  • .info
  • .alert
  • .secondary

These will add the appropriate classes to the flash message component for styling in Bootstrap or Foundation. For example:

// Bootstrap: the flash message component will have 'alert alert-success' classes
// Foundation: the flash message component will have 'alert-box success' classes
this.flashMessages.success('Success!');

You can take advantage of Promises, and their .then and .catch methods. To add a flash message after saving a model (or when it fails):

@action saveFoo() {
  const flashMessages = this.flashMessages;

  this.model
    .save()
    .then((res) => {
      flashMessages.success('Successfully saved!');
      doSomething(res);
    })
    .catch((err) => {
      flashMessages.danger('Something went wrong!');
      handleError(err);
    });
}

Custom messages

If the convenience methods don't fit your needs, you can add custom messages with add:

this.flashMessages.add({
  message: 'Custom message',
});

Custom messages API

You can also pass in options to custom messages:

this.flashMessages.add({
  message: 'I like alpacas',
  type: 'alpaca',
  timeout: 500,
  priority: 200,
  sticky: true,
  showProgress: true,
  extendedTimeout: 500,
  destroyOnClick: false,
  onDestroy() {
    // behavior triggered when flash is destroyed
  },
});

this.flashMessages.success('This is amazing', {
  timeout: 100,
  priority: 100,
  sticky: false,
  showProgress: true,
});
  • message: string

    Required when preventDuplicates is enabled. The message that the flash message displays.

  • type?: string

    Default: info

    This is mainly used for styling. The flash message's type is set as a class name on the rendered component, together with a prefix. The rendered class name depends on the message type that was passed into the component.

  • timeout?: number

    Default: 3000

    Number of milliseconds before a flash message is automatically removed.

  • priority?: number

    Default: 100

    Higher priority messages appear before low priority messages. The best practise is to use priority values in multiples of 100 (100 being the lowest priority). Note that you will need modify your template for this work.

  • sticky?: boolean

    Default: false

    By default, flash messages disappear after a certain amount of time. To disable this and make flash messages permanent (they can still be dismissed by click), set sticky to true.

  • showProgress?: boolean

    Default: false

    To show a progress bar in the flash message, set this to true.

  • extendedTimeout?: number

    Default: 0

    Number of milliseconds before a flash message is removed to add the class 'exiting' to the element. This can be used to animate the removal of messages with a transition.

  • destroyOnClick?: boolean

    Default: true

    By default, flash messages will be destroyed on click. Disabling this can be useful if the message supports user interaction.

  • onDestroy: function

    Default: undefined

    A function to be called when the flash message is destroyed.

Animated example

To animate messages, set extendedTimeout to something higher than zero. Here we've chosen 500ms.

module.exports = function (environment) {
  let ENV = {
    flashMessageDefaults: {
      extendedTimeout: 500,
    },
  };
}

Then animate using CSS transitions, using the .active and .active.exiting classes.

.alert {
  opacity: 0;
  position: relative;
  left: 100px;

  transition: all 700ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

  &.active {
    opacity: 1;
    left: 0px;

    &.exiting {
      opacity: 0;
      left: 100px;
    }
  }
}

Arbitrary options

You can also add arbitrary options to messages:

this.flashMessages.success('Cool story bro', {
  someOption: 'hello',
});

this.flashMessages.add({
  message: 'hello',
  type: 'foo',
  componentName: 'some-component',
  content: customContent,
});

Example use case

This makes use of the component helper, allowing the template that ultimately renders the flash to be dynamic:

{{#each this.flashMessages.queue as |flash|}}
  <FlashMessage @flash={{flash}} as |component flash|>
    {{#if flash.componentName}}
      {{component flash.componentName content=flash.content}}
    {{else}}
      <h6>{{component.flashType}}</h6>
      <p>{{flash.message}}</p>
    {{/if}}
  </FlashMessage>
{{/each}}

Clearing all messages on screen

It's best practice to use flash messages sparingly, only when you need to notify the user of something. If you're sending too many messages, and need a way for your users to clear all messages from screen, you can use this method:

this.flashMessages.clearMessages();

Returning flash object

The flash message service is designed to be Fluent, allowing you to chain methods on the service easily. The service should handle most cases but if you want to access the flash object directly, you can use the getFlashObject method:

const flashObject = this.flashMessages.add({
  message: 'hola',
  type: 'foo',
}).getFlashObject();

You can then manipulate the flashObject directly. Note that getFlashObject must be the last method in your chain as it returns the flash object directly.

Service defaults

In config/environment.js, you can override service defaults in the flashMessageDefaults object:

module.exports = function(environment) {
  let ENV = {
    flashMessageDefaults: {
      // flash message defaults
      timeout: 5000,
      extendedTimeout: 0,
      priority: 200,
      sticky: true,
      showProgress: true,

      // service defaults
      type: 'alpaca',
      types: [ 'alpaca', 'notice', 'foobar' ],
      preventDuplicates: false,
    },
  };
}

See the options section for information about flash message specific options.

  • type?: string

    Default: info

    When adding a custom message with add, if no type is specified, this default is used.

  • types?: array

    Default: [ 'success', 'info', 'warning', 'danger', 'alert', 'secondary' ]

    This option lets you specify exactly what types you need, which means in the above example, you can do this.flashMessages.{alpaca,notice,foobar}.

  • preventDuplicates?: boolean

    Default: false

    If true, only 1 instance of a flash message (based on its message) can be added at a time. For example, adding two flash messages with the message "Great success!" would only add the first instance into the queue, and the second is ignored.

Displaying flash messages

Then, to display somewhere in your app, add this to your template:

{{#each this.flashMessages.queue as |flash|}}
  <FlashMessage @flash={{flash}} />
{{/each}}

It also accepts your own template:

{{#each this.flashMessages.queue as |flash|}}
  <FlashMessage @flash={{flash}} as |component flash|>
    <h6>{{component.flashType}}</h6>
    <p>{{flash.message}}</p>
    {{#if component.showProgressBar}}
      <div class="alert-progress">
        <div class="alert-progressBar" style="{{component.progressDuration}}"></div>
      </div>
    {{/if}}
  </FlashMessage>
{{/each}}

Custom close action

The close action is always passed to the component whether it is used or not. It can be used to implement your own close button, such as an x in the top-right corner.

When using a custom close action, you will want to set destroyOnClick=false to override the default (destroyOnClick=true). You could do this globally in flashMessageDefaults.

{{#each this.flashMessages.queue as |flash|}}
  <FlashMessage @flash={{flash}} as |component flash close|>
    {{flash.message}}
    <span role="button" {{on "click" close}}>x</span>
  </FlashMessage>
{{/each}}

Styling with Foundation or Bootstrap

By default, flash messages will have Bootstrap style class names. If you want to use Foundation, simply specify the messageStyle on the component:

{{#each this.flashMessages.queue as |flash|}}
  <FlashMessage @flash={{flash}} @messageStyle='foundation' />
{{/each}}

Styling with user-specified message type class prefix

If you don't wish to use the class names associated with Bootstrap / Foundation, specify the messageStylePrefix on the component. This will override the class name prefixes with your own. For example, messageStylePrefix='special-alert-' would create flash messages with the class special-alert-succcess

{{#each this.flashMessages.queue as |flash|}}
  <FlashMessage @flash={{flash}} @messageStylePrefix='special-alert-' />
{{/each}}

Sort messages by priority

To display messages sorted by priority, add this to your template:

{{#each this.flashMessages.arrangedQueue as |flash|}}
  <FlashMessage @flash={{flash}} />
{{/each}}

Rounded corners (Foundation)

To add radius or round type corners in Foundation:

{{#each this.flashMessages.arrangedQueue as |flash|}}
  <FlashMessage @flash={{flash}} @messageStyle='foundation' class='radius' />
{{/each}}
{{#each this.flashMessages.arrangedQueue as |flash|}}
  <FlashMessage @flash={{flash}} @messageStyle='foundation' class='round' />
{{/each}}

Custom flash message component

If the provided component isn't to your liking, you can easily create your own. All you need to do is pass in the flash object to that component:

{{#each this.flashMessages.queue as |flash|}}
  <CustomComponent @flash={{flash}} />
{{/each}}

Test helpers

This addon provides helper functions for enabling and disabling flash message timeouts at any time during test runs.

Timeouts are initially disabled during test runs.

  • enableTimeout: () => void

    import { enableTimeout } from 'ember-cli-flash/test-support';

    Globally enables flash messages removal after timeout.

  • disableTimeout: () => void

    import { disableTimeout } from 'ember-cli-flash/test-support';

    Globally prevents flash messages from being removed after timeout.

These test helpers may be used to enable and disable timeouts granularly, or even for your entire test suite.

// tests/acceptance/foo-page-test.js

import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { click, visit } from '@ember/test-helpers';
import { enableTimeout, disableTimeout } from 'ember-cli-flash/test-support';

module('Application | Component | foo-page', function (hooks) {
  setupApplicationTest(hooks);

  module('with flash message timeout' function (hooks) {
    hooks.before(function () {
      // Enable timeout for tests within this module
      enableTimeout();
    });

    hooks.after(function () {
      // Clean up by disabling timeout again
      disableTimeout();
    })

    test('flash message is removed after 5 seconds', async function (assert) {
      assert.expect(1);

      await visit('/');

      await click('.button-that-opens-alert');

      assert.dom('.alert.alert-success').doesNotExist(
        'Timer was removed due to `timeout: 5_000`'
      );
    });
  });
});

Acceptance / Integration tests

Some example tests below, based on qunit.

An example acceptance test:

// tests/acceptance/foo-page-test.js

import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
import { click, visit } from '@ember/test-helpers';

module('Application | Component | foo-page', function (hooks) {
  setupApplicationTest(hooks);

  test('flash message is rendered', async function (assert) {
    assert.expect(1);

    await visit('/');

    await click('.button-that-opens-alert');

    assert.dom('.alert.alert-success').exists({ count: 1 });
  });
});

An example integration test:

// tests/integration/components/x-foo-test.js

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Component | x-foo', function (hooks) {
  setupRenderingTest(hooks);

  hooks.beforeEach(function () {
    // We have to register any types we expect to use in this component
    const typesUsed = ['info', 'warning', 'success'];
    this.owner.lookup('service:flash-messages').registerTypes(typesUsed);
  });

  test('it renders', function (assert) {
    await render(hbs`<XFoo/>`);
    ...
  });
});

Unit testing

For unit tests that require the flashMessages service, you'll need to do a small bit of setup:

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Container | Route | foo', function (hooks) {
  setupTest(hooks);

  hooks.beforeEach(function () {
    // We have to register any types we expect to use in this component
    const typesUsed = ['info', 'warning', 'success'];
    this.owner.lookup('service:flash-messages').registerTypes(typesUsed);
  });

  test('it does the thing it should do', function (assert) {
    const subject = this.owner.lookup('route:foo');
    ...
  });
});

Styling

This addon is minimal and does not currently ship with a stylesheet. You can style flash messages by targeting the appropriate alert classes in your CSS.

License

MIT

Contributors

We're grateful to these wonderful contributors who've contributed to ember-cli-flash:

ember-cli-flash's People

Contributors

abhilashlr avatar bgentry avatar charlesfries avatar cowboyd avatar dhaulagiri avatar elwayman02 avatar gilest avatar github-actions[bot] avatar greenkeeperio-bot avatar homu avatar johno avatar jrjohnson avatar jrowlingson avatar jwlawrence avatar kategengler avatar kmiyashiro avatar makepanic avatar mike-north avatar mrchocolatine avatar nullvoxpopuli avatar poteto avatar robbiethewagner avatar rwjblue avatar sandydoo avatar sbatson5 avatar st-h avatar stukalin avatar techn1x avatar wagenet avatar xiphiasuvella avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-cli-flash's Issues

Acceptance tests halt due to run.later scheduling

Given the following app:

// app/routes/application.js

export default Ember.Route.extend({
  actions: {
    sayHello() {
      let flashes = this.get('flashes');
      flashes.info('Hiya');
    }
  }
});
<!-- app/templates/application.hbs -->

<button {{action "sayHello"}}>Say hello</button>

{{#each flashes.queue as |flash|}}
  {{flash-message flash=flash}}
{{/each}}

An acceptance test has the following behaviour:

// tests/acceptance/hello-test.js

test('say hello', function(assert) {
  visit('/');
  click('button:contains("Say hello")');
  // Our test waits here until the run.later scheduled in _destroyLater is flushed
  andThen(() => {
    // By the time we get here the flash message has gone already
    assert.ok(find('Hiya').length);
  });
});

This is tricky both because andThen behaves unintuitively and because the test will pause for the full timeout duration.

I’ve worked around this in my tests with a total hack:

// tests/test-helper.js

import FlashObject from 'ember-cli-flash/flash/object';

FlashObject.reopen({ _destroyLater: null });

This is obviously not ideal but I’m struggling to come up with a reasonable API for this scenario. Any thoughts?

P.S. Love this addon so much ❤️

flashMessageDefaults not working

Seems that custom flashMessageDefaults not working correctly. I keep getting the default ones (etc timeout value is always 3000).

acceptance tests breaking with v1.2.0

Hi, I'm running an application that is using Ember 1.12.1 and Ember-CLI 0.2.7.

My package.json has the following line:

"ember-cli-flash": "^1.1.4",

Which updated the library to v1.2.0 on a recent npm install. My tests then started breaking with errors like:

Error: Element .alert.alert-warning not found.

If I run the test with the container visible, I can see the message flash, and the test hangs until the flash message disappears, and then it fails, and I get the aforementioned error.

Thank you for this library! It's great.

Transition hooks for animating out

Great addon!

I've just included a CSS keyframe animation to fade in the flash messages but just scratching my head as to how to fade them out again.

The addon seems to remove the messages instantly from the DOM, is there any way it could remove the active class first, then waiting for the JS transition event before removing it?

If you have approach that works already it would be fantastic to hear it.

Thanks

Destroy a message with click throw a error

When a message is destroyed with click (invoking public destroyMessage() of flash/object) the _destroyLater() try destroy again the object after timeout ... and throws a error. If the message clicked is on the middle of array ... the others messages (newer) are not erased by timeout.

One possible solution is cancel the try of _destroyLater() when _destroyMessage() is invoked (flash/object) :

  _destroyLaterTimer: null,
  _destroyLater: function() {
    var defaultTimeout = get(this, 'defaultTimeout');
    var timeout        = getWithDefault(this, 'timeout', defaultTimeout);

    this.set('_destroyLaterTimer', run.later(this, '_destroyMessage', timeout));
  }.on('init'),

  _destroyMessage: function() {
    var queue = get(this, 'queue');

    run.cancel(this.get('_destroyLaterTimer'));
    set(this, 'isDestroyed', true);
    if (queue) {
      queue.removeObject(this);
    }
  }

Other solution is verify if the object is already destroyed when _destroyMessage() is invoked:

  _destroyMessage: function() {
    var queue = get(this, 'queue');
    if ( queue && !this.get('isDestroyed') ) {
      queue.removeObject(this);
      set(this, 'isDestroyed', true);
    }   
  }

Handlebars 2.0.0 compatibility?

I get the following error when trying to use ember-cli-flash with Ember 1.9.1 and Handlebars 2.0.0: Uncaught Error: Unknown template object: function

I'm pretty new to Ember so it's quite possible I'm doing something wrong but some googling seemed to indicate that this has to do with incompatibilities between Handlebars 1.3.0 and 2.0.0. Is that the case?

this.get('flashMessages') returns undefined. Pod structure?

I'm trying to use ember-cli-flash with my application that is laid out in a pod structure. When calling this.get('flashMessage') from the controller, I get an error Uncaught TypeError: Cannot read property 'success' of undefined.

Do you know if the pod structure might cause conflict?

I will try to post an example of the error sometime tomorrow.

Addon is not working at all

Hi,
I'm trying to use this addon inside my project built with ember-cli 0.1.11, but when I serve the development application this is what happens

File: ember-cli-flash/components/flash-message
Unexpected token (3:20)
SyntaxError: Unexpected token (3:20)
    at raise (D:\Work\ember-cli-flash-modal\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:333:15)
    at unexpected (D:\Work\ember-cli-flash-modal\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:1366:5)
    at parseIdent (D:\Work\ember-cli-flash-modal\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:2471:7)
    at parsePropertyName (D:\Work\ember-cli-flash-modal\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:2250:78)

and so on... the problem is obviously the Destructors....
Let me know if you need more infos

What is the recommended way to destroy a flash message?

When using the addon like so

{{#if flashMessages.queue}}
  <div class="FlashQueue">
    {{#each flashMessages.queue as |flash|}}
      {{capp-flash-message flash=flash action="destroyMessage"}}
    {{/each}}
  </div>
{{/if}}

I'd like to be able to destroy a flash message by bubbling up an action from the flash-message component. Is there a method on the flash that I can use to destroy it, or is there another recommended way?

Global default timeout

@poteto - First of all, thanks for creating this awesome add-on.

I was wondering if there is a way to set an app-wide timeout value, so I don't have to set it for every flash message?

Thanks!

Error running acceptance tests with default helpers/flash-message.js

I've been scratching my head about this issue for a few days (trying the occasional hack while traveling) and haven't been able to run tests on a few of my projects recently.

I keep getting the error below:

Could not find module `ember-cli-flash/flash/object` imported from `my-app/tests/helpers/flash-message`

What's strange is that this is happening when running on Ubuntu or Codeship's CI servers and was working on my Mac dev environment until I refreshed my NPM cache... Not sure what seems to be the issue...

Multiple flash messages are removed at the same time

When I have multiple flash messages being displayed on the page at the same time, but initiated at different times, multiple flash messages are removed at the same time. This appears to be random in which ones are removed together. It is independent of the type of flash message it is. Take a look at the attached gif.
ember-cli-flash-multi-flash-remove

Render example error in Ember 1.13

The following example

{{#each flashMessages.queue as |flash|}}
  {{#flash-message flash=flash as |component flash|}}
    {{#if flash.template}}
      {{render flash.template flash.context}}
    {{else}}
      <h6>{{component.flashType}}</h6>
      <p>{{flash.message}}</p>
    {{/if}}
  {{/flash-message}}
{{/each}}

throws the following error.

Uncaught Error: Assertion Failed: The first argument of {{render}} must be quoted, e.g. {{render "sidebar"}}.

It would seem one cannot use render in this way. Another possibility would be to replace this line with a component helper, available since 1.11.

...
    {{#if flash.componentName}}
      {{component flash.componentName content=flash.content}}
    {{else}}
...

Link in message

Hi,

Thanks for the component. Would it be possible to pass a link inside the message? Right now because of the escaping, it prints the HTML rather than rendering the link.

Thanks!

Flash message after page refresh

Hey. Great plugin.
I'm thinking about using it but here's what I need to do. After a user selects something from a dropdown and clicks the "Save" button, I need to refresh the page (I need to clear some i18n stuff).

What would be the best way of showing a message after a page refresh? I'm thinking of storing the message in localStorage for example, and after the page refreshes, an initializer would check for the message in localStorage, and the message would get injected into ember-cli-flash and shown to the user.

Does that sound ok? Thanks.

Tests fail after installing this addon

Tests fail on empty project after ember install ember-cli-flash.

Building...

test-helper.js: line 2, col 8, 'flashMessageHelper' is defined but never used.

1 error

===== 1 JSHint Error

Built project successfully. Stored in "/Users/blimmer/code/oss/ember-cli-example-app-for-github/tmp/class-tests_dist-vxbmlNUY.tmp".
ok 1 PhantomJS 2.0 - JSHint - .: app.js should pass jshint
ok 2 PhantomJS 2.0 - JSHint - helpers: helpers/flash-message.js should pass jshint
ok 3 PhantomJS 2.0 - JSHint - helpers: helpers/resolver.js should pass jshint
ok 4 PhantomJS 2.0 - JSHint - helpers: helpers/start-app.js should pass jshint
ok 5 PhantomJS 2.0 - JSHint - .: router.js should pass jshint
not ok 6 PhantomJS 2.0 - JSHint - .: test-helper.js should pass jshint
    ---
        actual: >
            false
        expected: >
            true
        message: >
            test-helper.js should pass jshint.
            test-helper.js: line 2, col 8, 'flashMessageHelper' is defined but never used.

            1 error
        Log: |
    ...

1..6
# tests 6
# pass  5
# fail  1

Update to ember-cli 0.2.2

  • Update templates to remove bind-attr
  • Remove use of prototype extensions (mostly Ember.String.classify())
  • Escape CSS before binding to style attr
  • Add warning to README about compatibility with older versions

Links inside the flash message are unable to be copied since click() makes the flash message to be closed

If the flash message has text say: "You can copy paste this <URL>" before you start highlighting, the flash message closes due to (https://github.com/poteto/ember-cli-flash/blob/develop/addon/components/flash-message.js#L90):

click() {
    this._destroyFlashMessage();
}

This should be made as option based as the above use case might not work. Alternatively, should I extend the flash-message component?

Unexpected token in components/ember-cli-flash

seeing the following error when started ember server

File: ember-cli-flash/components/flash-message
Unexpected token (3:21)
SyntaxError: Unexpected token (3:21)
    at raise (E:\Documents\Synapse\Projects\Synapse\Synapse MX\synapse-mx-client-ember-cli\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:333:15)
    at unexpected (E:\Documents\Synapse\Projects\Synapse\Synapse MX\synapse-mx-client-ember-cli\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:1366:5)
    at parseIdent (E:\Documents\Synapse\Projects\Synapse\Synapse MX\synapse-mx-client-ember-cli\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:2471:7)
    at parsePropertyName (E:\Documents\Synapse\Projects\Synapse\Synapse MX\synapse-mx-client-ember-cli\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:2250:78)
    at parseObj (E:\Documents\Synapse\Projects\Synapse\Synapse MX\synapse-mx-client-ember-cli\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:2225:9)
    at parseExprAtom (E:\Documents\Synapse\Projects\Synapse\Synapse MX\synapse-mx-client-ember-cli\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:2136:14)
    at parseVar (E:\Documents\Synapse\Projects\Synapse\Synapse MX\synapse-mx-client-ember-cli\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:1875:57)
    at parseVarStatement (E:\Documents\Synapse\Projects\Synapse\Synapse MX\synapse-mx-client-ember-cli\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:1763:5)
    at parseStatement (E:\Documents\Synapse\Projects\Synapse\Synapse MX\synapse-mx-client-ember-cli\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:1569:47)
    at parseTopLevel (E:\Documents\Synapse\Projects\Synapse\Synapse MX\synapse-mx-client-ember-cli\node_modules\ember-cli\node_modules\broccoli-es6modules\node_modules\esperanto\node_modules\acorn\acorn.js:1526:18)

Similar to #1 I think. Ember 1.10, CLI 0.1.15

Using in Acceptance testing

Hi.
I was trying to test that the flash is shown during an acceptance test..:

visit('/customers').then ->
  click('button:contains(\'Delete Customer\')').then ->
    equal currentRouteName(), 'customers.index'
    equal find('.flashMessage').text(), 'Customer was deleted'

It feels like maybe I'm just tired and totally overlooking something, but a pointer would really be helpful.
If i get this working I can write up a little tutorial and add it to the README...

Two places to display

I have pretty common scenario in which I need to display flash message on one place, automatically hide it after certain amount of time - (so that the user won't be bothered by multiple notifications). And then put the same notification into other place for later review if user misses the notification for the first time. This second place is some popup menu hidden under some icon.

I can think of a way that I would create each notificaiton two times. This does not seem right to me. Any better idea to this?

`ember generate` error during install

Thanks for the building this great add on. The error doesn't block installation but thought you might want to know.

$ ember install ember-cli-flash
version: 0.2.3
Installed packages for tooling via npm.
installing
  create tests/helpers/flash-messages.js
installing
The `ember generate` command requires an entity name to be specified. For more details, use `ember help`.

Compatibility with 0.2.0

Hello,
I have an issue using ember-cli-flash with ember-cli 0.2.0. It was installed with ember install:addon ember-cli-flash
The error is javascript Uncaught Error: Could not find module ember-cli-flash/services/flash-messages-serviceimported fromxk21/initializers/flash-messages-service``

After upgrading Ember from 1.12 to 1.13 its freezing browsers

Today i've upgraded ember to 1.13.2, everything worked fine, besides one thing, i think it could be Ember related as it was working fine on 1.12 version.
When i have more than one flash message active at same time and i am changing route, it just stops on loading route and freezes firefox using whole 1 core cpu time, on chrome it freezes the current process, no way to refresh the page, or any other action on this tab is possible besides closing it by force.
Firefox is reporting 'Unresponsive script' and asking if i want to stop it etc.
I can't debug this because there is no information in console.
Interesting is that with only one flash message everything works fine.
Any ideas ?

#86 breaks current installs

I'm not super familiar with managing dependencies in addons but I think ember-new-computed needs to be in dependencies and not devDependencies.

Our builds broke with the new release that included the ember-new-computed (#86 ) as a dependency because npm install wasn't triggering the dependency to be installed.

The message component (flashMessage) is shared between all different components?

Hi, thanks for this amazing plugin. What i`m trying to todo, is have different notifications in different controllers/views, but seems that this properties is shared between all of them, because when i create a message on one controller, the same message is displayed in all places where i have defined the template.

I´m not sure, if this is the expected behavior or if i`m missing something.

Thanks for your help!

Uncaught Error: Computed Property declared without a property function

With ember-cli 0.2.7 and ember-cli-flash 1.2.0 I'm getting this error stopping the entire Ember app from loading:

Uncaught Error: Computed Property declared without a property function
computed @ ember.debug.js:10586
add @ computed.js:17
(anonymous function) @ object.js:14

Stems from the following line within: https://github.com/poteto/ember-cli-flash/blob/develop/addon/flash/object.js

totalTimeout: customComputed.add('timeout', 'extendedTimeout').readOnly(),

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.