hooks.beforeEach(function() {
    this.owner.register('breakpoints:main', {
      mobile: '(max-width: 767px)',
      tablet: '(min-width: 768px) and (max-width: 991px)',
      desktop: '(min-width: 992px) and (max-width: 1200px)'
    }, { instantiate: false });

    this.owner.register('component:dummy-component', Component.extend({
      media: service()
    }));
  });
Example #2
0
import Component from '@ember/component';
import { computed } from '@ember/object';

const DAYS_OF_WEEK = ["m", "t", "w", "th", "f", "s", "su"];

export default Component.extend({
  classNames: ['ui_day-of-week-selector', 'row'],

  collection: computed('model.@each.{enabled}', function() {
    const model = this.get("model") || [];
    return DAYS_OF_WEEK.map((item, i) => {
      const match = model.find(record => record.get('day') === i);

      if(match) {
        return {id:match.get('day'), text:DAYS_OF_WEEK[i], enabled:match.get('enabled')};
      } else {
        return {id:i, text:DAYS_OF_WEEK[i], enabled:false};
      }
    });
  }),

  actions: {
    onDayClick(target) {
      this.get("change")(target.id, !target.enabled);
    }
  }
});
/**
 * @module ember-paper
 */
import Component from '@ember/component';

import layout from '../templates/components/paper-card-header';

/**
 * @class PaperCardHeader
 * @extends Ember.Component
 */
export default Component.extend({
  layout,
  tagName: 'md-card-header'
});
Example #4
0
import { A } from '@ember/array';
import Component from '@ember/component';
import { computed } from '@ember/object';

