function resolver (campaign) {
    const {platform, sub_status, status} = campaign

    const defaultStatus = {
      name: sub_status || status,
      is_active: false,
      platform,
      description: '???'
    }

    const foundStatus = find(statuses, {name: status, platform})
    const foundSubStatus = find(statuses, {name: sub_status, platform})

    let foundDescriptor

    if (foundStatus && !foundStatus.is_active) {
      foundDescriptor = foundStatus
    } else {
      foundDescriptor = foundSubStatus || foundStatus || defaultStatus
    }

    return assign(omit(campaign, 'status', 'sub_status'), {
      status: assign({}, foundDescriptor, {
        status,
        sub_status,
        icon: getStatusIcon(foundDescriptor)
      })
    })
  }
Exemple #2
0
	const extendedItems = items.map( ( item ) => {
		const extra = assign( {}, item.extra, {
			context: 'calypstore',
			withPlansOnly: domainsWithPlansOnlyTestEnabled && ! freeTrialsEnabled ? 'yes' : ''
		} );

		return assign( {}, item, { extra } );
	} );
Exemple #3
0
export const items = ( state = initialItemsState, action ) => {
	switch ( action.type ) {
		case JETPACK_SET_INITIAL_STATE:
		case JETPACK_MODULES_LIST_RECEIVE:
			return assign( {}, state, action.modules );
		case JETPACK_MODULE_ACTIVATE_SUCCESS:
			return assign( {}, state, {
				[ action.module ]: assign( {}, state[ action.module ], { activated: true } )
			} );
		case JETPACK_MODULE_DEACTIVATE_SUCCESS:
			return assign( {}, state, {
				[ action.module ]: assign( {}, state[ action.module ], { activated: false } )
			} );
		case JETPACK_MODULE_UPDATE_OPTION_SUCCESS:
			let module = state[ action.module ];
			let newOptions = assign( {}, module.options, {
				[ action.optionName ]: assign( {}, module.options[ action.optionName ], {
					current_value: action.optionValue
				} )
			} );
			return assign( {}, state, {
				[ action.module ]: assign( {}, state[ action.module ], {
					options: newOptions
				} )
			} );
		default:
			return state;
	}
};
Exemple #4
0
	each(scaleNames, function(name) {
		var _computed = _scaleComputed[name];
		if (_computed.count > 0) {
			var currScale = chartProps.scale[name] || clone(config.defaultProps.chartProps.scale.primaryScale);
			var domain = help.computeScaleDomain(currScale, _computed.data, {
				nice: true,
				minZero: _computed.hasColumn
			});
			assign(currScale, domain);

			var ticks;
			if (name === "primaryScale") {
				ticks = currScale.ticks;
			} else {
				ticks = scale.primaryScale.ticks;
			}

			currScale.tickValues = help.exactTicks(currScale.domain, ticks);
			each(currScale.tickValues, function(v) {
				var tickPrecision = help.precision(Math.round(v*factor)/factor);
				if (tickPrecision > currScale.precision) {
					currScale.precision = tickPrecision;
				}
			});

			scale[name] = currScale;

			if (chartProps.mobile) {
				if (chartProps.mobile.scale) {
					var currMobile = chartProps.mobile.scale[name];
					if (currMobile) {
						var domain = help.computeScaleDomain(currMobile, _computed.data, {
							nice: true,
							minZero: _computed.hasColumn
						});
						assign(currMobile, domain);

						var ticks = (name == "primaryScale") ? currMobile.ticks : scale.primaryScale.ticks;
						currMobile.tickValues = help.exactTicks(currMobile.domain, ticks);
						each(currMobile.tickValues, function(v) {
							var tickPrecision = help.precision(Math.round(v*factor)/factor);
							if (tickPrecision > currMobile.precision) {
								currMobile.precision = tickPrecision;
							}
						});
					}
				}
			} else {
				chartProps.mobile = {};
			}
		}
	});
Exemple #5
0
	signupProgress = map( signupProgress, function( step ) {
		if ( step.stepName === newStep.stepName ) {
			const { status } = newStep;
			if ( ! newStep.processingMessage && ( status === 'pending' || status === 'completed' ) ) {
				// pending or completed steps can omit the processing message if they are skipped
				return assign( {}, omit( step, 'processingMessage' ), newStep );
			}

			return assign( {}, step, newStep );
		}

		return step;
	} );
