Beispiel #1
0
      later(() => {
        get(this, 'access').login(provider, code).then((user) => {
          if ( get(user, 'mustChangePassword') && provider === 'local' ) {
            get(this, 'session').set(C.SESSION.BACK_TO, window.location.origin);
            get(this, 'access').set('userCode', code);
            get(this, 'router').transitionTo('update-password');
          } else {
            setProperties(this, {
              user: null,
              code: null,
            });
            get(this, 'access').set('userCode', null);
            get(this, 'access').set('firstLogin', false);
            this.send('complete', true);
            this.send('waiting', provider);
          }
        }).catch((err) => {
          this.send('waiting', provider);

          if ( err && [401, 403].includes(err.status) ) {
            let key = 'loginPage.error.authFailed'

            if ( USER_PASS_PROVIDERS.includes(provider) ) {
              key = 'loginPage.error.authFailedCreds';
            }

            set(this, 'errorMsg', get(this, 'intl').t(key));
          } else {
            set(this, 'errorMsg', (err ? err.message : 'No response received'));
          }
        })
      }, 10);
  test('it correctly toggles non-boolean falsey values', function(assert) {
    let jimBob = { isAlive: undefined };
    let action = toggle(['isAlive', jimBob]);
    action();

    assert.ok(get(jimBob, 'isAlive') === true, 'should be true');
  });
Beispiel #3
0
  rollbackAttributes() {
    let dirtyKeys;
    if (this.hasChangedAttributes()) {
      dirtyKeys = Object.keys(this._attributes);
      this._attributes = null;
    }

    if (get(this, 'isError')) {
      this._inFlightAttributes = null;
      this.didCleanError();
    }

    if (this.isNew()) {
      this.removeFromInverseRelationships();
    }

    if (this.isValid()) {
      this._inFlightAttributes = null;
    }

    this.send('rolledBack');

    if (dirtyKeys && dirtyKeys.length > 0) {
      this._record._notifyProperties(dirtyKeys);
    }
  }
Beispiel #4
0
 this.shouldSetServerUrl().then((proceed) => {
   if (proceed) {
     this.send('finishComplete');
   } else {
     get(this, 'router').transitionTo('update-critical-settings');
   }
 });
Beispiel #5
0
 ruleKeyDidChange: observer('rule.key', function() {
   if ( get(this, 'rule.key') === 'event' ) {
     set(this, 'rule.value', eventChoices[0].value);
   } else {
     set(this, 'rule.value', '');
   }
 }),
  test('it toggles the property', function(assert) {
    let jimBob = { isAlive: false };
    let action = toggle(['isAlive', jimBob]);
    action();

    assert.ok(get(jimBob, 'isAlive') === true, 'should be true');
  });
Beispiel #7
0
 run(() => {
   let record = store.push(hash);
   record.deleteRecord();
   store.push(hash);
   assert.equal(get(record, 'currentState.stateName'), 'root.deleted.uncommitted',
     'record accepts pushedData is in root.deleted.uncommitted state');
 });
  test('it correctly toggles non-boolean truthy values', function(assert) {
    let jimBob = { isAlive: {} };
    let action = toggle(['isAlive', jimBob]);
    action();

    assert.ok(get(jimBob, 'isAlive') === false, 'should be false');
  });
Beispiel #9
0
      ec2.describeVpcs({}, (err, vpcs) => {
        if ( err ) {
          let errors = get(self, 'errors') || [];

          errors.pushObject(err);
          set(this, 'errors', errors);
          if (cb && typeof cb === 'function') {
            cb();
          }

          return;
        }

        vpcs.Vpcs.forEach((vpc) => {
          vpcNames[vpc.VpcId] = nameFromResource(vpc, 'VpcId');
          vpcTags[vpc.VpcId] = tagsFromResource(vpc);
        });

        ec2.describeSubnets({}, (err, data) => {
          if ( err ) {
            let errors = get(self, 'errors') || [];

            errors.pushObject(err);
            set(this, 'errors', errors);
            if (cb && typeof cb === 'function') {
              cb();
            }

            return;
          }

          set(this, `clients.${ rName }`, ec2);

          data.Subnets.forEach((subnet) => {
            if ( (subnet.State || '').toLowerCase() !== 'available' ) {
              return;
            }

            subnets.pushObject(EmberObject.create({
              subnetName: nameFromResource(subnet, 'SubnetId'),
              subnetId:   subnet.SubnetId,
              subnetTags: tagsFromResource(subnet),
              vpcName:    vpcNames[subnet.VpcId] || subnet.VpcId,
              vpcId:      subnet.VpcId,
              vpcTags:    vpcTags[subnet.VpcId] || [],
              zone:       subnet.AvailabilityZone,
              region:     rName
            }));
          });

          setProperties(this, {
            'allSubnets': subnets,
            'step':       2,
          });
          if (cb && typeof cb === 'function') {
            cb();
          }
        });
      });
				.then( () => {
					assert.ok(
						env.store.hasRecordForId( "twitchUser", "foo" ),
						"Store has a User record registered after accessing the partner_login"
					);

					return get( record, "channel" );
				})
Beispiel #11
0
 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')
Beispiel #12
0
 watchedStateChanged: observer('watchStateOf.relevantState', function() {
   const state = get(this, 'watchState.relevantState');
   if ( state === 'active' ) {
     this.connect();
   } else {
     this.disconnect();
   }
 }),
