mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-15 06:16:04 +00:00
feat(v5): authorize creates, deep-link selection, list apps in v4
Restrict V5 application and resource-connection creation to team admins. Resolve project, environment, and application from query params and keep session selection in sync. Surface V5 apps on the v4 resource index and count them for project/environment emptiness. Create the flux data dir on install and upgrade.
This commit is contained in:
1 parent
772093928f
commit
a4ab69df56
23 files changed
+299
-38
No files matched your search
@@ -90,6 +90,7 @@ export default function Dashboard({
|
||||
projects = [],
|
||||
selectedProjectUuid = null,
|
||||
selectedEnvironmentUuid = null,
|
||||
selectedApplicationUuid = null,
|
||||
}: V5DashboardProps) {
|
||||
const [applications, setApplications] = useState<V5Application[]>(initialApplications);
|
||||
const [ingresses, setIngresses] = useState<V5CaddyIngress[]>(caddyIngresses);
|
||||
@@ -175,11 +176,20 @@ export default function Dashboard({
|
||||
setIngresses(settledResources.ingresses);
|
||||
resetConnections(initialResourceConnections);
|
||||
setSelectedNginxServerId((currentServerId) => currentServerId || nginxServers[0]?.id || '');
|
||||
setSelectedApplicationId(null);
|
||||
setSelectedInspectorApplicationId(null);
|
||||
const linkedApplicationExists = settledResources.applications.some((application) => application.id === selectedApplicationUuid);
|
||||
setSelectedApplicationId(linkedApplicationExists ? selectedApplicationUuid : null);
|
||||
setSelectedInspectorApplicationId(linkedApplicationExists ? selectedApplicationUuid : null);
|
||||
centerOnCanvasNodes(settledResources.applications, settledResources.ingresses);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [initialApplications, caddyIngresses, initialResourceConnections, nginxServers[0]?.id, selectedProjectUuid, selectedEnvironmentUuid]);
|
||||
}, [
|
||||
initialApplications,
|
||||
caddyIngresses,
|
||||
initialResourceConnections,
|
||||
nginxServers[0]?.id,
|
||||
selectedProjectUuid,
|
||||
selectedEnvironmentUuid,
|
||||
selectedApplicationUuid,
|
||||
]);
|
||||
|
||||
useCanvasResourceMerge({
|
||||
teamId: currentTeam?.id ?? null,
|
||||
|
||||
@@ -145,6 +145,7 @@ export type V5DashboardProps = {
|
||||
projects?: V5Project[];
|
||||
selectedProjectUuid?: string | null;
|
||||
selectedEnvironmentUuid?: string | null;
|
||||
selectedApplicationUuid?: string | null;
|
||||
};
|
||||
|
||||
export type SelectItemOption = {
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
->merge($env->clickhouses ?? collect());
|
||||
$envResources = collect()
|
||||
->merge($env->applications->map(fn($app) => ['type' => 'application', 'resource' => $app]))
|
||||
->merge($env->v5Applications->map(fn($app) => ['type' => 'v5-application', 'resource' => $app]))
|
||||
->merge($envDatabases->map(fn($db) => ['type' => 'database', 'resource' => $db]))
|
||||
->merge($env->services->map(fn($svc) => ['type' => 'service', 'resource' => $svc]))
|
||||
->sortBy(fn($item) => strtolower($item['resource']->name));
|
||||
@@ -140,6 +141,7 @@
|
||||
->merge($env->clickhouses ?? collect());
|
||||
$envResources = collect()
|
||||
->merge($env->applications->map(fn($app) => ['type' => 'application', 'resource' => $app]))
|
||||
->merge($env->v5Applications->map(fn($app) => ['type' => 'v5-application', 'resource' => $app]))
|
||||
->merge($envDatabases->map(fn($db) => ['type' => 'database', 'resource' => $db]))
|
||||
->merge($env->services->map(fn($svc) => ['type' => 'service', 'resource' => $svc]));
|
||||
@endphp
|
||||
@@ -157,6 +159,11 @@
|
||||
$resType = $envResource['type'];
|
||||
$res = $envResource['resource'];
|
||||
$resRoute = match ($resType) {
|
||||
'v5-application' => route('v5.dashboard', [
|
||||
'project' => $project->uuid,
|
||||
'environment' => $env->uuid,
|
||||
'application' => $res->uuid,
|
||||
]),
|
||||
'application' => route('project.application.configuration', [
|
||||
'project_uuid' => $project->uuid,
|
||||
'environment_uuid' => $env->uuid,
|
||||
@@ -233,10 +240,15 @@
|
||||
class="grid grid-cols-1 gap-4 pt-4 lg:grid-cols-2 xl:grid-cols-3">
|
||||
<template x-for="item in filteredApplications" :key="item.uuid">
|
||||
<span>
|
||||
<a class="h-24 coolbox group" :href="item.hrefLink" {{ wireNavigate() }}>
|
||||
<a class="h-24 coolbox group" :href="item.hrefLink"
|
||||
@click="if (item.version === 'v5') { $event.preventDefault(); window.location.assign(item.hrefLink) }"
|
||||
{{ wireNavigate() }}>
|
||||
<div class="flex flex-col w-full">
|
||||
<div class="flex gap-2 px-4">
|
||||
<div class="pb-2 truncate box-title" x-text="item.name"></div>
|
||||
<template x-if="item.version === 'v5'">
|
||||
<span class="badge">V5</span>
|
||||
</template>
|
||||
<div class="flex-1"></div>
|
||||
<template x-if="item.status.startsWith('running')">
|
||||
<div title="running" class="bg-success badge-dashboard"></div>
|
||||
@@ -271,9 +283,9 @@
|
||||
<a :href="`/tags/${tag.name}`" class="tag" x-text="tag.name">
|
||||
</a>
|
||||
</template>
|
||||
<a :href="`${item.hrefLink}/tags`" class="add-tag">
|
||||
Add tag
|
||||
</a>
|
||||
<template x-if="item.version !== 'v5'">
|
||||
<a :href="`${item.hrefLink}/tags`" class="add-tag">Add tag</a>
|
||||
</template>
|
||||
</div>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
Reference in new issue
Block a user