module.exports = function changeObject (state, change, object) {
  var updatedObject = assign({}, object)

  if (typeof change === 'object') {
    updatedObject = assign(object, change)
  } else {
    change(updatedObject)
  }

  return validate(state, updatedObject)

  .then(function () {
    return updatedObject
  })
}
Exemple #7
0
            renderProps.createElement = function(Component, routerProps) {
              // Other than fusing the data object with the routerProps, there is no way
              // to pass data into the routing context of react-router during a server render.
              // since we are going to use `assign` to fuse the routerProps and the actual
              // data object, we need to make sure that there are no properties between the two object
              // with the same name at the root level. (Having two properties with the same name breaks assign.)
              // Info on why we need to fuse the two objects?
              // --------------------------------------------
              // * https://github.com/ngduc/react-setup/issues/10
              // * https://github.com/reactjs/react-router/issues/1969
              // * http://stackoverflow.com/questions/36137901/react-route-and-server-side-rendering-how-to-render-components-with-data
              if (options.settings.env !== 'production') {
                var intersection = Object.keys(routerProps).filter(function(elem) {
                  return Object.keys(data).indexOf(elem) !== -1;
                });
                if (intersection.length) {
                  var errMsg = 'Your data object cannot have property(ies) named: "' +
                    intersection +
                    '"\n Blacklisted property names that cannot be used: "' +
                    Object.keys(routerProps) +
                    '"\n'
                  throw new Error(errMsg);
                }
              }

              // define a createElement strategy for react-router that transfers data props to all route "components"
              // for any component created by react-router, fuse data object with the routerProps
              // NOTE: This may be imposing too large of an opinion?
              return React.createElement(Component, assign({}, data, routerProps));
            };
Exemple #8
0
function run(data) {
    const opts = assign({base: process.cwd()}, cli.flags);
    const command = opts.htmlTarget || opts.inline ? 'generateInline' : 'generate';

    if (command === 'generate') {
        opts.dest = opts.styleTarget || '';
    }

    ok = true;

    if (data) {
        opts.html = data;
    } else {
        opts.src = cli.input[0];
        if (opts.src && !file.isExternal(opts.src)) {
            opts.src = path.resolve(cli.input[0]);
        }
    }

    try {
        critical[command](opts, (err, val) => {
            if (err) {
                error(err);
            } else {
                process.stdout.write(val, process.exit);
            }
        });
    } catch (err) {
        error(err);
    }
}
Exemple #9
0
const requests = ( state = initialRequestsState, action ) => {
	switch ( action.type ) {
		case JETPACK_PLUGINS_DATA_FETCH:
			return assign( {}, state, {
				isFetchingPluginsData: true
			} );
		case JETPACK_PLUGINS_DATA_FETCH_FAIL:
		case JETPACK_PLUGINS_DATA_FETCH_RECEIVE:
			return assign( {}, state, {
				isFetchingPluginsData: false
			} );

		default:
			return state;
	}
};
	getPhone: function() {
		fetchFromAPIIfNotInitialized();

		return assign( {
			loading: _loading,
		}, _phone );
	}
	getEmail: function() {
		fetchFromAPIIfNotInitialized();

		return assign( {
			loading: _loading,
		}, _email );
	},
Exemple #12
0
function saveStep( step ) {
	if ( find( signupProgress, { stepName: step.stepName } ) ) {
		updateStep( step );
	} else {
		addStep( assign( {}, step, { status: 'in-progress' } ) );
	}
}
Exemple #13
0
  let getAst = function () {
    let ast;

    try {
      ast = babylon.parse(code, assign({
        allowReturnOutsideFunction: true,
        allowSuperOutsideMethod: true
      }, opts));

      ast = traverse.removeProperties(ast);

      traverse.cheap(ast, function (node) {
        node[FROM_TEMPLATE] = true;
      });
    } catch (err) {
      err.stack = `${err.stack}from\n${stack}`;
      throw err;
    }

    getAst = function () {
      return ast;
    };

    return ast;
  };
Exemple #14
0
Project.prototype.bowerDependencies = function(bower) {
  if (!bower) {
    var bowerPath = path.join(this.root, 'bower.json');
    bower = (existsSync(bowerPath)) ? require(bowerPath) : {};
  }
  return assign({}, bower['devDependencies'], bower['dependencies']);
};
 registerSerializers(newSerializerMaps) {
   let currentSerializerMap = this._serializerMap || {};
   this._serializerMap = _assign(
     currentSerializerMap,
     newSerializerMaps
   );
 }
Exemple #16
0
  /**
   * Executes pipeline activity following a completed (successful or
   * not) computation run.
   * @private
   * @param {Error|null} err
   * @param {object} opts
   * @param {object} opts.runInputs original opts passed to run
   * @param {object} opts.runRslt
   * @param {ComputationResult} opts.compResult the ComputationResult for the environment.
   *                                @note this should only be touched by plugins.
   * @param {boolean} opts.forceSave
   * @param {boolean} opts.runCancelled
   * @returns {Promise}
   */
  _postRun(opts) {
    const runInputs = opts.runInputs;
    const runOutput = opts.runOutput;
    const compResult = opts.compResult;
    const forceSave = opts.forceSave;
    const runCancelled = opts.runCancelled;

    this.events.emit('computation:end', runInputs);
    let postRunInputs = assign({}, runInputs, { previousData: runOutput });
    return (runCancelled ?
      Promise.resolve({ didStep: false }) :
      this.tryNext(postRunInputs, { postRun: true })
    )
    .then((stepRslt) => {
      // set `inProgress` to represent whether we are about to be inProgress
      // again (e.g. if pipeline will run again). in this regard cb()s get
      // accurate depiction of state
      this.inProgress = !!stepRslt.didStep;
      this.events.emit('save-request', runOutput, null, forceSave);
      this.inProgress = false; // reset
      if (stepRslt.didStep) {
        this.events.emit('inProgress', runOutput);
        return this.run(postRunInputs, compResult);
      }
      return runOutput;
    });
  }
Exemple #17
0
MediaActions.update = function( siteId, item ) {
	var newItem;

	if ( Array.isArray( item ) ) {
		item.forEach( MediaActions.update.bind( null, siteId ) );
		return;
	}

	newItem = assign( {}, MediaStore.get( siteId, item.ID ), item );

	Dispatcher.handleViewAction( {
		type: 'RECEIVE_MEDIA_ITEM',
		siteId: siteId,
		data: newItem
	} );

	debug( 'Updating media for %d by ID %d to %o', siteId, item.ID, item );
	wpcom.site( siteId ).media( item.ID ).update( item, function( error, data ) {
		Dispatcher.handleServerAction( {
			type: 'RECEIVE_MEDIA_ITEM',
			error: error,
			siteId: siteId,
			data: data
		} );
	} );
};
Exemple #18
0
	normalizePluginData: function( plugin, pluginData ) {
		plugin = this.whiteListPluginData( assign( plugin, pluginData ) );

		return transform( plugin, function( returnData, item, key ) {
			switch ( key ) {
				case 'short_description':
				case 'description':
				case 'name':
				case 'slug':
					returnData[ key ] = decodeEntities( item );
					break;
				case 'author':
					returnData.author = item;
					returnData.author_name = PluginUtils.extractAuthorName( item );
					returnData.author_url = plugin.author_url || PluginUtils.extractAuthorUrl( item );
					break;
				case 'sections':
					let cleanItem = {};
					for ( let sectionKey of Object.keys( item ) ) {
						cleanItem[ sectionKey] = sanitizeHtml( item[ sectionKey ], {
							allowedTags: [ 'h4', 'h5', 'h6', 'blockquote', 'code', 'b', 'i', 'em', 'strong', 'a', 'p', 'img', 'ul', 'ol', 'li' ],
							allowedAttributes: { a: [ 'href' ], img: [ 'src' ] },
							allowedSchemes: [ 'http', 'https' ],
							transformTags: {
								h1: 'h3',
								h2: 'h3',
							}
						} );
					}
					returnData.sections = cleanItem;
					returnData.screenshots = cleanItem.screenshots ? PluginUtils.extractScreenshots( cleanItem.screenshots ) : null;
					break;
				case 'num_ratings':
				case 'rating':
					returnData[ key ] = parseInt( item, 10 );
					break;
				case 'ratings':
					for ( let prop in item ) {
						item[ prop ] = parseInt( item[ prop ], 10 );
					}
					returnData[ key ] = item;
					break;
				case 'icons':
					if ( item ) {
						returnData.icon = item[ '2x' ] || item[ '1x' ] || item.svg || item.default;
					}
					break;
				case 'homepage':
				case 'plugin_url':
					returnData.plugin_url = item;
					break;
				case 'compatibility':
					returnData[ key ] = PluginUtils.normalizeCompatibilityList( item );
					break;
				default:
					returnData[ key ] = item;
			}
		} );
	},
