Show ratings for own published tools, hide Rate button instead

Own tools now display the rating bar (average, count) so authors can
see how their tool is rated. The Rate button is hidden entirely for
own tools rather than shown disabled, since the server enforces the
self-review restriction anyway.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rob 2026-01-30 02:36:32 -04:00
parent b1c73aba3f
commit 7022bb10f2
1 changed files with 11 additions and 22 deletions

View File

@ -943,54 +943,43 @@ class ToolsPage(QWidget):
self.main_window.show_status(f"Published '{tool_name}'") self.main_window.show_status(f"Published '{tool_name}'")
def _update_rate_button(self): def _update_rate_button(self):
"""Update the Rate button state based on current selection.""" """Update the Rate button visibility and state based on current selection."""
if not self._current_tool: if not self._current_tool:
self.btn_rate.setEnabled(False) self.btn_rate.setVisible(False)
self.btn_rate.setText("Rate Tool")
self.btn_rate.setToolTip("Select a tool to rate")
return return
tool_name = self._get_qualified_name() tool_name = self._get_qualified_name()
if not tool_name: if not tool_name:
self.btn_rate.setEnabled(False) self.btn_rate.setVisible(False)
self.btn_rate.setText("Rate Tool")
self.btn_rate.setToolTip("Select a tool to rate")
return return
registry_info = get_tool_registry_info(tool_name) registry_info = get_tool_registry_info(tool_name)
if not registry_info: if not registry_info:
self.btn_rate.setEnabled(False) self.btn_rate.setVisible(False)
self.btn_rate.setText("Rate Tool")
self.btn_rate.setToolTip("Local tools can't be rated")
return return
config = load_config() config = load_config()
if not config.registry.token: if not config.registry.token:
self.btn_rate.setEnabled(False) self.btn_rate.setVisible(False)
self.btn_rate.setText("Rate Tool")
self.btn_rate.setToolTip("Sign in to rate")
return return
owner, name = registry_info owner, name = registry_info
# Check if this is the user's own tool # Hide button entirely for your own tools
if self._my_slug and owner == self._my_slug: if self._my_slug and owner == self._my_slug:
self.btn_rate.setEnabled(False) self.btn_rate.setVisible(False)
self.btn_rate.setText("Rate Tool")
self.btn_rate.setToolTip("You can't rate your own tool")
return return
# Check if user has an existing review # Show and enable for other registry tools
self.btn_rate.setVisible(True)
self.btn_rate.setEnabled(True)
cached = self._rating_cache.get(tool_name) cached = self._rating_cache.get(tool_name)
if cached and cached.get("my_review"): if cached and cached.get("my_review"):
self.btn_rate.setText("Edit Rating") self.btn_rate.setText("Edit Rating")
else: else:
self.btn_rate.setText("Rate Tool") self.btn_rate.setText("Rate Tool")
self.btn_rate.setEnabled(True)
self.btn_rate.setToolTip("")
def _fetch_my_slug(self): def _fetch_my_slug(self):
"""Fetch and cache the current user's slug.""" """Fetch and cache the current user's slug."""
if self._my_slug_fetched: if self._my_slug_fetched: