fix: show that user is disabled in workspacelist (#6748)
* fix: show that user is disabled in workspacelist * Update SQLx metadata --------- Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT workspace.id, workspace.name, usr.username, workspace_settings.color, workspace.parent_workspace_id,\n CASE WHEN usr.operator THEN workspace_settings.operator_settings ELSE NULL END as operator_settings\n FROM workspace\n JOIN usr ON usr.workspace_id = workspace.id\n JOIN workspace_settings ON workspace_settings.workspace_id = workspace.id\n WHERE usr.email = $1 AND workspace.deleted = false",
|
||||
"query": "SELECT workspace.id, workspace.name, usr.username, workspace_settings.color, workspace.parent_workspace_id,\n CASE WHEN usr.operator THEN workspace_settings.operator_settings ELSE NULL END as operator_settings,\n usr.disabled\n FROM workspace\n JOIN usr ON usr.workspace_id = workspace.id\n JOIN workspace_settings ON workspace_settings.workspace_id = workspace.id\n WHERE usr.email = $1 AND workspace.deleted = false",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -32,6 +32,11 @@
|
||||
"ordinal": 5,
|
||||
"name": "operator_settings",
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "disabled",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
@@ -45,8 +50,9 @@
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
null
|
||||
null,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "d0037961e8e787c4277afc3eb79f3b72e3323f878387de8b6fa31493f1215a77"
|
||||
"hash": "c095a9658c542efc9f0255a1b536d2fd8a25fe4cd57c223db7d744493f8470c6"
|
||||
}
|
||||
@@ -18010,11 +18010,14 @@ components:
|
||||
created_by:
|
||||
type: string
|
||||
nullable: true
|
||||
disabled:
|
||||
type: boolean
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- username
|
||||
- color
|
||||
- disabled
|
||||
required:
|
||||
- email
|
||||
- workspaces
|
||||
|
||||
@@ -366,6 +366,7 @@ struct UserWorkspace {
|
||||
pub color: Option<String>,
|
||||
pub operator_settings: Option<Option<serde_json::Value>>,
|
||||
pub parent_workspace_id: Option<String>,
|
||||
pub disabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -2109,7 +2110,8 @@ async fn user_workspaces(
|
||||
let workspaces = sqlx::query_as!(
|
||||
UserWorkspace,
|
||||
"SELECT workspace.id, workspace.name, usr.username, workspace_settings.color, workspace.parent_workspace_id,
|
||||
CASE WHEN usr.operator THEN workspace_settings.operator_settings ELSE NULL END as operator_settings
|
||||
CASE WHEN usr.operator THEN workspace_settings.operator_settings ELSE NULL END as operator_settings,
|
||||
usr.disabled
|
||||
FROM workspace
|
||||
JOIN usr ON usr.workspace_id = workspace.id
|
||||
JOIN workspace_settings ON workspace_settings.workspace_id = workspace.id
|
||||
|
||||
@@ -140,12 +140,17 @@
|
||||
<MenuItem
|
||||
class={twMerge(
|
||||
'text-xs min-w-0 w-full overflow-hidden flex flex-col py-1.5',
|
||||
workspace.disabled && 'opacity-50 cursor-not-allowed',
|
||||
$workspaceStore === workspace.id
|
||||
? 'cursor-default bg-surface-selected'
|
||||
: 'cursor-pointer hover:bg-surface-hover data-[highlighted]:bg-surface-hover'
|
||||
: workspace.disabled
|
||||
? ''
|
||||
: 'cursor-pointer hover:bg-surface-hover data-[highlighted]:bg-surface-hover'
|
||||
)}
|
||||
onClick={async () => {
|
||||
await toggleSwitchWorkspace(workspace.id)
|
||||
if (!workspace.disabled) {
|
||||
await toggleSwitchWorkspace(workspace.id)
|
||||
}
|
||||
}}
|
||||
{item}
|
||||
>
|
||||
@@ -166,7 +171,7 @@
|
||||
isForked ? 'text-secondary' : 'text-primary'
|
||||
)}
|
||||
>
|
||||
{workspace.name}
|
||||
{workspace.name}{workspace.disabled ? ' (user disabled)' : ''}
|
||||
</div>
|
||||
<div
|
||||
class={twMerge(
|
||||
|
||||
@@ -37,6 +37,7 @@ export interface UserWorkspace {
|
||||
color?: string
|
||||
operator_settings?: OperatorSettings
|
||||
parent_workspace_id?: string | null
|
||||
disabled: boolean
|
||||
}
|
||||
|
||||
const persistedWorkspace = BROWSER && getWorkspace()
|
||||
@@ -89,7 +90,8 @@ export const userWorkspaces: Readable<Array<UserWorkspace>> = derived(
|
||||
name: 'Admins',
|
||||
username: 'superadmin',
|
||||
color: undefined,
|
||||
operator_settings: undefined
|
||||
operator_settings: undefined,
|
||||
disabled: false
|
||||
}
|
||||
]
|
||||
} else {
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
async function loadWorkspacesAsAdmin() {
|
||||
workspaces = (await WorkspaceService.listWorkspacesAsSuperAdmin({ perPage: 1000 })).map((x) => {
|
||||
return { ...x, username: 'superadmin' }
|
||||
return { ...x, username: 'superadmin', disabled: false }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -205,9 +205,16 @@
|
||||
<label class="block pb-2" style:padding-left={`${depth * 24}px`}>
|
||||
<button
|
||||
class="w-full mx-auto py-1 px-2 rounded-md border
|
||||
shadow-sm text-sm text-secondary font-normal mt-1 hover:ring-1 hover:ring-indigo-300 flex items-center"
|
||||
shadow-sm text-sm text-secondary font-normal mt-1 flex items-center"
|
||||
class:opacity-50={workspace.disabled}
|
||||
class:cursor-not-allowed={workspace.disabled}
|
||||
class:hover:ring-1={!workspace.disabled}
|
||||
class:hover:ring-indigo-300={!workspace.disabled}
|
||||
disabled={workspace.disabled}
|
||||
on:click={async () => {
|
||||
speakFriendAndEnterWorkspace(workspace.id)
|
||||
if (!workspace.disabled) {
|
||||
speakFriendAndEnterWorkspace(workspace.id)
|
||||
}
|
||||
}}
|
||||
>
|
||||
{#if isForked}
|
||||
@@ -227,6 +234,9 @@
|
||||
{#if workspace['deleted']}
|
||||
<span class="text-red-500"> (archived)</span>
|
||||
{/if}
|
||||
{#if workspace.disabled}
|
||||
<span class="text-red-500"> (user disabled in this workspace)</span>
|
||||
{/if}
|
||||
{#if isForked && parentName}
|
||||
<span class="text-tertiary text-xs mt-1">
|
||||
<br />
|
||||
|
||||
Reference in New Issue
Block a user