Beispiel #1
0
import EmberObject, { computed } from '@ember/object';
import { equal, match } from '@ember/object/computed';
import ModelReloaderMixin from 'screwdriver-ui/mixins/model-reloader';
import DS from 'ember-data';
import ENV from 'screwdriver-ui/config/environment';
import { isActiveBuild } from 'screwdriver-ui/utils/build';

export default DS.Model.extend(ModelReloaderMixin, {
  pipelineId: DS.attr('string'),
  name: DS.attr('string'),
  isPR: match('name', /^PR-/),
  state: DS.attr('string'),
  stateChanger: DS.attr('string'),
  stateChangeTime: DS.attr('date'),
  stateChangeTimeWords: computed('stateChangeTime', {
    get() {
      const duration = Date.now() - +this.get('stateChangeTime');

      return `${humanizeDuration(duration, { round: true, largest: 1 })} ago`;
    }
  }),
  stateChangeMessage: DS.attr('string'),
  // !for pr job only {
  title: DS.attr('string'),
  group: computed('isPR', 'name', {
    get() {
      return this.get('isPR') ? parseInt(this.get('name').slice('PR-'.length), 10) : null;
    }
  }),
  username: DS.attr('string'),
  userProfile: DS.attr('string'),
Beispiel #2
0
      return;
    }
    setProperties(this, DEFAULTS);
  },

  checkAction() {
    const currentAction = get(this, 'selectedAction');
    const oldAction = get(this, 'oldSelectedAction');

    if (currentAction !== oldAction) {
      this.reset();
    }
    set(this, 'oldSelectedAction', currentAction);
  },

  dataIsEmpty: match('data', new RegExp(DEFAULTS.data)),

  expirationDate: computed('creation_time', 'creation_ttl', function() {
    const { creation_time, creation_ttl } = this.getProperties('creation_time', 'creation_ttl');
    if (!(creation_time && creation_ttl)) {
      return null;
    }
    return moment(creation_time).add(moment.duration(creation_ttl, 'seconds'));
  }),

  handleError(e) {
    set(this, 'errors', e.errors);
  },

  handleSuccess(resp, action) {
    let props = {};
Beispiel #3
0
/* eslint-disable ghost/ember/alias-model-in-controller */
import Controller, {inject as controller} from '@ember/controller';
import {computed} from '@ember/object';
import {match} from '@ember/object/computed';
import {inject as service} from '@ember/service';

export default Controller.extend({
    appController: controller('application'),
    ghostPaths: service(),

    showBackLink: match('appController.currentRouteName', /^setup\.(two|three)$/),

    backRoute: computed('appController.currentRouteName', function () {
        let currentRoute = this.get('appController.currentRouteName');

        return currentRoute === 'setup.two' ? 'setup.one' : 'setup.two';
    })
});
Beispiel #4
0
/* eslint-disable ghost/ember/alias-model-in-controller */
import Controller from '@ember/controller';
import {computed} from '@ember/object';
import {match} from '@ember/object/computed';
import {inject as service} from '@ember/service';

export default Controller.extend({
    ghostPaths: service(),
    router: service(),

    showBackLink: match('router.currentRouteName', /^setup\.(two|three)$/),

    backRoute: computed('router.currentRouteName', function () {
        let currentRoute = this.router.currentRouteName;

        return currentRoute === 'setup.two' ? 'setup.one' : 'setup.two';
    })
});