From 131fa446ee0ce5c755d96ed81d2c4da6c386bed7 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Wed, 4 Oct 2023 13:35:52 -0400 Subject: [PATCH] Initial bug fixes for tool shed 2. --- lib/tool_shed/managers/users.py | 4 +++- lib/tool_shed/webapp/api2/users.py | 2 +- .../webapp/frontend/src/components/ShedToolbar.vue | 4 +--- .../src/components/pages/RepositoryPage.vue | 2 +- lib/tool_shed/webapp/frontend/src/schema/schema.ts | 14 ++++++++------ lib/tool_shed_client/schema/__init__.py | 4 ++++ 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/tool_shed/managers/users.py b/lib/tool_shed/managers/users.py index 055aaf1945d1..7d9012cf938b 100644 --- a/lib/tool_shed/managers/users.py +++ b/lib/tool_shed/managers/users.py @@ -12,7 +12,7 @@ from tool_shed.webapp.model import User from tool_shed_client.schema import ( CreateUserRequest, - User as ApiUser, + UserV2 as ApiUser, ) @@ -58,9 +58,11 @@ def api_create_user(trans: ProvidesUserContext, request: CreateUserRequest) -> A def get_api_user(app: ToolShedApp, user: User) -> ApiUser: + admin = user.email in app.config.admin_users return ApiUser( id=app.security.encode_id(user.id), username=user.username, + is_admin=admin, ) diff --git a/lib/tool_shed/webapp/api2/users.py b/lib/tool_shed/webapp/api2/users.py index 8873d8b9800f..fefef4e71a7d 100644 --- a/lib/tool_shed/webapp/api2/users.py +++ b/lib/tool_shed/webapp/api2/users.py @@ -34,7 +34,7 @@ from tool_shed.webapp.model import User as SaUser from tool_shed_client.schema import ( CreateUserRequest, - User, + UserV2 as User, ) from . import ( depends, diff --git a/lib/tool_shed/webapp/frontend/src/components/ShedToolbar.vue b/lib/tool_shed/webapp/frontend/src/components/ShedToolbar.vue index 631d2349f8ac..3338c42984c1 100644 --- a/lib/tool_shed/webapp/frontend/src/components/ShedToolbar.vue +++ b/lib/tool_shed/webapp/frontend/src/components/ShedToolbar.vue @@ -8,13 +8,11 @@ defineProps({ required: true, }, }) -// TODO: recover from the API -const ADMINS = ["jmchilton"] const authStore = useAuthStore() void authStore.setup() -const admin = computed(() => authStore.user && ADMINS.indexOf(authStore.user.username) > -1) +const admin = computed(() => authStore.user && authStore.user.is_admin)