Page MenuHomePhabricator

Vue store cleanup: Replace all the old store access methods with the new simplified ones
Closed, ResolvedPublic

Description

Description

The methods we have been using to access and alter the state are incredibly complex and difficult to use, for example:

addZType: function ( context, objectId ) {
    var nextId;
    context.dispatch( 'setZObjectValue', { id: objectId, value: 'object' } );

    // Set type
    context.dispatch( 'addZObject', { key: Constants.Z_OBJECT_TYPE, value: Constants.Z_TYPE, parent: objectId } );

    // Set identity
    context.dispatch( 'addZObject', { key: Constants.Z_TYPE_IDENTITY, value: Constants.NEW_ZID_PLACEHOLDER, parent: objectId } );

    // Set keys
    nextId = zobjectTreeUtils.getNextObjectId( context.rootState.zobjectModule.zobject );
    context.dispatch( 'addZObject', { key: Constants.Z_TYPE_KEYS, value: 'object', parent: objectId } );
    context.dispatch( 'changeType', { id: nextId, type: Constants.Z_TYPED_LIST, value: Constants.Z_KEY } );

    // Set validator
    nextId = zobjectTreeUtils.getNextObjectId( context.rootState.zobjectModule.zobject );
    context.dispatch( 'addZObject', { key: Constants.Z_TYPE_VALIDATOR, value: 'object', parent: objectId } );
    context.dispatch( 'changeType', { id: nextId, type: Constants.Z_REFERENCE, value: Constants.Z_VALIDATE_OBJECT } );
},

Can be simply replaced with the following two lines:

addBlankZType: function ( context, rowId ) {

    // Get the JSON to inject in current rowIndex for a blank Z_TYPE
    var blankZType = context.getters.getScaffolding( Constants.Z_TYPE );

    // Call the function injectZObject to recursively add all the object into the table space
    context.dispatch( ‘injectZObjectFromRowId’, { index: rowId, value: blankZType } );
 } );

As part of the default component POC we have created a set of new store interfaces that are simple and intuitive to use, which will be used for the development of DefaultView.

This task is to replace the complex methods from Function Editor and Function Viewer with the new ones, so that we can have the whole front-end modifying its state with only a few, intuitive, documented and heavily tested methods.


Completion checklist

Event Timeline

Change 926432 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] Remove unused components from old UI

https://gerrit.wikimedia.org/r/926432

Change 927212 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] Replace old getZkeyLabels method with getLabel

https://gerrit.wikimedia.org/r/927212

Change 927244 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] Replace getZkeys with getStoredObject

https://gerrit.wikimedia.org/r/927244

Change 927212 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Replace old getZkeyLabels method with getLabel

https://gerrit.wikimedia.org/r/927212

Change 927244 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Replace getZkeys with getStoredObject

https://gerrit.wikimedia.org/r/927244

Jdforrester-WMF subscribed.

Confirmed, nice work past-Geno. :-)