export default Component.extend({
  classNames: ["col", "card-1"],


  itemTotals: computed("orders.@each.{totalQuantity}", function(){
    const orders = this.get("orders") || A();
    return _
      .chain(orders.toArray())
      .map(order => order.get("orderItems").toArray())
      .flatten()
      .groupBy(orderItem => orderItem.get("item.name"))
      .mapValues(orderItems =>
        orderItems.reduce((acc, cur) =>
          ({p:cur.get("item.position"), q:acc["q"] + Number(cur.get("quantity"))}), {p:0, q:0}))

      .map(({p, q}, name) => ({name, quantity:q, position:p}))
      .filter(row => row.quantity > 0)
      .sortBy(["position"])
      .value();
  }),

  totalUnits: computed("orders.@each.{totalQuantity}", function() {
    const orders = this.get("orders") || A();
    return orders.reduce((acc, cur) => acc + cur.get("totalQuantity"), 0);
  })
});
 * {{search-preprints
 *  search="search"
}}
 * ```
 * @class search-preprints
 */
export default Component.extend({
    metrics: service(),
    theme: service(),
    actions: {
        search() {
            const query = $.trim(this.$('#searchBox').val());
            /* eslint-disable-next-line ember/closure-actions */
            this.sendAction('search', query);
            this.get('metrics').trackEvent({
                category: 'button',
                action: 'click',
                label: 'Index - Search',
                extra: query,
            });
        },
    },

    keyDown(event) {
        // Search also activated when enter key is clicked
        if (event.keyCode === 13) {
            this.send('search');
        }
    },
});
export default Component.extend({
    classNames: ['rl-dropdown-toggle'],

    tagName: 'button',

    attributeBindings: ['type', 'role', 'disabled'],

    type: computed('tagName', function() {
        return this.get('tagName') === 'button' ? 'button' : null;
    }),

    role: computed('tagName', function() {
        return this.get('tagName') === 'a' ? 'button' : null;
    }),

    dropdownContainer: computed(function() {
        return this.nearestOfType(RlDropdownContainer);
    }),

    action: 'toggleDropdown',

    propagateClicks: true,

    disabled: false,

    click(event) {
        if (!this.get('disabled')) {
            let propagateClicks = this.get('propagateClicks');

            this.get('dropdownContainer').send(this.get('action'));

            if (propagateClicks === false || propagateClicks === 'false') {
                event.stopPropagation();
            }
        }
    }
});
export default Component.extend({
  classNames: ['donation-goals'],
  sorting: ['amount:desc'],

  donationGoals: alias('project.donationGoals'),
  sortedDonationGoals: sort('donationGoals', 'sorting'),

  /**
   * Indicates if the user can add a new donation goal.
   *
   * This is possible if no other donation goal
   * is currently being added or edited.
   *
   * @property canAdd
   * @type {Boolean}
   */
  canAdd: not('_currentlyEditingDonationGoals'),

  /**
   * Indicates if the user can cancel adding or editing a donation goal.
   *
   * This is possible if there is already a saved donation goal present.
   *
   * @property canCancel
   * @type {Boolean}
   */
  canCancel: alias('hasExistingDonationGoals'),

  /**
   * Indicates if the user can start editing a donation goal.
   *
   * This is possible if no other donation goal
   * is currently being added or edited.
   *
   * @property canEdit
   * @type {Boolean}
   */
  canEdit: not('_currentlyEditingDonationGoals'),

  /**
   * Indicates if there are existing donations goals for this project.
   *
   * @property hasExistingDonationGoals
   * @type {Boolean}
   */
  hasExistingDonationGoals: notEmpty('_existingDonationGoals'),

  _currentlyEditingDonationGoals: notEmpty('_editedDonationGoals'),
  _editedDonationGoals: filterBy('project.donationGoals', 'isEditing'),
  _existingDonationGoals: setDiff('project.donationGoals', '_newDonationGoals'),
  _newDonationGoals: filterBy('project.donationGoals', 'isNew')
});
export default Component.extend({
  classNames: ['project-card__donation-progress'],

  /**
   * The amount donated towards this donation goal
   * @property {Number} amountDonated
   */
  amountDonated: 0,

  /**
   * The total amount needed to donate towards the current donation goal.
   * Aliased from the donation goal assigned in the template.
   *
   * @property {Number} amountNeeded
   */
  amountNeeded: alias('donationGoal.amount'),

  /**
   * The description this donation goal
   * @property {String} description
   */
  description: alias('donationGoal.description'),

  /**
   * A computed field. Uses fields `amountDonated` and `amountNeeded` to
   * compute a percentage.
   *
   * @return {String} The computed percentage, rounded to two decimals.
   */
  percentage: computed('amountDonated', 'amountNeeded', function() {
    let { amountDonated, amountNeeded } = this.getProperties('amountDonated', 'amountNeeded');
    let percentage = amountDonated / amountNeeded * 100;
    return percentage.toFixed(2);
  })
});
Example #9
0
export default Component.extend({
  modalService:         service('modal'),
  globalStore:          service(),
  layout,
  tagName:              'TR',
  classNames:           'main-row',

  member:               null,
  roles:                null,
  owner:                null,
  type:                 null,
  pageType:             null,
  editing:              false,
  // customRoles:       null,
  _customRole:          null,
  errors:               null,
  principal:            null,
  external:             null,
  noUpdate:             false,
  principalId:          null,
  principalGravatarSrc: null,


  role:                 alias('member.role'),
  init() {
    this._super(...arguments);
    let member = get(this, 'member');

    if (get(this, 'member.bindings.length') === 1) {
      set(this, 'roleTemplateId', get(this, 'member.bindings.firstObject'));
    }

    if (member) {
      if (get(member, 'bindings.length') !== 0) { // new
        set(this, 'noUpdate', true);
      }
      if ( get(member, 'principalId') ) {
        get(this, 'globalStore').rawRequest({
          url:    `principals/${ encodeURIComponent(get(member, 'principalId')) }`,
          method: 'GET',
        }).then((xhr) => {
          if ( xhr.status === 204 ) {
            return;
          }

          if ( xhr.body && typeof xhr.body === 'object') {
            set(this, 'principal', set(this, 'external', xhr.body));
            this.principalChanged();
          }

          return xhr;
        }).catch((xhr) => {
          if (get(member, 'principalId')) {
            set(this, 'principalId', get(member, 'principalId'));
            set(this, 'principalGravatarSrc', `data:image/png;base64,${ new Identicon(AWS.util.crypto.md5(get(member, 'principalId') || 'Unknown', 'hex'), 80, 0.01).toString() }`)
          }

          return xhr;
        });
      }
      this.principalChanged();
    }
  },

  actions: {
    gotError(err) {
      set(this, 'errors', [Errors.stringify(err)]);
    },
    addAuthorized(principal) {
      set(this, 'principal', principal);
    },
    onSelect(selected) {
      if (selected.value === 'custom') {
        next(() => {
          this.openModal(false);
        });
      }
    },
  },

  principalChanged: observer('principal', 'member', function() {
    let principal = (get(this, 'principal'));

    if (principal) {
      set(this, 'member.principalId', get(principal, 'id'));
      set(this, 'member.memberType', get(principal, 'principalType'));
    }
  }),

  roleTemplate: computed('roleTemplateId', 'roles.[]', function() {
    return (get(this, 'roles') || []).findBy('id', get(this, 'roleTemplateId'));
  }),


  roleTemplateId: computed({
    get() {
      return get(this, 'member.isCustom') ?  'custom' : get(this, 'member.bindings.firstObject');
    },

    set(key, value) {
      if (value === 'custom') {
        set(this, '_roleTemplateId', get(this, 'roleTemplateId'));
      } else {
        set(this, 'member.bindings', [value])
      }

      return value;
    }
  }),

  builtInRoles: computed('roles.[]', function() {
    return get(this, 'roles').filter((r) => ( r.builtin || r.external ) && r.id !== 'read-only');
  }),

  customRoles: computed('roles.[]', function() {
    return get(this, 'roles').filter((r) => !r.builtin && !r.external && !r.hidden);
  }),

  choices: computed('roles.[]', 'pageType', function() {
    const pt = get(this, 'pageType');
    const allRoles = get(this, 'globalStore').all('roleTemplate');

    let neuRoles = BASIC_ROLES.map((r) => {
      const id = (r.typePrefix ? `${ pt }-${ r.value }` : r.value);
      const rt = allRoles.findBy('id', id )

      // If it's a real entry (i.e. not "custom")
      if ( !r.virtual ) {
        // And there's no corresponding role, or there is one but it's locked
        if (!rt || get(rt, 'locked') === true) {
          // And it's not the currently selected role
          if ( id !== get(this, 'roleTemplateId') ) {
            // Hide this entry (return nothing instead of a row)
            return;
          }
        }
      }

      return {
        label: r.label,
        value: id,
      };
    });

    if ( pt ) {
      let customRoles = get(this, 'customRoles').map( (r) => {
        if (r.id === 'read-only') {
          return;
        } else {
          return {
            label: r.name,
            value: r.id
          }
        }
      });

      neuRoles = neuRoles.concat(customRoles);

      return neuRoles.filter((x) => !!x);
    }

    return neuRoles;
  }),
  modalCanceled() {
  },

  doneAdding(customs) {
    if (customs.length === 1) { // more then one? of course its custom
      let match = customs[0];

      if (C.BASIC_ROLE_TEMPLATE_ROLES.includes(match)) {
        setProperties(this, {
          'member.isCustom': false,
          roleTemplateId:    match,
        });
      } else {
        setProperties(this, {
          'member.isCustom': true,
          roleTemplateId:    'custom',
        });
      }
    } else {
      setProperties(this, {
        'member.isCustom': true,
        roleTemplateId:    'custom',
      });
    }
    set(this, 'member.bindings', customs);
  },


  openModal(isCustom = false) {
    get(this, 'modalService').toggleModal('modal-add-custom-roles', {
      current:       get(this, 'member.bindings'),
      done:          this.doneAdding.bind(this),
      editng:        get(this, 'editing'),
      modalCanceled: this.modalCanceled.bind(this),
      model:         get(this, 'member'),
      roles:         get(this, 'builtInRoles'),
      type:          get(this, 'pageType'),
      isCustom,
    });
  },

});
Example #10
0
File: component.js Project: go/ui
export default Component.extend({
  layout,
  classNames:        ['banner'],
  classNameBindings: ['color'],
  color:             'bg-default',
  icon:              'icon-info',
  title:             null,
  titleWidth:        null,
  message:           '',
  showClose:         false,

  actions: {
    close() {
      this.sendAction('close');
    },
  },

  showIcon: computed('title', function() {
    let title = this.get('title');
    return title === null || title === undefined;
  }),


  titleStr: computed('title', function(){
    let title = this.get('title');
    if ( typeof title === 'number' ) {
      title = ""+title;
    }

    return title;
  }),

  titleStyle: computed('width', function() {
    let width = this.get('titleWidth');
    if ( width) {
      return ('width: ' + width + 'px').htmlSafe();
    }
  }),
});
import Component from '@ember/component';
import layout from '../../templates/components/twitter-entity/user-mention';

export default Component.extend({
  layout,
  tagName: ''
});
Example #12
0
import Component from '@ember/component';
import { once } from '@ember/runloop';
import { set, get } from '@ember/object';

export default Component.extend({
  dateNow:      null,
  dateInterval: null,
  didInsertElement(){
    this._super(...arguments);
    once(() => {
      var interval = window.setInterval(() => {
        set(this, 'dateNow', Date.now())
      }, 1000);

      set(this, 'dateInterval', interval);
    });
  },
  willDestroyElement(){
    this._super(...arguments);
    var interval = get(this, 'dateInterval');

    interval && window.clearInterval(interval);
  },
  actions: {
    showLogs(stageIndex, stepIndex){
      this.sendAction('showLogsActivity', get(this, 'activity'), stageIndex, stepIndex)
    },
  }
});
Example #13
0
import { readOnly } from '@ember/object/computed';
import Component from '@ember/component';

export default Component.extend({
    user: null,
    attributeBindings: ['title', 'href'],
    tagName: 'a',

    title: readOnly('user.login'),

    // TODO replace this with a link to a native crates.io profile
    // page when they exist.
    href: readOnly('user.url'),
});
Example #14
0
import Component from '@ember/component';
import branchConditionsEnums from 'pipeline/utils/branchConditionsEnums';
import { get } from '@ember/object';

export default Component.extend({
  branchCondition: function(){
    let condition = get(this, 'model.sourceCodeConfig.branchCondition');
    if(condition){
      let conditionEnum = branchConditionsEnums.find(ele => ele.value === condition)
      return conditionEnum&&conditionEnum.label||'';
    }
    return '';
  }.property('model.sourceCodeConfig.branchCondition')
});
Example #15
0
export default Component.extend({
  /**
   * Used by the `sort` computed macro.
   *
   * @property sortProperties
   * @type {Array<String>}
   */
  sortProperties: ['name'],

  /**
   * Sort the properties by name to make them easier to find in the object inspector.
   *
   * @property sortedAllProperties
   * @type {Array<Object>}
   */
  sortedAllProperties: sort('allProperties', 'sortProperties'),

  allProperties: computed('model', function() {
    const props = this.get('model.mixins').map(function(mixin) {
      return mixin.properties.filter(function(p) {
        return !p.hasOwnProperty('overridden');
      });
    });

    return props.flat();
  }),

  actions: {
    traceErrors() {
      this.get('port').send('objectInspector:traceErrors', {
        objectId: this.get('model.objectId')
      });
    }
  }
});
Example #16
0
File: component.js Project: go/ui
import Component from '@ember/component';
import layout from './template';

export default Component.extend({
  layout,
  model:    null,
  tagName:  '',
});
Example #17
0
import Component from '@ember/component';
import { computed } from '@ember/object';

export default Component.extend({
  startArgs: computed('prNum', 'jobs', {
    get() {
      const prNum = this.get('prNum');
      const jobs = this.get('jobs') || [];

      if (!prNum) {
        return [];
      }

      // Pass arguments with PR number and jobs to reload when starting PR event.
      return [prNum, jobs];
    }
  }),
  actions: {
    startBuild() {
      const args = this.get('startArgs');
      const startFunc = this.get('startBuild');

      startFunc.apply(null, args);
    }
  }
});
Example #18
0
export default Component.extend({
  didInsertElement() {
    this.$().find('table').DataTable({
      searching: false,
      order: [[1, 'desc']],
      data: this.regions,
      columns: [
        {
          data: 'name',
          title: 'Location',
          defaultContent: '-',
          render: (name, type, data) => {
            if(type === 'display' && name && name !== '-') {
              let link;
              let params = clone(this.presentQueryParamValues);
              if(this.regionField === 'request_ip_city') {
                delete params.region;
                params.search = 'request_ip_city:"' + data.id + '"';
                link = '#/stats/logs?' + $.param(params);
              } else {
                params.region = data.id;
                link = '#/stats/map?' + $.param(params);
              }

              return '<a href="' + link + '">' + escape(name) + '</a>';
            }

            return name;
          },
        },
        {
          data: 'hits',
          title: 'Hits',
          defaultContent: '-',
          render(number, type) {
            if(type === 'display' && number && number !== '-') {
              return numeral(number).format('0,0');
            }

            return number;
          },
        },
      ],
    });
  },

  refreshData: observer('regions', function() {
    let table = this.$().find('table').dataTable().api();
    table.clear();
    table.rows.add(this.regions);
    table.draw();
  }),

  downloadUrl: computed('backendQueryParamValues', function() {
    return '/admin/stats/map.csv?' + $.param(this.backendQueryParamValues);
  }),
});
import Component from '@ember/component';
import { computed } from '@ember/object';

const iconMap = {
	alert: 'error',
	warning: 'alert',
	success: 'checkmark',
	message: 'flag'
};

export default Component.extend({
	classNames: 'wds-banner-notification',
	classNameBindings: ['typeClassName'],

	type: 'message',

	icon: computed('type', function () {
		return iconMap[this.type];
	}),

	typeClassName: computed('type', function () {
		return 'wds-' + this.type;
	})
});
Example #20
0
import Component from '@ember/component';
import EditTableView from '../../mixins/edit-table-view';

export default Component.extend(EditTableView);
export default Component.extend({
  classNames: ['sortable-column'],
  tagName: 'th',
  action: 'sortByKey',
  filterAction: 'filter',
  filterBy: null,
  filteredBy: null,
  filterType: 'list',
  sortDesc: false,
  sortBy: null,
  sortKey: null,
  filtered: false,

  sorted: function() {
    let sortBy = this.get('sortBy');
    let sortKey = this.get('sortKey');
    return sortBy === sortKey;
  }.property('sortBy', 'sortKey'),

  actions: {
    sort() {
      let sortBy = this.get('sortBy');
      let sorted = this.get('sorted');
      let sortDesc = false;
      if (sorted) {
        sortDesc = this.toggleProperty('sortDesc');
      }
      this.sendAction('action', sortBy, sortDesc);
    },

    filter(filterValue) {
      if (isEmpty(filterValue)) {
        this.set('filtered');
      } else {
        this.set('filtered', true);
      }
      let filterBy = this.get('filterBy');
      let $dropdown = this.$('.dropdown-toggle');
      $dropdown.dropdown('toggle');
      this.sendAction('filterAction', filterBy, filterValue);
    }
  }
});
import { computed } from '@ember/object';
import Component from '@ember/component';
import { htmlSafe } from '@ember/string';

export default Component.extend({
  item: null,
  tagName: '',

  labelStyle: computed('item.parentCount', function() {
    let expanderOffset = this.get('item.hasChildren') ? 12 : 0;
    let padding = this.get('item.parentCount') * 20 - expanderOffset + 25;
    return htmlSafe(`padding-left: ${padding}px;`);
  }),

  hasElement: computed('item', function() {
    return this.get('item.view.tagName') !== '';
  })
});
Example #23
0
import Component from '@ember/component';
import layout from './template';

export default Component.extend({
  question:    null,
  answer:      null,
  namespaceId: '',

  layout,

  tagName:    'div',

});
import Component from '@ember/component';

export default Component.extend({
  classNames: ['organization-header'],
  classNameBindings: ['expanded'],
  expanded: false
});
Example #25
0
import Component from '@ember/component';

export default Component.extend({
  classNames: ["row"],
  actions: {
    onStartDateSelected(date) {
      this.set("stashedStartDate", moment(date).format("YYYY-MM-DD"));
    },

    onEndDateSelected(date) {
      this.set("stashedEndDate", moment(date).format("YYYY-MM-DD"));
    },

    generateReport() {
      this.get("onDatesConfirmed")(this.get("stashedStartDate"), this.get("stashedEndDate"));
    }
  }
});
 *
 */
import Component from '@ember/component';
import layout from '../templates/components/bc-radio-button';

/**
 * `Component/RadioButton`
 *
 */
export default Component.extend({
	layout: layout,
	classNames: ['bc-radio-button', 'bc-radio-button'],

	tagName: null,
	type: 'radio',
	value: null,
	label: null,
	name: null,
	disabled: false,
	checked: false,

	change() {
		this.sendAction('onSelect', this.get('value'));
	},

	click(evt) {
		evt.stopPropagation();
		return true;
	}
});
Example #27
0
/**
 * @module Toolbar
 * `Toolbar` components are containers for Toolbar actions.
 *
 * @example
 * ```js
 * <Toolbar>
 *   <ToolbarActions>
 *     <ToolbarSecretLink @params={{array 'vault.cluster.policies.create'}} @type="add">
 *       Create policy
 *     </ToolbarSecretLink>
 *   </ToolbarActions>
 * </Toolbar>
 * ```
 *
 */

import Component from '@ember/component';
import layout from '../templates/components/toolbar';

export default Component.extend({
  tagName: '',
  layout,
});
Example #28
0
File: component.js Project: go/ui
import Component from '@ember/component';
import layout from './template';
import VolumeSource from 'shared/mixins/volume-source';

export default Component.extend(VolumeSource, {
  layout,
  field: 'local',
  fieldType: 'localVolumeSource',
});
Example #29
0
import Component from '@ember/component';

export default Component.extend({
  header: 'Request Submitted',
  content: 'Processing your request...'
});
import Component from '@ember/component';

export default Component.extend({
  classNames: ['donation-goals-activation']
});