mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-11 17:44:19 -05:00
get username works for service users
This commit is contained in:
@@ -6,7 +6,7 @@ use komodo_client::{
|
||||
ListApiKeysForServiceUserResponse, ListApiKeysResponse,
|
||||
ListUsers, ListUsersResponse,
|
||||
},
|
||||
entities::user::{User, UserConfig},
|
||||
entities::user::{admin_service_user, User, UserConfig},
|
||||
};
|
||||
use mungos::{
|
||||
by_id::find_one_by_id,
|
||||
@@ -26,6 +26,13 @@ impl Resolve<GetUsername, User> for State {
|
||||
GetUsername { user_id }: GetUsername,
|
||||
_: User,
|
||||
) -> anyhow::Result<GetUsernameResponse> {
|
||||
if let Some(user) = admin_service_user(&user_id) {
|
||||
return Ok(GetUsernameResponse {
|
||||
username: user.username,
|
||||
avatar: None,
|
||||
});
|
||||
}
|
||||
|
||||
let user = find_one_by_id(&db_client().users, &user_id)
|
||||
.await
|
||||
.context("failed at mongo query for user")?
|
||||
|
||||
@@ -28,7 +28,6 @@ import { Link } from "react-router-dom";
|
||||
import { fmt_duration, fmt_operation, fmt_version } from "@lib/formatting";
|
||||
import {
|
||||
cn,
|
||||
is_service_user,
|
||||
updateLogToHtml,
|
||||
usableResourcePath,
|
||||
version_is_none,
|
||||
@@ -50,44 +49,6 @@ export const UpdateUser = ({
|
||||
iconSize?: number;
|
||||
defaultAvatar?: boolean;
|
||||
muted?: boolean;
|
||||
}) => {
|
||||
if (is_service_user(user_id)) {
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"flex items-center gap-2 text-nowrap",
|
||||
muted && "text-muted-foreground",
|
||||
className
|
||||
)}
|
||||
>
|
||||
<User className={`w-${iconSize} h-${iconSize}`} />
|
||||
{user_id}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<RealUpdateUser
|
||||
user_id={user_id}
|
||||
className={className}
|
||||
iconSize={iconSize}
|
||||
defaultAvatar={defaultAvatar}
|
||||
muted={muted}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const RealUpdateUser = ({
|
||||
user_id,
|
||||
className,
|
||||
iconSize = 4,
|
||||
defaultAvatar,
|
||||
muted,
|
||||
}: {
|
||||
user_id: string;
|
||||
className?: string;
|
||||
iconSize?: number;
|
||||
defaultAvatar?: boolean;
|
||||
muted?: boolean;
|
||||
}) => {
|
||||
const res = useRead("GetUsername", { user_id }).data;
|
||||
const username = res?.username;
|
||||
|
||||
@@ -231,20 +231,6 @@ export const sync_no_changes = (sync: Types.ResourceSync) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const is_service_user = (user_id: string) => {
|
||||
return (
|
||||
user_id === "System" ||
|
||||
user_id === "Procedure" ||
|
||||
user_id === "Github" ||
|
||||
user_id === "Git Webhook" ||
|
||||
user_id === "Auto Redeploy" ||
|
||||
user_id === "Resource Sync" ||
|
||||
user_id === "Stack Wizard" ||
|
||||
user_id === "Build Manager" ||
|
||||
user_id === "Repo Manager"
|
||||
);
|
||||
};
|
||||
|
||||
export const extract_registry_domain = (image_name: string) => {
|
||||
if (!image_name) return "docker.io";
|
||||
const maybe_domain = image_name.split("/")[0];
|
||||
|
||||
Reference in New Issue
Block a user