diff --git a/frontend/src/lib/components/ChangeInstanceUsername.svelte b/frontend/src/lib/components/ChangeInstanceUsername.svelte index 89e7f470a1..e4f696bfd0 100644 --- a/frontend/src/lib/components/ChangeInstanceUsername.svelte +++ b/frontend/src/lib/components/ChangeInstanceUsername.svelte @@ -1,75 +1,11 @@ {isConflict ? 'Fix username conflict' : 'Change username'} -
- {isConflict ? 'Fix username conflict' : 'Change username'} - - {isConflict ? 'Auto-generated instance username' : 'New username'} - - - {#if isConflict} - - Users are required to have an instance-wide username that is shared across all workspaces. - However, this user has different usernames in different workspaces. - - {#if usernameInfo?.workspace_usernames && usernameInfo.workspace_usernames.filter((w) => w.username !== username).length > 0} -
-
- Workspaces requiring username modification: {usernameInfo.workspace_usernames - .filter((w) => w.username !== username) - .map((wu) => `${wu.workspace_id} (${wu.username})`) - .join(', ')} - {/if} -
- {/if} - - {#if !isConflict && usernameInfo?.workspace_usernames && usernameInfo.workspace_usernames.filter((w) => w.username !== username).length > 0} - - {usernameInfo.workspace_usernames - .filter((w) => w.username !== username) - .map((wu) => `${wu.workspace_id}`) - .join(', ')} - - {/if} - - - This operation does not handle references in scripts, workflows and applications to scripts in - the workspace, and references in resources to variables. You will have to handle those - manually. -
-
- - -
+ close(null)} + on:renamed + />
diff --git a/frontend/src/lib/components/ChangeInstanceUsernameInner.svelte b/frontend/src/lib/components/ChangeInstanceUsernameInner.svelte new file mode 100644 index 0000000000..a321f4ac1d --- /dev/null +++ b/frontend/src/lib/components/ChangeInstanceUsernameInner.svelte @@ -0,0 +1,135 @@ + + +
+ {isConflict ? 'Fix username conflict' : 'Change username'} + + {isConflict ? 'Auto-generated instance username' : 'New username'} + + + {#if isConflict} + + Users are required to have an instance-wide username that is shared across all workspaces. + However, this user has different usernames in different workspaces. + + {#if usernameInfo?.workspace_usernames && usernameInfo.workspace_usernames.filter((w) => w.username !== username).length > 0} +
+
+ Workspaces requiring username modification: {usernameInfo.workspace_usernames + .filter((w) => w.username !== username) + .map((wu) => `${wu.workspace_id} (${wu.username})`) + .join(', ')} + {/if} +
+ {/if} + + {#if !isConflict && usernameInfo?.workspace_usernames && usernameInfo.workspace_usernames.filter((w) => w.username !== username).length > 0} + + {usernameInfo.workspace_usernames + .filter((w) => w.username !== username) + .map((wu) => `${wu.workspace_id}`) + .join(', ')} + + {/if} + + + This operation does not handle references in scripts, workflows and applications to scripts in + the workspace, and references in resources to variables. You will have to handle those manually. +
+
+ + +
diff --git a/frontend/src/lib/components/InstanceNameEditor.svelte b/frontend/src/lib/components/InstanceNameEditor.svelte new file mode 100644 index 0000000000..20f2993715 --- /dev/null +++ b/frontend/src/lib/components/InstanceNameEditor.svelte @@ -0,0 +1,68 @@ + + + + + + + + diff --git a/frontend/src/lib/components/SuperadminSettings.svelte b/frontend/src/lib/components/SuperadminSettings.svelte index d6b1d22755..104918b2eb 100644 --- a/frontend/src/lib/components/SuperadminSettings.svelte +++ b/frontend/src/lib/components/SuperadminSettings.svelte @@ -22,6 +22,7 @@ import ChangeInstanceUsername from './ChangeInstanceUsername.svelte' import Tooltip from './Tooltip.svelte' import { isCloudHosted } from '$lib/cloud' + import InstanceNameEditor from './InstanceNameEditor.svelte' let drawer: Drawer let filter = '' @@ -72,6 +73,21 @@ sendUserToast('Automatic username creation enabled') listUsers() } + + async function updateName(name: string | undefined, email: string) { + try { + await UserService.globalUserUpdate({ + email, + requestBody: { + name + } + }) + sendUserToast('User updated') + listUsers() + } catch (e) { + sendUserToast('Error updating user', true) + } + }
- {#if automateUsernameCreation && username} - { - listUsers() - }} - /> - {/if} + { + updateName(e.detail, email) + }} + on:renamed={() => { + listUsers() + }} + {automateUsernameCreation} + />