Beispiel #13
0
  hostDidChange: observer('*****@*****.**', function() {
    const hosts = [];

    get(this, 'hostArray').filter((host) => host.value).forEach((host) => {
      hosts.push(host.value);
    });
    set(this, 'hosts', hosts)
  }),
Beispiel #14
0
  lintObserver: observer('yaml', function() {
    const yaml = get(this,'yaml');
    const lintError = CodeMirror.lint.yaml(yaml);

    if ( lintError.length ) {
      set(this,'errors', null);
    }
  }),
Beispiel #15
0
 headerLabel: function() {
   const ps = get(this, 'pageScope');
   if (ps === 'cluster') {
     return 'loggingPage.clusterHeader';
   } else {
     return 'loggingPage.projectHeader';
   }
 }.property('pageScope'),
Beispiel #16
0
  sortIndex: computed('_node.{tree.sorts.[],column.valuePath}', function() {
    let valuePath = this.get('_node.column.valuePath');
    let sorts = this.get('_node.tree.sorts');

    let sortIndex = 0;

    for (let i = 0; i < get(sorts, 'length'); i++) {
      let sorting = objectAt(sorts, i);

      if (get(sorting, 'valuePath') === valuePath) {
        sortIndex = i + 1;
        break;
      }
    }

    return sortIndex;
  }),
Beispiel #17
0
  run(() => {
    testStore.push(testStore.normalize('model', { id: 1, name: provided }));
    testStore.push(testStore.normalize('model', { id: 2 }));

    let record = testStore.peekRecord('model', 1);

    assert.deepEqual(get(record, 'name'), expected, type + ' coerces ' + provided + ' to ' + expected);
  });
Beispiel #18
0
test('a DS.Model can have a defaultValue', function(assert) {
  const Tag = DS.Model.extend({
    name: DS.attr('string', { defaultValue: 'unknown' })
  });

  let store = createStore({
    tag: Tag
  });

  let tag = store.createRecord('tag');

  assert.equal(get(tag, 'name'), 'unknown', 'the default value is found');

  run(() => set(tag, 'name', null));

  assert.equal(get(tag, 'name'), null, `null doesn't shadow defaultValue`);
});
Beispiel #19
0
    record.destroyRecord().then(() => {
      let currentState = record._internalModel.currentState;

      assert.ok(currentState.stateName === 'root.deleted.saved',
        'record is in a persisted deleted state');
      assert.equal(get(record, 'isDeleted'), true);
      assert.ok(store.peekRecord('person', '1') !== null, 'the deleted person is not removed from store (no unload called)');
    });
Beispiel #20
0
 get(path, 'workloadIds').forEach(workload => {
   pathArray.pushObject({
     backendType: 'workload',
     targetPort: get(path, 'targetPort'),
     serviceId: workload,
     path: p,
   });
 });
Beispiel #21
0
  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;
  }),
Beispiel #22
0
test('can have a property set on it', function(assert) {
  let record = run(() => {
    let record = store.createRecord('person');
    set(record, 'name', 'bar');
    return record;
  });

  assert.equal(get(record, 'name'), 'bar', 'property was set on the record');
});
Beispiel #23
0
 projectDidChange: observer('primaryResource.project.id', function() {
   set(this, 'switchingProject', true);
   next(() => {
     set(this, 'switchingProject', false);
   });
   if ( !get(this, 'primaryResource.project.resourceQuota') ) {
     set(this, 'primaryResource.resourceQuota', null);
   }
 }),
Beispiel #24
0
 findAllByDatacenter: function(dc) {
   return get(this, 'store')
     .query('intention', { dc: dc })
     .then(function(items) {
       return items.forEach(function(item, i, arr) {
         set(item, 'Datacenter', dc);
       });
     });
 },
Beispiel #25
0
  displayRepositoryUrl: computed('repositoryUrl', function() {
    let url = get(this, 'repositoryUrl');

    if ( url.endsWith('.git') ) {
      url = url.substr(0, url.length - 4);
    }

    return url;
  }),
Beispiel #26
0
  shortCommit: computed('commit', function() {
    const commit = get(this, 'commit')

    if (commit) {
      return commit.substr(0, 8)
    }

    return '';
  }),
Beispiel #27
0
  expandAllObserver: on('init', observer('expandAll', function() {
    var ea = get(this, 'expandAll');

    if (ea) {
      set(this, 'expanded', true);
    } else {
      set(this, 'expanded', false);
    }
  })),
Beispiel #28
0
    return hash({ pod }).then((hash) => {
      const container = get(hash, 'pod.containers').findBy('name', params.container_name);

      if ( !container ) {
        this.replaceWith('authenticated.project.index');
      }

      return container;
    });
Beispiel #29
0
 Object.keys(preload).forEach((key) => {
   let preloadValue = get(preload, key);
   let relationshipMeta = this.modelClass.metaForProperty(key);
   if (relationshipMeta.isRelationship) {
     this._preloadRelationship(key, preloadValue);
   } else {
     this._data[key] = preloadValue;
   }
 });
Beispiel #30
0
  run(() => {
    store.push({
      data: {
        type: 'person',
        id: '1',
        attributes: {
          isArchived: true
        }
      }
    });

    let currentState = record._internalModel.currentState;

    assert.ok(currentState.stateName === 'root.deleted.saved',
      'record is still in a persisted deleted state');
    assert.ok(get(record, 'isDeleted') === true, 'The record is still deleted');
    assert.ok(get(record, 'isArchived') === true, 'The record reflects the update to canonical state');
  });