From 7c0ba551b8d53f16758ec0f7b7d8ca0994df08b1 Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Tue, 7 Nov 2023 13:41:45 -0600 Subject: [PATCH 1/8] Bug/WP-354: Workspace search - filter results visible to user (#893) * Workspace search - result filtering * add comments * Add protection in client side processing * Test with system prefix filter on id field * Add back search filtering with tapis listing * Use -1 as limit for listing projects --- .../DataFilesProjectsList/DataFilesProjectsList.jsx | 4 +++- server/portal/apps/projects/views.py | 11 +++++++++-- .../shared_workspace_operations.py | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/client/src/components/DataFiles/DataFilesProjectsList/DataFilesProjectsList.jsx b/client/src/components/DataFiles/DataFilesProjectsList/DataFilesProjectsList.jsx index 93c4f3181..f90f80791 100644 --- a/client/src/components/DataFiles/DataFilesProjectsList/DataFilesProjectsList.jsx +++ b/client/src/components/DataFiles/DataFilesProjectsList/DataFilesProjectsList.jsx @@ -85,7 +85,9 @@ const DataFilesProjectsList = ({ modal }) => { Header: 'ID', headerStyle: { textAlign: 'left' }, accessor: 'name', - Cell: (el) => {el.value.split('-').slice(-1)[0]}, + Cell: (el) => ( + {el.value ? el.value.split('-').slice(-1)[0] : ''} + ), }, ]; diff --git a/server/portal/apps/projects/views.py b/server/portal/apps/projects/views.py index ca03a8479..d98e8807b 100644 --- a/server/portal/apps/projects/views.py +++ b/server/portal/apps/projects/views.py @@ -84,10 +84,17 @@ def get(self, request): search = search.query(ngram_query | wildcard_query) search = search.extra(from_=int(offset), size=int(limit)) + search = search.filter('prefix', **{'id': f'{settings.PORTAL_PROJECTS_SYSTEM_PREFIX}'}) res = search.execute() - hits = [hit.to_dict() for hit in res] - listing = hits + hits = list(map(lambda hit: hit.id, res)) + listing = [] + # Filter search results to projects specific to user + if hits: + client = request.user.tapis_oauth.client + listing = list_projects(client) + filtered_list = filter(lambda prj: prj['id'] in hits, listing) + listing = list(filtered_list) else: client = request.user.tapis_oauth.client listing = list_projects(client) diff --git a/server/portal/apps/projects/workspace_operations/shared_workspace_operations.py b/server/portal/apps/projects/workspace_operations/shared_workspace_operations.py index a72cff46e..081a6059a 100644 --- a/server/portal/apps/projects/workspace_operations/shared_workspace_operations.py +++ b/server/portal/apps/projects/workspace_operations/shared_workspace_operations.py @@ -274,9 +274,12 @@ def list_projects(client): fields = "id,host,description,notes,updated,owner,rootDir" query = f"id.like.{settings.PORTAL_PROJECTS_SYSTEM_PREFIX}.*" + # use limit as -1 to allow search to corelate with + # all projects available to the api user listing = client.systems.getSystems(listType='ALL', search=query, - select=fields) + select=fields, + limit=-1) serialized_listing = map(lambda prj: { "id": prj.id, From e9352254d96b99d8d71ade748eba11856f1d8bbe Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Tue, 7 Nov 2023 16:07:59 -0600 Subject: [PATCH 2/8] Use homedir to isolate the search. (#897) --- server/portal/apps/site_search/api/unit_test.py | 2 +- server/portal/apps/site_search/api/views.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/portal/apps/site_search/api/unit_test.py b/server/portal/apps/site_search/api/unit_test.py index b871a3e70..3c3911428 100644 --- a/server/portal/apps/site_search/api/unit_test.py +++ b/server/portal/apps/site_search/api/unit_test.py @@ -144,7 +144,7 @@ def test_file_search_util(mock_file_search, regular_user): [{'name': 'testfile', 'path': '/path/to/testfile'}]} client = regular_user.tapis_oauth.client - res = files_search(client, 'test_query', 'test_system') + res = files_search(client, 'test_query', 'test_system', '/',) mock_file_search.assert_called_with(client, 'test_system', '/', query_string='test_query', diff --git a/server/portal/apps/site_search/api/views.py b/server/portal/apps/site_search/api/views.py index 7203e15e2..70cf3cefa 100644 --- a/server/portal/apps/site_search/api/views.py +++ b/server/portal/apps/site_search/api/views.py @@ -36,8 +36,8 @@ def cms_search(query_string, offset=0, limit=10): return total, results -def files_search(client, query_string, system, filter=None, offset=0, limit=10): - res = search_operation(client, system, '/', offset=offset, limit=limit, +def files_search(client, query_string, system, path, filter=None, offset=0, limit=10): + res = search_operation(client, system, path, offset=offset, limit=limit, query_string=query_string, filter=filter) return (res['count'], res['listing']) @@ -65,7 +65,7 @@ def get(self, request, *args, **kwargs): and ('siteSearchPriority' in conf and conf['siteSearchPriority'] is not None)) client = request.user.tapis_oauth.client if (request.user.is_authenticated and request.user.profile.setup_complete) else service_account() (public_total, public_results) = \ - files_search(client, qs, public_conf['system'], filter=filter, + files_search(client, qs, public_conf['system'], public_conf.get("homeDir", "/"), filter=filter, offset=offset, limit=limit) response['public'] = {'count': public_total, 'listing': public_results, @@ -84,7 +84,7 @@ def get(self, request, *args, **kwargs): and ('siteSearchPriority' in conf and conf['siteSearchPriority'] is not None)) client = request.user.tapis_oauth.client (community_total, community_results) = \ - files_search(client, qs, community_conf['system'], filter=filter, + files_search(client, qs, community_conf['system'], community_conf.get("homeDir", "/"), filter=filter, offset=offset, limit=limit) response['community'] = {'count': community_total, From ab77b1e7328846518aabe995b5c46ba85ed39508 Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Tue, 7 Nov 2023 16:27:20 -0600 Subject: [PATCH 3/8] Fix query string construction (#896) --- server/portal/apps/workspace/api/views.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/portal/apps/workspace/api/views.py b/server/portal/apps/workspace/api/views.py index f76b36402..9e263e08a 100644 --- a/server/portal/apps/workspace/api/views.py +++ b/server/portal/apps/workspace/api/views.py @@ -188,7 +188,12 @@ def listing(self, client, request): return data def search(self, client, request): - + ''' + Search using tapis in specific portal with providing query string. + Additonal parameters for search: + limit - limit param from request, otherwise default to 10 + offset - offset param from request, otherwise default to 0 + ''' query_string = request.GET.get('query_string') limit = int(request.GET.get('limit', 10)) @@ -197,10 +202,10 @@ def search(self, client, request): sql_queries = [ f"(tags IN ('portalName: {portal_name}')) AND", - f"(name like '%{query_string}%') OR", + f"((name like '%{query_string}%') OR", f"(archiveSystemDir like '%{query_string}%') OR", f"(appId like '%{query_string}%') OR", - f"(archiveSystemId like '%{query_string}%')", + f"(archiveSystemId like '%{query_string}%'))", ] data = client.jobs.getJobSearchListByPostSqlStr( @@ -212,7 +217,6 @@ def search(self, client, request): }, select="allAttributes" ) - return data def delete(self, request, *args, **kwargs): From fb996d51d7aa81629c697f9bc1962c48a8f72580 Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Tue, 7 Nov 2023 21:46:33 -0600 Subject: [PATCH 4/8] Hotfix 3.3.1 changelist --- CHANGELOG.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44f22257f..261e2a0e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [3.3.1] - 2023-11-07: Search related bug fixes and App Icon fix +- WP-355: Fixing issue with icons on dev/prod sites (#892) +- WP-354: Workspace search - filter results visible to user (#893) +- WP-356: Site Search: For files, use home dir to isolate the search (#897) +- WP-361: Jobs Search - restrict search to a specific portal (#896) + ## [3.3.0] - 2023-10-27: V3 integration improvements; bug fixes ### Added @@ -983,7 +989,8 @@ WP-306: Fix target path regression (#871) ## [1.0.0] - 2020-02-28 v1.0.0 Production release as of Feb 28, 2020. -[unreleased]: https://github.com/TACC/Core-Portal/compare/v3.3.0...HEAD +[unreleased]: https://github.com/TACC/Core-Portal/compare/v3.3.1...HEAD +[3.3.1]: https://github.com/TACC/Core-Portal/releases/tag/v3.3.1 [3.3.0]: https://github.com/TACC/Core-Portal/releases/tag/v3.3.0 [3.2.1]: https://github.com/TACC/Core-Portal/releases/tag/v3.2.1 [3.2.0]: https://github.com/TACC/Core-Portal/releases/tag/v3.2.0 From 4d95df11af9003c7f74f404c15f20fc5a404265d Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Thu, 9 Nov 2023 10:06:27 -0600 Subject: [PATCH 5/8] Remove id prefix post filter (#898) --- server/portal/apps/projects/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/server/portal/apps/projects/views.py b/server/portal/apps/projects/views.py index d98e8807b..fe25e2bc5 100644 --- a/server/portal/apps/projects/views.py +++ b/server/portal/apps/projects/views.py @@ -84,7 +84,6 @@ def get(self, request): search = search.query(ngram_query | wildcard_query) search = search.extra(from_=int(offset), size=int(limit)) - search = search.filter('prefix', **{'id': f'{settings.PORTAL_PROJECTS_SYSTEM_PREFIX}'}) res = search.execute() hits = list(map(lambda hit: hit.id, res)) From 5e6be960d09f75236dddc8d1d8a7f169af06aaa2 Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Thu, 9 Nov 2023 11:49:14 -0600 Subject: [PATCH 6/8] create hotfix 3.3.2 --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 261e2a0e5..82784f37e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - +## [3.3.2] - 2023-11-09: workspace search fails on frontera portal +- WP-380: Remove id prefix filter on workspace search (#898) + ## [3.3.1] - 2023-11-07: Search related bug fixes and App Icon fix - WP-355: Fixing issue with icons on dev/prod sites (#892) - WP-354: Workspace search - filter results visible to user (#893) @@ -989,7 +991,8 @@ WP-306: Fix target path regression (#871) ## [1.0.0] - 2020-02-28 v1.0.0 Production release as of Feb 28, 2020. -[unreleased]: https://github.com/TACC/Core-Portal/compare/v3.3.1...HEAD +[unreleased]: https://github.com/TACC/Core-Portal/compare/v3.3.2...HEAD +[3.3.2]: https://github.com/TACC/Core-Portal/releases/tag/v3.3.2 [3.3.1]: https://github.com/TACC/Core-Portal/releases/tag/v3.3.1 [3.3.0]: https://github.com/TACC/Core-Portal/releases/tag/v3.3.0 [3.2.1]: https://github.com/TACC/Core-Portal/releases/tag/v3.2.1 From 4d006aab41df90865991f8f6d270be9ebe9db928 Mon Sep 17 00:00:00 2001 From: Van Go <35277477+van-go@users.noreply.github.com> Date: Tue, 14 Nov 2023 10:03:39 -0600 Subject: [PATCH 7/8] WP-104: phantom entry in ViewTab when user removed (#884) * wp-104: phantom entry n ViewTab when user removed * maintain selected card value if it exists * prettier * requested changes * prettier --------- Co-authored-by: Chandra Y --- .../AllocationsTeamViewModal.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/src/components/Allocations/AllocationsModals/AllocationsTeamViewModal/AllocationsTeamViewModal.jsx b/client/src/components/Allocations/AllocationsModals/AllocationsTeamViewModal/AllocationsTeamViewModal.jsx index 08132979f..413147cb2 100644 --- a/client/src/components/Allocations/AllocationsModals/AllocationsTeamViewModal/AllocationsTeamViewModal.jsx +++ b/client/src/components/Allocations/AllocationsModals/AllocationsTeamViewModal/AllocationsTeamViewModal.jsx @@ -83,6 +83,15 @@ const AllocationsTeamViewModal = ({ isOpen, toggle }) => { const handleTabChange = (e, newValue) => { setSelectedTab(newValue); }; + + let selectedUser = null; + if (removingUserOperation && removingUserOperation.username) { + selectedUser = removingUserOperation.username; + } + if (card && card.username === selectedUser) { + setCard(null); + } + return ( From 1af7c8f5f00db782f78d8b799ca96699ad7afa8f Mon Sep 17 00:00:00 2001 From: Chandra Y Date: Wed, 15 Nov 2023 08:29:29 -0600 Subject: [PATCH 8/8] project search:Handle scenario where id is missing (#899) --- server/portal/apps/projects/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/portal/apps/projects/views.py b/server/portal/apps/projects/views.py index fe25e2bc5..94addcc15 100644 --- a/server/portal/apps/projects/views.py +++ b/server/portal/apps/projects/views.py @@ -86,7 +86,7 @@ def get(self, request): search = search.extra(from_=int(offset), size=int(limit)) res = search.execute() - hits = list(map(lambda hit: hit.id, res)) + hits = [hit.id for hit in res if hasattr(hit, 'id') and hit.id is not None] listing = [] # Filter search results to projects specific to user if hits: