forked from github-starred/komodo
get username works for service users
This commit is contained in:
@@ -6,7 +6,7 @@ use komodo_client::{
|
|||||||
ListApiKeysForServiceUserResponse, ListApiKeysResponse,
|
ListApiKeysForServiceUserResponse, ListApiKeysResponse,
|
||||||
ListUsers, ListUsersResponse,
|
ListUsers, ListUsersResponse,
|
||||||
},
|
},
|
||||||
entities::user::{User, UserConfig},
|
entities::user::{admin_service_user, User, UserConfig},
|
||||||
};
|
};
|
||||||
use mungos::{
|
use mungos::{
|
||||||
by_id::find_one_by_id,
|
by_id::find_one_by_id,
|
||||||
@@ -26,6 +26,13 @@ impl Resolve<GetUsername, User> for State {
|
|||||||
GetUsername { user_id }: GetUsername,
|
GetUsername { user_id }: GetUsername,
|
||||||
_: User,
|
_: User,
|
||||||
) -> anyhow::Result<GetUsernameResponse> {
|
) -> 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)
|
let user = find_one_by_id(&db_client().users, &user_id)
|
||||||
.await
|
.await
|
||||||
.context("failed at mongo query for user")?
|
.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 { fmt_duration, fmt_operation, fmt_version } from "@lib/formatting";
|
||||||
import {
|
import {
|
||||||
cn,
|
cn,
|
||||||
is_service_user,
|
|
||||||
updateLogToHtml,
|
updateLogToHtml,
|
||||||
usableResourcePath,
|
usableResourcePath,
|
||||||
version_is_none,
|
version_is_none,
|
||||||
@@ -50,44 +49,6 @@ export const UpdateUser = ({
|
|||||||
iconSize?: number;
|
iconSize?: number;
|
||||||
defaultAvatar?: boolean;
|
defaultAvatar?: boolean;
|
||||||
muted?: 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 res = useRead("GetUsername", { user_id }).data;
|
||||||
const username = res?.username;
|
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) => {
|
export const extract_registry_domain = (image_name: string) => {
|
||||||
if (!image_name) return "docker.io";
|
if (!image_name) return "docker.io";
|
||||||
const maybe_domain = image_name.split("/")[0];
|
const maybe_domain = image_name.split("/")[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user