adopted-ember-addons / ember-cli-flash

Simple, highly configurable flash messages for ember-cli
https://www.npmjs.com/package/ember-cli-flash
MIT License
355 stars 113 forks source link

enviornment.js flashMessageDefaults.sticky being ignored for prod build #162

Open pjdicke opened 8 years ago

pjdicke commented 8 years ago

I want the messages to be sticky and this works fine when developing but when I run ember build --environment production the prod version isn't sticky.

  flashMessageDefaults: {
     sticky: true,
     preventDuplicates: true
  }

I'm not overwriting this config anywhere else.

poteto commented 8 years ago

Could you verify that these defaults are being set in the production environment?

pjdicke commented 8 years ago

Here is my current config:

module.exports = function(environment) {
  var ENV = {
    contentSecurityPolicy: {
      'default-src': "'none'",
      'script-src': "'self' *",
      'font-src': "'self'",
      'connect-src': "'self' *",
      'img-src': "'self'",
      'style-src': "'self' *",
      'media-src': "'self'"
    },
    modulePrefix: 'clfs-app',
    environment: environment,
    baseURL: '/clweb/CLFSAdminNew/',
    rootURL: '/clweb/CLFSAdminNew/',
    locationType: 'hash',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },
    flashMessageDefaults: {
      sticky: true,
      preventDuplicates: true
    },
    APP: {
      imgSrc : '/clweb/apps/clfs/assets/images/'
      // Here you can pass flags/options to your application instance
      // when it is created
    }
  };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
    ENV.APP.imgSrc = 'assets/images/';
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

    // keep test console output quieter
    ENV.APP.LOG_ACTIVE_GENERATION = false;
    ENV.APP.LOG_VIEW_LOOKUPS = false;

    ENV.APP.rootElement = '#ember-testing';
  }

  if (environment === 'production') {
    ENV.baseURL = '/clweb/CLFSAdminNew/';
  }

  return ENV;
};

I have tried the following for production:

  if (environment === 'production') {
    ENV.baseURL = '/clweb/CLFSAdminNew/';
    ENV.flashMessageDefaults = {
      sticky: true,
      preventDuplicates: true
    };
  }

No dice.

poteto commented 8 years ago

Thanks for the detailed response! That's very odd, I don't do any environment checking in this addon. Could you please show me what the properties defined on your service looks like? If you open the ember-inspector in the production app you should be able to see something like this in the Container > service > flash-messages panel:

screenshot 2016-05-03 12 26 15
pjdicke commented 8 years ago

From production env/mode.

screen shot 2016-05-03 at 12 50 30 pm

jcowley commented 8 years ago

I don't think this has anything to do with the environment. I'm seeing sticky: true ignored in all environments.

jcowley commented 8 years ago

And, of course, as soon as I posted that it started working in all environments. Never mind. sigh

pjdicke commented 8 years ago

It only gets picked up when running ember serve but not for builds in my case.

pjdicke commented 8 years ago

Do you see anything that I might be doing wrong?

pjdicke commented 8 years ago

It's been awhile and figured I would check in on this issue. Any progress on wiring up the configuration overwrites correctly? I just had to do a new build on a new machine which pulled down a new copy of your addon which obviously wouldn't have my "hack" fix in the addonDefaults config obj.

ajelinek commented 7 years ago

I have been having the same issue. Once I think it works, it breaks again… Warning type was working fine, just not error.