From dbd4fbc9915a4f3fd3296f548fc8c770771f92f6 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Thu, 21 Jul 2016 15:18:29 -0700 Subject: [PATCH] Make Request switcher only show from current workspace --- app/components/RequestSwitcherModal.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/components/RequestSwitcherModal.js b/app/components/RequestSwitcherModal.js index bf331c5e3d..c792b68a26 100644 --- a/app/components/RequestSwitcherModal.js +++ b/app/components/RequestSwitcherModal.js @@ -56,13 +56,28 @@ class RequestSwitcherModal extends ModalComponent { } _handleChange (searchString) { + const {workspaceId} = this.props; + Promise.all([ db.requestAll(), db.requestGroupAll() ]).then(([ - requests, - requestGroups + allRequests, + allRequestGroups ]) => { + // TODO: Support nested RequestGroups + // Filter out RequestGroups that don't belong to this Workspace + const requestGroups = allRequestGroups.filter(rg => rg.parentId === workspaceId); + + // Filter out Requests that don't belong to this Workspace + const requests = allRequests.filter(r => { + if (r.parentId === workspaceId) { + return true; + } else { + return !!requestGroups.find(rg => rg._id === r.parentId); + } + }); + const {parentId} = this.props; const activeRequestGroup = requestGroups.find(rg => rg._id === parentId);