Exemple #19
0
const items = ( state = {}, action ) => {
	switch ( action.type ) {
		case JETPACK_PLUGINS_DATA_FETCH_RECEIVE:
			return assign( {}, action.pluginsData );
		default:
			return state;
	}
};
Exemple #20
0
 .catch(function (err) {
   logger.emerg('seed failure', assign(serializeError(err), {
     category: 'event',
     event: 'database-seed-failure',
     instance: instance,
     database: database
   }))
 })
Exemple #21
0
export const data = ( state = {}, action ) => {
	switch ( action.type ) {
		case JETPACK_SITE_DATA_FETCH_RECEIVE:
			return assign( {}, action.siteData );
		default:
			return state;
	}
};
export function startMirage(env = ENV) {
  let environment = env.environment;
  let discoverEmberDataModels = getWithDefault(env['ember-cli-mirage'] || {}, 'discoverEmberDataModels', false);
  let modules = readModules(env.modulePrefix);
  let options = _assign(modules, {environment, baseConfig, testConfig, discoverEmberDataModels});

  return new Server(options);
}
Exemple #23
0
	BuildSystem.config = function(cfg){
		// Merge meta configuration
		if(cfg && cfg.meta && this.meta) {
			cfg = assign({}, cfg, {
				meta: merge({}, this.meta, cfg.meta)
			});
		}
		buildConfig.call(this, cfg);
	};
 return d.values.map((datum) => {
   const radius = that.datumRadialPosition(datum)
   return assign(datum, {
     innerRadius: radius[0],
     outerRadius: radius[1],
     startAngle: this.theta(datum.start, layout.blocks[datum.block_id]),
     endAngle: this.theta(datum.end, layout.blocks[datum.block_id])
   })
 })
Exemple #25
0
function generateReactRouterServerError(type, existingErrorObj, additionalProperties) {
  var err = existingErrorObj || new Error('react router match fn error');
  err._type = type;
  if (additionalProperties) {
    assign(err, additionalProperties);
  }

  return err;
}
Exemple #26
0
MediaActions.edit = function( siteId, item ) {
	var newItem = assign( {}, MediaStore.get( siteId, item.ID ), item );

	Dispatcher.handleViewAction( {
		type: 'RECEIVE_MEDIA_ITEM',
		siteId: siteId,
		data: newItem
	} );
};
Exemple #27
0
function removeUserStepFromFlow( flow ) {
	if ( ! flow ) {
		return;
	}

	return assign( {}, flow, {
		steps: reject( flow.steps, stepName => stepConfig[ stepName ].providesToken )
	} );
}
Exemple #28
0
Project.prototype.dependencies = function(pkg, excludeDevDeps) {
  pkg = pkg || this.pkg || {};

  var devDependencies = pkg['devDependencies'];
  if (excludeDevDeps) {
    devDependencies = {};
  }

  return assign({}, devDependencies, pkg['dependencies']);
};
Exemple #29
0
      let updatedEmails = emails.map(email => {
        if (email.id === emailIdToDelete) {
          // make a copy of the email to update before updating
          return assign({}, email, {
            deleted: true
          });
        }

        return email;
      });
Exemple #30
0
 it('validateAndRun() should print a message if outside a project and command is not valid there.', function() {
   return new InsideProjectCommand(assign(options, {
     project: {
       hasDependencies: function() { return true; },
       isEmberCLIProject: function() { return false; },
     }
   })).validateAndRun([]).catch(function(reason) {
     expect(reason.message).to.match(/You have to be inside an ember-cli project/);
   });
 });