diff options
Diffstat (limited to 'web-ui/app/js')
| -rw-r--r-- | web-ui/app/js/features/features.js | 18 | ||||
| -rw-r--r-- | web-ui/app/js/lib/features.js | 5 | ||||
| -rw-r--r-- | web-ui/app/js/mail_view/data/mail_sender.js | 9 | ||||
| -rw-r--r-- | web-ui/app/js/mail_view/ui/mail_view.js | 21 | ||||
| -rw-r--r-- | web-ui/app/js/mail_view/ui/reply_section.js | 5 | ||||
| -rw-r--r-- | web-ui/app/js/main.js | 3 | ||||
| -rw-r--r-- | web-ui/app/js/mixins/with_feature_toggle.js | 9 | 
7 files changed, 44 insertions, 26 deletions
| diff --git a/web-ui/app/js/features/features.js b/web-ui/app/js/features/features.js new file mode 100644 index 00000000..74efdd07 --- /dev/null +++ b/web-ui/app/js/features/features.js @@ -0,0 +1,18 @@ +define([], function() { +  var disabledFeatures; + +  function getFeatures() { +    disabledFeatures = disabledFeatures || fetchDisabledFeatures(); +    return disabledFeatures; +  } + +  function fetchDisabledFeatures() { +    return ['saveDraft', 'createNewTag', 'replySection']; +  } + +  return { +    isEnabled: function(featureName) { +      return ! _.contains(getFeatures(), featureName); +    } +  }; +}); diff --git a/web-ui/app/js/lib/features.js b/web-ui/app/js/lib/features.js deleted file mode 100644 index deacc8fe..00000000 --- a/web-ui/app/js/lib/features.js +++ /dev/null @@ -1,5 +0,0 @@ -define([], function() { -  return { -     -  }; -}); diff --git a/web-ui/app/js/mail_view/data/mail_sender.js b/web-ui/app/js/mail_view/data/mail_sender.js index 7440f5a7..0dba1a02 100644 --- a/web-ui/app/js/mail_view/data/mail_sender.js +++ b/web-ui/app/js/mail_view/data/mail_sender.js @@ -2,9 +2,10 @@ define(    [      'flight/lib/component',      'mail_view/data/mail_builder', -    'page/events' +    'page/events', +    'features'    ], -  function (defineComponent, mailBuilder, events) { +  function (defineComponent, mailBuilder, events, features) {      'use strict';      return defineComponent(mailSender); @@ -67,7 +68,9 @@ define(        this.after('initialize', function () {          this.on(events.mail.send, this.sendMail); -        this.on(events.mail.saveDraft, this.saveDraft); +        if(features.isEnabled('saveDraft')) { +          this.on(events.mail.saveDraft, this.saveDraft); +        }          this.on(document, events.mail.save, this.saveMailWithCallback);        });      } diff --git a/web-ui/app/js/mail_view/ui/mail_view.js b/web-ui/app/js/mail_view/ui/mail_view.js index 1e27c879..9114fa2e 100644 --- a/web-ui/app/js/mail_view/ui/mail_view.js +++ b/web-ui/app/js/mail_view/ui/mail_view.js @@ -12,10 +12,11 @@ define(      'helpers/view_helper',      'mixins/with_hide_and_show',      'page/events', -    'views/i18n' +    'views/i18n', +    'features'    ], -  function (defineComponent, templates, mailActions, viewHelpers, withHideAndShow, events, i18n) { +  function (defineComponent, templates, mailActions, viewHelpers, withHideAndShow, events, i18n, features) {      return defineComponent(mailView, mailActions, withHideAndShow); @@ -148,13 +149,15 @@ define(        };        this.createNewTag = function() { -        var tagsCopy = this.attr.mail.tags.slice(); -        tagsCopy.push(this.select('newTagInput').val()); -        this.attr.tagCompleter.clear(); -        this.attr.tagCompleter.clearPrefetchCache(); -        this.attr.tagCompleter.clearRemoteCache(); -        this.trigger(document, events.mail.tags.update, { ident: this.attr.mail.ident, tags: _.uniq(tagsCopy)}); -        this.trigger(document, events.dispatchers.tags.refreshTagList); +        if(features.isEnabled('createNewTag')) { +          var tagsCopy = this.attr.mail.tags.slice(); +          tagsCopy.push(this.select('newTagInput').val()); +          this.attr.tagCompleter.clear(); +          this.attr.tagCompleter.clearPrefetchCache(); +          this.attr.tagCompleter.clearRemoteCache(); +          this.trigger(document, events.mail.tags.update, { ident: this.attr.mail.ident, tags: _.uniq(tagsCopy)}); +          this.trigger(document, events.dispatchers.tags.refreshTagList); +        }        };        this.handleKeyDown = function(event) { diff --git a/web-ui/app/js/mail_view/ui/reply_section.js b/web-ui/app/js/mail_view/ui/reply_section.js index 866a255a..80781842 100644 --- a/web-ui/app/js/mail_view/ui/reply_section.js +++ b/web-ui/app/js/mail_view/ui/reply_section.js @@ -5,13 +5,14 @@ define(      'mail_view/ui/reply_box',      'mail_view/ui/forward_box',      'mixins/with_hide_and_show', +    'mixins/with_feature_toggle',      'page/events'    ], -  function (defineComponent, templates, ReplyBox, ForwardBox, withHideAndShow, events) { +  function (defineComponent, templates, ReplyBox, ForwardBox, withHideAndShow, withFeatureToggle, events) {      'use strict'; -    return defineComponent(replySection, withHideAndShow); +    return defineComponent(replySection, withHideAndShow, withFeatureToggle('replySection'));      function replySection() {        this.defaultAttrs({ diff --git a/web-ui/app/js/main.js b/web-ui/app/js/main.js index 22a11c3a..665416fc 100644 --- a/web-ui/app/js/main.js +++ b/web-ui/app/js/main.js @@ -20,7 +20,8 @@ requirejs.config({      'search': 'js/search',      'foundation': 'js/foundation',      'i18next': 'bower_components/i18next/i18next.amd', -    'quoted-printable': 'bower_components/quoted-printable' +    'quoted-printable': 'bower_components/quoted-printable', +    'features': 'js/features/features'    }  }); diff --git a/web-ui/app/js/mixins/with_feature_toggle.js b/web-ui/app/js/mixins/with_feature_toggle.js index 3a484388..2b071e68 100644 --- a/web-ui/app/js/mixins/with_feature_toggle.js +++ b/web-ui/app/js/mixins/with_feature_toggle.js @@ -1,15 +1,12 @@ -define(['lib/features'], +define(['features'],    function(features) {      function withFeatureToggle(componentName) {        return function() { -        var defaultToggle = {enabled: true}; -          this.around('initialize', function(basicInitialize) { -          var featureToggle = features[componentName] || defaultToggle; -          if(featureToggle.enabled) { -            basicInitialize(arguments[1], arguments[2]); +          if(features.isEnabled(componentName)) { +            return basicInitialize(arguments[1], arguments[2]);            }          });        }; | 
