diff --git a/client/src/components/History/HistoryPublishedList.vue b/client/src/components/History/HistoryPublishedList.vue index 906f6cf3be6f..16522e086504 100644 --- a/client/src/components/History/HistoryPublishedList.vue +++ b/client/src/components/History/HistoryPublishedList.vue @@ -1,44 +1,63 @@ + + diff --git a/client/src/entry/analysis/router.js b/client/src/entry/analysis/router.js index a45d8cd5768f..c0d6d8010bc6 100644 --- a/client/src/entry/analysis/router.js +++ b/client/src/entry/analysis/router.js @@ -266,7 +266,11 @@ export function getRouter(Galaxy) { { path: "histories/list_published", component: HistoryPublishedList, - props: true, + props: (route) => { + return { + ...route.query, + }; + }, }, { path: "histories/archived", diff --git a/lib/galaxy/managers/histories.py b/lib/galaxy/managers/histories.py index eecb73b61d9b..2f89fb1bed86 100644 --- a/lib/galaxy/managers/histories.py +++ b/lib/galaxy/managers/histories.py @@ -884,3 +884,19 @@ def _add_parsers(self): "update_time": {"op": ("le", "ge", "gt", "lt"), "val": self.parse_date}, } ) + self.fn_filter_parsers.update( + { + "username": { + "op": { + "eq": self.username_eq, + "contains": self.username_contains, + }, + }, + } + ) + + def username_eq(self, item, val: str) -> bool: + return val.lower() == str(item.user.username).lower() + + def username_contains(self, item, val: str) -> bool: + return val.lower() in str(item.user.username).lower() diff --git a/lib/galaxy_test/selenium/test_histories_published.py b/lib/galaxy_test/selenium/test_histories_published.py index c3d0ba4868f0..aa609a7880e8 100644 --- a/lib/galaxy_test/selenium/test_histories_published.py +++ b/lib/galaxy_test/selenium/test_histories_published.py @@ -54,6 +54,29 @@ def test_published_histories_tag_click(self): self.assert_histories_present([self.history3_name, self.history1_name]) + @selenium_test + def test_published_histories_username_click(self): + self._login() + self.navigate_to_published_histories() + self.sleep_for(self.wait_types.UX_RENDER) + present_histories = self.get_present_histories() + clicked = False + for row in present_histories: + his = row.find_elements(By.TAG_NAME, "td")[0] + if self.history2_name in his.text: + row.find_elements(By.TAG_NAME, "td")[2].find_elements( + By.CSS_SELECTOR, ".published-histories-username-link" + )[0].click() + clicked = True + break + + assert clicked + text = self.components.published_histories.search_input.wait_for_value() + if "test2" not in text: + raise AssertionError("Failed to update search filter with username on username click") + + self.assert_histories_present([self.history2_name]) + @selenium_test def test_published_histories_search_standard(self): self._login() diff --git a/test/unit/app/managers/test_HistoryManager.py b/test/unit/app/managers/test_HistoryManager.py index f24ff8ffc3e6..6809f564af82 100644 --- a/test/unit/app/managers/test_HistoryManager.py +++ b/test/unit/app/managers/test_HistoryManager.py @@ -795,10 +795,57 @@ def test_orm_filter_parsing(self): def test_fn_filter_parsing(self): user2 = self.user_manager.create(**user2_data) + user3 = self.user_manager.create(**user3_data) history1 = self.history_manager.create(name="history1", user=user2) history2 = self.history_manager.create(name="history2", user=user2) history3 = self.history_manager.create(name="history3", user=user2) + history4 = self.history_manager.create(name="history4", user=user3) + + # test username eq filter + filters_2 = self.filter_parser.parse_filters( + [ + ("username", "eq", "user2"), + ] + ) + filters_3 = self.filter_parser.parse_filters( + [ + ("username", "eq", "user3"), + ] + ) + username_filter_2 = filters_2[0].filter + username_filter_3 = filters_3[0].filter + + assert username_filter_2(history1) + assert username_filter_2(history2) + assert username_filter_2(history3) + assert not username_filter_2(history4) + assert not username_filter_3(history1) + assert not username_filter_3(history2) + assert not username_filter_3(history3) + assert username_filter_3(history4) + + assert self.history_manager.list(filters=filters_2) == [history1, history2, history3] + assert self.history_manager.list(filters=filters_3) == [history4] + + # test username contains filter + filters = self.filter_parser.parse_filters( + [ + ("username", "contains", "user"), + ] + ) + + assert self.history_manager.list(filters=filters) == [history1, history2, history3, history4] + + # test username eq filter (inequality) + filters = self.filter_parser.parse_filters( + [ + ("username", "eq", "user"), + ] + ) + + assert self.history_manager.list(filters=filters) == [] + # test annotation filter filters = self.filter_parser.parse_filters( [ ("annotation", "has", "no play"),