From aaeb12afacb07e86f9784a6ffca18ee7ae232069 Mon Sep 17 00:00:00 2001 From: Evgeny Kochetkov Date: Wed, 19 Apr 2017 18:36:08 +0300 Subject: [PATCH] refactor(xod-project): get rid of patch labels --- packages/xod-project/src/adapter.js | 7 ------- packages/xod-project/src/patch.js | 25 ------------------------- packages/xod-project/test/patch.spec.js | 19 ------------------- 3 files changed, 51 deletions(-) diff --git a/packages/xod-project/src/adapter.js b/packages/xod-project/src/adapter.js index fcb23bcd..5975cbee 100644 --- a/packages/xod-project/src/adapter.js +++ b/packages/xod-project/src/adapter.js @@ -80,8 +80,6 @@ export const mergePatchesAndNodeTypes = R.converge( ] ); -// :: {} -> String -const getLabel = R.prop('label'); // :: {} -> [a] const getNodes = propValues('nodes'); // :: {} -> [a] @@ -99,10 +97,6 @@ const assocPatchUnsafe = R.curry( (path, patch, project) => R.assocPath(['patches', path], patch, project) ); -// :: Patch -> Maybe fn -// fn :: Patch -> Patch -const addLabel = oldPatch => Maybe(getLabel(oldPatch)).map(Patch.setPatchLabel); - // :: String -> String export const convertPinType = R.cond([ [R.equals('bool'), R.always('boolean')], @@ -313,7 +307,6 @@ const convertPatches = R.compose( return Tuple(nodeIdMap, assocNodes); }, R.map(oldPatch => Maybe.of(Patch.createPatch()) - .chain(apOrSkip(addLabel(oldPatch))) .chain(apOrSkip(copyImpls(oldPatch))) .map(convertPatchPins(oldPatch)) .map(convertNodes(oldPatch)) diff --git a/packages/xod-project/src/patch.js b/packages/xod-project/src/patch.js index 11addd32..9a740fe4 100644 --- a/packages/xod-project/src/patch.js +++ b/packages/xod-project/src/patch.js @@ -43,31 +43,6 @@ export const duplicatePatch = def( R.clone ); -/** - * @function getPatchLabel - * @param {Patch} patch - * @returns {string} - */ -export const getPatchLabel = def( - 'getPatchLabel :: Patch -> Label', - // TODO: when label field is included in type definition, remove fallback to '' - R.propOr('', 'label') -); - -/** - * @function setPatchLabel - * @param {string} label - * @param {Patch} patch - * @returns {Patch} a copy of the `patch` with new label - */ -export const setPatchLabel = def( - 'setPatchLabel :: Label -> Patch -> Patch', - R.useWith( - R.assoc('label'), - [String, R.identity] - ) -); - /** * @function getPatchPath * @param {Patch} patch diff --git a/packages/xod-project/test/patch.spec.js b/packages/xod-project/test/patch.spec.js index c75d379d..6d2faa90 100644 --- a/packages/xod-project/test/patch.spec.js +++ b/packages/xod-project/test/patch.spec.js @@ -56,25 +56,6 @@ describe('Patch', () => { }); }); - // properties - describe('getPatchLabel', () => { - it('should return patch label', () => { - const patch = Helper.defaultizePatch({ label: 'patchLabel' }); - expect(Patch.getPatchLabel(patch)).to.be.equal('patchLabel'); - }); - }); - describe('setPatchLabel', () => { - it('should return patch with new label', () => { - const newLabel = 'new label'; - const patch = Helper.defaultizePatch({ label: 'old label' }); - const newPatch = Patch.setPatchLabel(newLabel, patch); - - expect(newPatch) - .to.have.property('label') - .that.is.a('string') - .that.equals(newLabel); - }); - }); describe('listImpls', () => { it('should return empty array for empty patch', () => { expect(Patch.listImpls(emptyPatch))