From 1aa4966a92fc66f6d2ecc24e42201459c57f2b58 Mon Sep 17 00:00:00 2001 From: badrAZ Date: Fri, 17 Aug 2018 10:05:20 +0200 Subject: [PATCH] feat(xo-web/SelectTag): allow non existing tags (#3316) --- packages/xo-web/src/common/select-objects.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/xo-web/src/common/select-objects.js b/packages/xo-web/src/common/select-objects.js index b41a8db11..ac8cbc2b6 100644 --- a/packages/xo-web/src/common/select-objects.js +++ b/packages/xo-web/src/common/select-objects.js @@ -119,6 +119,7 @@ const getObjectsById = objects => */ class GenericSelect extends React.Component { static propTypes = { + allowMissingObjects: PropTypes.bool, hasSelectAll: PropTypes.bool, multi: PropTypes.bool, onChange: PropTypes.func.isRequired, @@ -138,7 +139,8 @@ class GenericSelect extends React.Component { () => this.props.xoContainers !== undefined, () => this.props.xoObjects, this._getSelectedIds, - (withContainers, objects, ids) => { + () => !this.props.allowMissingObjects, + (withContainers, objects, ids, removed) => { const objectsById = getObjectsById(objects) const missingObjects = [] const addIfMissing = id => { @@ -146,8 +148,8 @@ class GenericSelect extends React.Component { missingObjects.push({ id, label: id, + removed, value: id, - removed: true, }) } } @@ -580,7 +582,7 @@ export const SelectTag = makeStoreSelect( tags => map(tags, tag => ({ id: tag, type: 'tag', value: tag })) ), }), - { placeholder: _('selectTags') } + { allowMissingObjects: true, placeholder: _('selectTags') } ) export const SelectHighLevelObject = makeStoreSelect(