mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 00:00:33 +00:00
create workspace require superadmin is now default
This commit is contained in:
@@ -111,6 +111,7 @@ pub fn global_service() -> Router {
|
||||
.route("/allowed_domain_auto_invite", get(is_allowed_auto_domain))
|
||||
.route("/unarchive/:workspace", post(unarchive_workspace))
|
||||
.route("/delete/:workspace", delete(delete_workspace))
|
||||
.route("/create_workspace_require_superadmin", get(create_workspace_require_superadmin))
|
||||
}
|
||||
|
||||
#[cfg(feature = "enterprise")]
|
||||
@@ -1070,10 +1071,19 @@ async fn check_name_conflict<'c>(tx: &mut Transaction<'c, Postgres>, w_id: &str)
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
|
||||
pub static ref CREATE_WORKSPACE_REQUIRE_SUPERADMIN: bool = std::env::var("CREATE_WORKSPACE_REQUIRE_SUPERADMIN").is_ok_and(|x| x.parse::<bool>().unwrap_or(true));
|
||||
pub static ref CREATE_WORKSPACE_REQUIRE_SUPERADMIN: bool = {
|
||||
match std::env::var("CREATE_WORKSPACE_REQUIRE_SUPERADMIN") {
|
||||
Ok(val) => val == "true",
|
||||
Err(_) => true,
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
async fn create_workspace_require_superadmin() -> String {
|
||||
format!("{}", *CREATE_WORKSPACE_REQUIRE_SUPERADMIN)
|
||||
}
|
||||
|
||||
async fn _check_nb_of_workspaces(db: &DB) -> Result<()> {
|
||||
let nb_workspaces = sqlx::query_scalar!("SELECT COUNT(*) FROM workspace WHERE id != 'admins' AND deleted = false",)
|
||||
.fetch_one(db)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
import { USER_SETTINGS_HASH } from '$lib/components/sidebar/settings'
|
||||
import { switchWorkspace } from '$lib/storeUtils'
|
||||
import { Cog, Crown } from 'lucide-svelte'
|
||||
import { isCloudHosted } from '$lib/cloud'
|
||||
|
||||
let invites: WorkspaceInvite[] = []
|
||||
let list_all_as_super_admin: boolean = false
|
||||
@@ -71,6 +72,18 @@
|
||||
$: nonAdminWorkspaces = (workspaces ?? []).filter((x) => x.id != 'admins')
|
||||
$: noWorkspaces = $superadmin && nonAdminWorkspaces.length == 0
|
||||
|
||||
async function getCreateWorkspaceRequireSuperadmin() {
|
||||
const r = await fetch('/api/workspaces/create_workspace_require_superadmin')
|
||||
const t = await r.text()
|
||||
createWorkspace = t != 'true'
|
||||
}
|
||||
|
||||
let createWorkspace = $superadmin || isCloudHosted()
|
||||
|
||||
if (!createWorkspace) {
|
||||
getCreateWorkspaceRequireSuperadmin()
|
||||
}
|
||||
|
||||
loadInvites()
|
||||
loadWorkspaces()
|
||||
|
||||
@@ -114,7 +127,8 @@
|
||||
{#if workspaces && $usersWorkspaceStore}
|
||||
{#if workspaces.length == 0}
|
||||
<p class="text-sm text-tertiary mt-2">
|
||||
You are not a member of any workspace yet. Accept an invitation or create your own
|
||||
You are not a member of any workspace yet. Accept an invitation {#if createWorkspace}or
|
||||
create your own{/if}
|
||||
workspace.
|
||||
</p>
|
||||
{/if}
|
||||
@@ -157,16 +171,18 @@
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<div class="flex flex-row-reverse pt-4">
|
||||
<Button
|
||||
size="sm"
|
||||
btnClasses={noWorkspaces ? 'animate-bounce hover:animate-none' : ''}
|
||||
color={noWorkspaces ? 'dark' : 'blue'}
|
||||
href="/user/create_workspace{rd ? `?rd=${encodeURIComponent(rd)}` : ''}"
|
||||
variant={noWorkspaces ? 'contained' : 'border'}
|
||||
>+ Create a new workspace
|
||||
</Button>
|
||||
</div>
|
||||
{#if createWorkspace}
|
||||
<div class="flex flex-row-reverse pt-4">
|
||||
<Button
|
||||
size="sm"
|
||||
btnClasses={noWorkspaces ? 'animate-bounce hover:animate-none' : ''}
|
||||
color={noWorkspaces ? 'dark' : 'blue'}
|
||||
href="/user/create_workspace{rd ? `?rd=${encodeURIComponent(rd)}` : ''}"
|
||||
variant={noWorkspaces ? 'contained' : 'border'}
|
||||
>+ Create a new workspace
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<h2 class="mt-6 mb-4">Invites to join a Workspace</h2>
|
||||
{#if invites.length == 0}
|
||||
|
||||
Reference in New Issue
Block a user