mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02be78a26e | ||
|
|
711d4613ed | ||
|
|
a5fe5225e1 | ||
|
|
b752d9437c | ||
|
|
18df92e048 | ||
|
|
4e66b8ed04 | ||
|
|
4f14d16452 | ||
|
|
592588ef76 | ||
|
|
3fec7c3392 | ||
|
|
2335caefd7 | ||
|
|
194eedeaa8 | ||
|
|
ecd09aedb9 | ||
|
|
b5350b5fe3 | ||
|
|
ceaafd5531 | ||
|
|
654accad4a | ||
|
|
173c7894b4 | ||
|
|
1ab51d15f9 | ||
|
|
ddce51d2d3 | ||
|
|
fc9fbf4357 | ||
|
|
5e8cd7e0e6 | ||
|
|
1eb5fbb983 | ||
|
|
d9ccb389f0 | ||
|
|
dc80d1d752 | ||
|
|
ff28a80d7c | ||
|
|
ab55ab349a | ||
|
|
a1ec7dbec2 | ||
|
|
e29846ae25 | ||
|
|
e38519aec2 | ||
|
|
a620d7a9f7 | ||
|
|
88ebd79681 | ||
|
|
e08efa12fa | ||
|
|
7a685c0518 | ||
|
|
4deaaa2c8e | ||
|
|
adaf0f89fb | ||
|
|
47de5373b1 | ||
|
|
db9d23b5ec | ||
|
|
47c74931d4 | ||
|
|
be01031501 | ||
|
|
2e656d9c41 | ||
|
|
9071193c4d | ||
|
|
27e1da6363 | ||
|
|
e02c5496ae | ||
|
|
3fee236fd0 |
@@ -1,6 +1,12 @@
|
||||
# Environment
|
||||
NODE_ENV=development
|
||||
|
||||
# Logging
|
||||
# Controls minimum log level. Options: debug | info | warn | error
|
||||
# Set to "warn" or "error" in production to suppress health-check ping noise.
|
||||
# Use "debug" to see all request logs including agent status pings.
|
||||
LOG_LEVEL=info
|
||||
|
||||
# Database
|
||||
DATABASE_URL=postgresql://devuser:changeme@localhost:5433/devdb?schema=public
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ on:
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -57,12 +58,51 @@ jobs:
|
||||
exit 1
|
||||
|
||||
- name: Install Playwright browsers
|
||||
run: pnpm exec playwright install --with-deps chromium firefox webkit
|
||||
run: pnpm exec playwright install --with-deps chromium
|
||||
|
||||
- name: Run Playwright tests
|
||||
run: pnpm exec playwright test --project chromium
|
||||
run: pnpm exec playwright test
|
||||
env:
|
||||
PROJECT_URL: http://localhost:8887
|
||||
# E2E Notification
|
||||
E2E_NOTIFICATION_SMTP_HOST: ${{ secrets.E2E_NOTIFICATION_SMTP_HOST }}
|
||||
E2E_NOTIFICATION_SMTP_PORT: ${{ secrets.E2E_NOTIFICATION_SMTP_PORT }}
|
||||
E2E_NOTIFICATION_SMTP_USER: ${{ secrets.E2E_NOTIFICATION_SMTP_USER }}
|
||||
E2E_NOTIFICATION_SMTP_PASSWORD: ${{ secrets.E2E_NOTIFICATION_SMTP_PASSWORD }}
|
||||
E2E_NOTIFICATION_SMTP_FROM: ${{ secrets.E2E_NOTIFICATION_SMTP_FROM }}
|
||||
E2E_NOTIFICATION_SMTP_TO: ${{ secrets.E2E_NOTIFICATION_SMTP_TO }}
|
||||
E2E_NOTIFICATION_SLACK_WEBHOOK: ${{ secrets.E2E_NOTIFICATION_SLACK_WEBHOOK }}
|
||||
E2E_NOTIFICATION_DISCORD_WEBHOOK: ${{ secrets.E2E_NOTIFICATION_DISCORD_WEBHOOK }}
|
||||
E2E_NOTIFICATION_TELEGRAM_BOT_TOKEN: ${{ secrets.E2E_NOTIFICATION_TELEGRAM_BOT_TOKEN }}
|
||||
E2E_NOTIFICATION_TELEGRAM_CHAT_ID: ${{ secrets.E2E_NOTIFICATION_TELEGRAM_CHAT_ID }}
|
||||
E2E_NOTIFICATION_TELEGRAM_TOPIC_ID: ${{ secrets.E2E_NOTIFICATION_TELEGRAM_TOPIC_ID }}
|
||||
E2E_NOTIFICATION_GOTIFY_SERVER_URL: ${{ secrets.E2E_NOTIFICATION_GOTIFY_SERVER_URL }}
|
||||
E2E_NOTIFICATION_GOTIFY_APP_TOKEN: ${{ secrets.E2E_NOTIFICATION_GOTIFY_APP_TOKEN }}
|
||||
E2E_NOTIFICATION_NTFY_TOPIC: ${{ secrets.E2E_NOTIFICATION_NTFY_TOPIC }}
|
||||
E2E_NOTIFICATION_NTFY_SERVER_URL: ${{ secrets.E2E_NOTIFICATION_NTFY_SERVER_URL }}
|
||||
E2E_NOTIFICATION_NTFY_TOKEN: ${{ secrets.E2E_NOTIFICATION_NTFY_TOKEN }}
|
||||
E2E_NOTIFICATION_NTFY_USERNAME: ${{ secrets.E2E_NOTIFICATION_NTFY_USERNAME }}
|
||||
E2E_NOTIFICATION_NTFY_PASSWORD: ${{ secrets.E2E_NOTIFICATION_NTFY_PASSWORD }}
|
||||
E2E_NOTIFICATION_WEBHOOK_URL: ${{ secrets.E2E_NOTIFICATION_WEBHOOK_URL }}
|
||||
E2E_NOTIFICATION_WEBHOOK_SECRET_HEADER: ${{ secrets.E2E_NOTIFICATION_WEBHOOK_SECRET_HEADER }}
|
||||
E2E_NOTIFICATION_WEBHOOK_SECRET: ${{ secrets.E2E_NOTIFICATION_WEBHOOK_SECRET }}
|
||||
|
||||
# E2E Storage
|
||||
E2E_STORAGE_AWS_S3_ENDPOINT_URL: ${{ secrets.E2E_STORAGE_AWS_S3_ENDPOINT_URL }}
|
||||
E2E_STORAGE_AWS_S3_REGION: ${{ secrets.E2E_STORAGE_AWS_S3_REGION }}
|
||||
E2E_STORAGE_AWS_S3_ACCESS_KEY: ${{ secrets.E2E_STORAGE_AWS_S3_ACCESS_KEY }}
|
||||
E2E_STORAGE_AWS_S3_SECRET_KEY: ${{ secrets.E2E_STORAGE_AWS_S3_SECRET_KEY }}
|
||||
E2E_STORAGE_AWS_S3_BUCKET_NAME: ${{ secrets.E2E_STORAGE_AWS_S3_BUCKET_NAME }}
|
||||
E2E_STORAGE_AWS_S3_PORT: ${{ secrets.E2E_STORAGE_AWS_S3_PORT }}
|
||||
E2E_STORAGE_R2_ENDPOINT_URL: ${{ secrets.E2E_STORAGE_R2_ENDPOINT_URL }}
|
||||
E2E_STORAGE_R2_REGION: ${{ secrets.E2E_STORAGE_R2_REGION }}
|
||||
E2E_STORAGE_R2_ACCESS_KEY: ${{ secrets.E2E_STORAGE_R2_ACCESS_KEY }}
|
||||
E2E_STORAGE_R2_SECRET_KEY: ${{ secrets.E2E_STORAGE_R2_SECRET_KEY }}
|
||||
E2E_STORAGE_R2_BUCKET_NAME: ${{ secrets.E2E_STORAGE_R2_BUCKET_NAME }}
|
||||
E2E_STORAGE_R2_PORT: ${{ secrets.E2E_STORAGE_R2_PORT }}
|
||||
E2E_STORAGE_GOOGLE_DRIVE_CLIENT_ID: ${{ secrets.E2E_STORAGE_GOOGLE_DRIVE_CLIENT_ID }}
|
||||
E2E_STORAGE_GOOGLE_DRIVE_CLIENT_SECRET: ${{ secrets.E2E_STORAGE_GOOGLE_DRIVE_CLIENT_SECRET }}
|
||||
E2E_STORAGE_GOOGLE_DRIVE_FOLDER_ID: ${{ secrets.E2E_STORAGE_GOOGLE_DRIVE_FOLDER_ID }}
|
||||
|
||||
- name: Upload report if failed
|
||||
if: failure()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: Auto Release & Publish
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
pull_request_target:
|
||||
types: [ closed ]
|
||||
branches:
|
||||
- main
|
||||
|
||||
@@ -9,7 +9,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: aquasecurity/trivy-action@0.35.0
|
||||
- uses: aquasecurity/trivy-action@v0.35.0
|
||||
with:
|
||||
scan-type: 'fs'
|
||||
format: 'table'
|
||||
|
||||
@@ -54,3 +54,8 @@ certificates
|
||||
/blob-report/
|
||||
/playwright/.cache/
|
||||
/playwright/.auth/
|
||||
/e2e/local-storage.json
|
||||
|
||||
.claude
|
||||
.codex
|
||||
/docs
|
||||
|
||||
+3
-1
@@ -21,6 +21,8 @@ keywords:
|
||||
- backups
|
||||
- postgresql
|
||||
- mysql
|
||||
- firebird
|
||||
- mssql
|
||||
- mariadb
|
||||
- devops
|
||||
- database
|
||||
@@ -31,5 +33,5 @@ keywords:
|
||||
- web-ui
|
||||
- agent
|
||||
license: Apache-2.0
|
||||
version: 1.10.0
|
||||
version: 1.14.1
|
||||
date-released: '2026-03-02'
|
||||
|
||||
@@ -16,7 +16,7 @@ seed-pocket:
|
||||
@docker compose -f docker-compose.func.yml stop pocket-id >/dev/null 2>&1 || true
|
||||
@docker compose -f docker-compose.func.yml rm -f -s pocket-id >/dev/null 2>&1 || true
|
||||
@docker volume rm portabase-dev-func_pocket-id-data >/dev/null 2>&1 || true
|
||||
@docker compose -f docker-compose.func.yml run --rm -v ./seeds/pocket-id/portabase.zip:/tmp/portabase.zip pocket-id ./pocket-id import --yes --path /tmp/portabase.zip >/dev/null
|
||||
@docker compose -f docker-compose.func.yml run --rm -v $$(pwd)/seeds/pocket-id/portabase.zip:/tmp/portabase.zip pocket-id ./pocket-id import --yes --path /tmp/portabase.zip >/dev/null
|
||||
@docker compose -f docker-compose.func.yml up -d pocket-id
|
||||
@sleep 2
|
||||
@docker compose -f docker-compose.func.yml exec pocket-id ./pocket-id one-time-access-token admin
|
||||
@@ -46,3 +46,17 @@ export-keycloak:
|
||||
@docker rm -f kc-exporter >/dev/null 2>&1
|
||||
@docker compose -f docker-compose.func.yml start keycloak >/dev/null 2>&1
|
||||
@echo "Keycloak configuration and users exported to seeds/keycloak/*.json"
|
||||
|
||||
end-to-end:
|
||||
@echo "Starting E2E testing..."
|
||||
@docker compose -f docker-compose.e2e.yml up -d
|
||||
@CI=true PROJECT_URL=http://localhost:8887 pnpm playwright test --project=chromium || (docker compose -f docker-compose.e2e.yml down --volumes && exit 1)
|
||||
@docker compose -f docker-compose.e2e.yml down --volumes
|
||||
@echo "Finished E2E testing successfully."
|
||||
|
||||
e2e-manual:
|
||||
@echo "Starting E2E testing..."
|
||||
@docker compose -f docker-compose.e2e.yml up -d
|
||||
@pnpm playwright test --ui || (docker compose -f docker-compose.e2e.yml down --volumes && exit 1)
|
||||
@docker compose -f docker-compose.e2e.yml down --volumes
|
||||
@echo "Finished E2E testing successfully."
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
[](LICENSE)
|
||||
[](https://hub.docker.com/r/portabase/portabase)
|
||||
[](https://github.com/Portabase/portabase/pkgs/container/charts%2Fportabase)
|
||||
[](https://github.com/Portabase/portabase)
|
||||
[](https://www.buymeacoffee.com/portabase)
|
||||
|
||||
@@ -21,8 +22,11 @@
|
||||
[](https://mariadb.org/)
|
||||
[](https://sqlite.org/)
|
||||
[](https://redis.io/)
|
||||
[](https://valkey.io/)
|
||||
[](https://www.mongodb.com/)
|
||||
[](https://valkey.io/)
|
||||
[](https://firebirdsql.org/)
|
||||
[](https://www.microsoft.com/en-us/sql-server)
|
||||
|
||||
[](https://github.com/Portabase/portabase)
|
||||
[](https://github.com/Portabase/portabase)
|
||||
|
||||
@@ -62,17 +66,17 @@ You have 4 ways to install Portabase:
|
||||
|
||||
## Supported databases
|
||||
|
||||
| Engine | Support | Supported Versions | Restore |
|
||||
|:-------------------|:----------|:----------------------------------|:--------|
|
||||
| **PostgreSQL** | ✅ Stable | 12, 13, 14, 15, 16, 17 and 18 | Yes |
|
||||
| **MySQL** | ✅ Stable | 5.7, 8 and 9 | Yes |
|
||||
| **MariaDB** | ✅ Stable | 10 and 11 | Yes |
|
||||
| **MongoDB** | ✅ Stable | 4, 5, 6, 7 and 8 | Yes |
|
||||
| **SQLite** | ✅ Stable | 3.x | Yes |
|
||||
| **Redis** | ✅ Stable | 2.8+ | No |
|
||||
| **Valkey** | ✅ Stable | 7.2+ | No |
|
||||
| **MSSQL Server** | ❌ Ongoing | - | Yes |
|
||||
| **Firebird** | ❌ Ongoing | - | Yes |
|
||||
| Engine | Support | Supported Versions | Restore |
|
||||
|:-------------------|:----------|:------------------------------|:--------|
|
||||
| **PostgreSQL** | ✅ Stable | 12, 13, 14, 15, 16, 17 and 18 | Yes |
|
||||
| **MySQL** | ✅ Stable | 5.7, 8 and 9 | Yes |
|
||||
| **MariaDB** | ✅ Stable | 10 and 11 | Yes |
|
||||
| **MongoDB** | ✅ Stable | 4, 5, 6, 7 and 8 | Yes |
|
||||
| **SQLite** | ✅ Stable | 3.x | Yes |
|
||||
| **Redis** | ✅ Stable | 2.8+ | No |
|
||||
| **Valkey** | ✅ Stable | 7.2+ | No |
|
||||
| **Firebird** | ✅ Stable | 3.0, 4.0, 5.0 | Yes |
|
||||
| **MSSQL Server** | ✅ Stable | 2017, 2019, 2022, Azure SQL | Yes |
|
||||
|
||||
See the [Database Servers documentation](https://portabase.io/docs/agent/db) for version-specific backup and restore details.
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {db} from "@/db";
|
||||
import {logger} from "@/lib/logger";
|
||||
import {notFound} from "next/navigation";
|
||||
import {SettingsTabs} from "@/components/wrappers/dashboard/admin/settings/settings-tabs";
|
||||
import {desc, isNull} from "drizzle-orm";
|
||||
@@ -8,13 +9,15 @@ import * as drizzleDb from "@/db";
|
||||
import {StorageChannelWith} from "@/db/schema/12_storage-channel";
|
||||
import {NotificationChannelWith} from "@/db/schema/09_notification-channel";
|
||||
|
||||
const log = logger.child({module: "dashboard/admin/settings"});
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
|
||||
const settings = await db.query.setting.findFirst({
|
||||
where: (fields, {eq}) => eq(fields.name, "system"),
|
||||
});
|
||||
|
||||
console.log(settings)
|
||||
log.debug({settings}, "Settings loaded");
|
||||
|
||||
const storageChannels = await db.query.storageChannel.findMany({
|
||||
with: {
|
||||
@@ -33,7 +36,7 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
}) as NotificationChannelWith[]
|
||||
|
||||
|
||||
if (!settings || !storageChannels || !notificationChannels ) {
|
||||
if (!settings || !storageChannels || !notificationChannels) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
@@ -45,7 +48,8 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
</div>
|
||||
</PageHeader>
|
||||
<PageContent className="flex flex-col gap-5">
|
||||
<SettingsTabs storageChannels={storageChannels} notificationChannels={notificationChannels} settings={settings} />
|
||||
<SettingsTabs storageChannels={storageChannels} notificationChannels={notificationChannels}
|
||||
settings={settings}/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "@/features/layout/page";
|
||||
import { db } from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
import {eq, isNull} from "drizzle-orm";
|
||||
import { notFound } from "next/navigation";
|
||||
import { ButtonDeleteAgent } from "@/components/wrappers/dashboard/agent/button-delete-agent/button-delete-agent";
|
||||
import { capitalizeFirstLetter } from "@/utils/text";
|
||||
@@ -15,7 +15,7 @@ import { generateEdgeKey } from "@/utils/edge_key";
|
||||
import { getServerUrl } from "@/utils/get-server-url";
|
||||
import { AgentContentPage } from "@/components/wrappers/dashboard/agent/agent-content";
|
||||
import { AgentDialog } from "@/features/agents/components/agent.dialog";
|
||||
import { AgentType } from "@/features/agents/agents.schema";
|
||||
|
||||
|
||||
export default async function RoutePage(
|
||||
props: PageParams<{ agentId: string }>,
|
||||
@@ -26,13 +26,30 @@ export default async function RoutePage(
|
||||
where: eq(drizzleDb.schemas.agent.id, agentId),
|
||||
with: {
|
||||
databases: true,
|
||||
organizations: true,
|
||||
},
|
||||
});
|
||||
|
||||
const organizations = await db.query.organization.findMany({
|
||||
where: (fields) => isNull(fields.deletedAt),
|
||||
with: {
|
||||
members: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (!agent) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const isOwnerByAnOrganization = agent.organizationId
|
||||
|
||||
if (isOwnerByAnOrganization){
|
||||
notFound();
|
||||
}
|
||||
|
||||
const organizationIds = agent.organizations.map(org => org.organizationId)
|
||||
|
||||
const edgeKey = await generateEdgeKey(getServerUrl(), agent.id);
|
||||
|
||||
return (
|
||||
@@ -45,12 +62,14 @@ export default async function RoutePage(
|
||||
<div className="flex items-center gap-2 md:justify-between w-full ">
|
||||
<div className="flex items-center gap-2">
|
||||
<AgentDialog
|
||||
agent={agent as AgentType & { id: string }}
|
||||
agent={agent}
|
||||
typeTrigger={"edit"}
|
||||
adminView={true}
|
||||
organizations={organizations}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<ButtonDeleteAgent agentId={agentId} text={"Delete Agent"} />
|
||||
<ButtonDeleteAgent organizationIds={organizationIds} agentId={agentId} text={"Delete Agent"} />
|
||||
</div>
|
||||
</div>
|
||||
</PageTitle>
|
||||
|
||||
@@ -5,7 +5,7 @@ import {Page, PageActions, PageContent, PageHeader, PageTitle} from "@/features/
|
||||
import {notFound} from "next/navigation";
|
||||
import {db} from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {desc, eq, not} from "drizzle-orm";
|
||||
import {and, desc, eq, isNull, not} from "drizzle-orm";
|
||||
import {Metadata} from "next";
|
||||
import {AgentDialog} from "@/features/agents/components/agent.dialog";
|
||||
|
||||
@@ -16,13 +16,13 @@ export const metadata: Metadata = {
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
|
||||
const agents = await db.query.agent.findMany({
|
||||
where: not(eq(drizzleDb.schemas.agent.isArchived, true)),
|
||||
where: and(not(eq(drizzleDb.schemas.agent.isArchived, true)),isNull(drizzleDb.schemas.agent.organizationId)),
|
||||
with: {
|
||||
databases: true
|
||||
},
|
||||
orderBy: (fields) => desc(fields.lastContact),
|
||||
});
|
||||
|
||||
|
||||
if (!agents) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {Page, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
||||
import {notFound} from "next/navigation";
|
||||
import {getOrganization} from "@/lib/auth/auth";
|
||||
import {Metadata} from "next";
|
||||
import {db} from "@/db";
|
||||
import {MigrationTool} from "@/components/wrappers/dashboard/organization/migration/migration-tool";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Projects",
|
||||
};
|
||||
|
||||
export default async function RoutePage(props: PageParams<{}>) {
|
||||
|
||||
const organization = await getOrganization({});
|
||||
|
||||
if (!organization) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const projects = await db.query.project.findMany({
|
||||
where: (project, {eq, and, not}) =>
|
||||
and(
|
||||
eq(project.organizationId, organization.id),
|
||||
not(eq(project.isArchived, true))
|
||||
),
|
||||
with: {
|
||||
organization: true,
|
||||
databases: {
|
||||
where: (database, { isNull, not, inArray, and }) =>
|
||||
and(
|
||||
isNull(database.deletedAt),
|
||||
not(inArray(database.dbms, ["valkey", "redis"]))
|
||||
),
|
||||
|
||||
with: {
|
||||
backups: {
|
||||
where: (backup, { isNull, eq, and }) =>
|
||||
and(
|
||||
isNull(backup.deletedAt),
|
||||
eq(backup.status, "success")
|
||||
),
|
||||
orderBy: (backup, {desc}) => [desc(backup.createdAt)],
|
||||
limit: 15,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader className="flex flex-col items-start justify-between mb-6">
|
||||
<PageTitle className="mb-2">
|
||||
Database Migration
|
||||
</PageTitle>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Import backups from a source project into your target database
|
||||
</p>
|
||||
</PageHeader>
|
||||
<PageContent>
|
||||
<MigrationTool projects={projects}/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -6,16 +6,15 @@ import {
|
||||
import {CardsWithPagination} from "@/components/wrappers/common/cards-with-pagination";
|
||||
import {ProjectDatabaseCard} from "@/components/wrappers/dashboard/projects/project-card/project-database-card";
|
||||
import {notFound, redirect} from "next/navigation";
|
||||
|
||||
import {db} from "@/db";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {getActiveMember, getOrganization} from "@/lib/auth/auth";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {capitalizeFirstLetter} from "@/utils/text";
|
||||
import {ProjectDialog} from "@/features/projects/components/project.dialog";
|
||||
import {DatabaseWith} from "@/db/schema/07_database";
|
||||
import {ProjectWith} from "@/db/schema/06_project";
|
||||
import {isUuidv4} from "@/utils/verify-uuid";
|
||||
import {getOrganizationAvailableDatabases} from "@/db/services/database";
|
||||
|
||||
|
||||
export default async function RoutePage(props: PageParams<{
|
||||
@@ -56,19 +55,7 @@ export default async function RoutePage(props: PageParams<{
|
||||
redirect("/dashboard/projects");
|
||||
}
|
||||
|
||||
const availableDatabases = (
|
||||
await db.query.database.findMany({
|
||||
where: (db, {or, eq, isNull}) => or(isNull(db.projectId), eq(db.projectId, proj.id)),
|
||||
with: {
|
||||
agent: true,
|
||||
project: true,
|
||||
backups: true,
|
||||
restorations: true,
|
||||
},
|
||||
orderBy: (db, {desc}) => [desc(db.createdAt)],
|
||||
})
|
||||
) as DatabaseWith[];
|
||||
|
||||
const availableDatabases = await getOrganizationAvailableDatabases(organization.id, proj.id)
|
||||
const isMember = activeMember?.role === "member";
|
||||
|
||||
return (
|
||||
@@ -102,8 +89,9 @@ export default async function RoutePage(props: PageParams<{
|
||||
organizationSlug={organization.slug}
|
||||
// @ts-ignore
|
||||
cardItem={ProjectDatabaseCard}
|
||||
cardsPerPage={6}
|
||||
cardsPerPage={20}
|
||||
numberOfColumns={3}
|
||||
pageSizeOptions={[10, 20, 50]}
|
||||
extendedProps={proj}
|
||||
/>
|
||||
) : (
|
||||
|
||||
@@ -9,6 +9,7 @@ import {EmptyStatePlaceholder} from "@/components/wrappers/common/empty-state-pl
|
||||
import {Metadata} from "next";
|
||||
import {ProjectDialog} from "@/features/projects/components/project.dialog";
|
||||
import {DatabaseWith} from "@/db/schema/07_database";
|
||||
import {getOrganizationAvailableDatabases} from "@/db/services/database";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Projects",
|
||||
@@ -35,18 +36,7 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
});
|
||||
const isMember = activeMember?.role === "member";
|
||||
|
||||
const availableDatabases = (
|
||||
await db.query.database.findMany({
|
||||
where: (db, {isNull}) => isNull(db.projectId),
|
||||
with: {
|
||||
agent: true,
|
||||
project: true,
|
||||
backups: true,
|
||||
restorations: true,
|
||||
},
|
||||
orderBy: (db, {desc}) => [desc(db.createdAt)],
|
||||
})
|
||||
).filter((db) => db.project == null) as DatabaseWith[];
|
||||
const availableDatabases = await getOrganizationAvailableDatabases(organization.id)
|
||||
|
||||
|
||||
return (
|
||||
@@ -66,11 +56,12 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
organizationSlug={organization.slug}
|
||||
data={projects}
|
||||
cardItem={ProjectCard}
|
||||
cardsPerPage={9}
|
||||
cardsPerPage={12}
|
||||
numberOfColumns={3}
|
||||
pageSizeOptions={[12, 24, 48]}
|
||||
/>
|
||||
) : isMember ? (
|
||||
<EmptyStatePlaceholder text="No project available"/>
|
||||
<EmptyStatePlaceholder state={"empty"} text="No project available"/>
|
||||
) : (
|
||||
<ProjectDialog databases={availableDatabases} organization={organization} isEmpty={true}/>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
import {PageParams} from "@/types/next";
|
||||
import {
|
||||
Page,
|
||||
PageContent,
|
||||
PageDescription,
|
||||
PageTitle,
|
||||
} from "@/features/layout/page";
|
||||
import {db} from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {notFound} from "next/navigation";
|
||||
import {ButtonDeleteAgent} from "@/components/wrappers/dashboard/agent/button-delete-agent/button-delete-agent";
|
||||
import {capitalizeFirstLetter} from "@/utils/text";
|
||||
import {generateEdgeKey} from "@/utils/edge_key";
|
||||
import {getServerUrl} from "@/utils/get-server-url";
|
||||
import {AgentContentPage} from "@/components/wrappers/dashboard/agent/agent-content";
|
||||
import {AgentDialog} from "@/features/agents/components/agent.dialog";
|
||||
import {getActiveMember, getOrganization} from "@/lib/auth/auth";
|
||||
import {currentUser} from "@/lib/auth/current-user";
|
||||
import {computeOrganizationPermissions} from "@/lib/acl/organization-acl";
|
||||
|
||||
|
||||
export default async function RoutePage(
|
||||
props: PageParams<{ agentId: string }>,
|
||||
) {
|
||||
const {agentId} = await props.params;
|
||||
|
||||
const organization = await getOrganization({});
|
||||
const user = await currentUser();
|
||||
const activeMember = await getActiveMember();
|
||||
|
||||
if (!organization || !activeMember || !user) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
|
||||
|
||||
const {canManageAgents} = computeOrganizationPermissions(activeMember);
|
||||
|
||||
if (!canManageAgents){
|
||||
notFound();
|
||||
}
|
||||
|
||||
const agent = await db.query.agent.findFirst({
|
||||
where: eq(drizzleDb.schemas.agent.id, agentId),
|
||||
with: {
|
||||
databases: true,
|
||||
organizations: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
if (!agent) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const hasAccess =
|
||||
agent.organizationId === organization.id ||
|
||||
agent.organizations.some(org => org.organizationId === organization.id);
|
||||
|
||||
if (!hasAccess) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const isOwned = agent.organizationId
|
||||
const edgeKey = await generateEdgeKey(getServerUrl(), agent.id);
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<div className="justify-between gap-2 sm:flex">
|
||||
<PageTitle className="flex flex-col md:flex-row items-center justify-between w-full ">
|
||||
<div className="min-w-full md:min-w-fit ">
|
||||
{capitalizeFirstLetter(agent.name)}
|
||||
</div>
|
||||
{isOwned && (
|
||||
<div className="flex items-center gap-2 md:justify-between w-full ">
|
||||
<div className="flex items-center gap-2">
|
||||
<AgentDialog
|
||||
agent={agent}
|
||||
typeTrigger={"edit"}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<ButtonDeleteAgent organizationId={organization.id ?? null} agentId={agentId} text={"Delete Agent"}/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</PageTitle>
|
||||
</div>
|
||||
|
||||
{agent.description && (
|
||||
<PageDescription className="mt-5 sm:mt-0">
|
||||
{agent.description}
|
||||
</PageDescription>
|
||||
)}
|
||||
<PageContent className="flex flex-col w-full h-full justify-between gap-6">
|
||||
<AgentContentPage agent={agent} edgeKey={edgeKey}/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function RoutePage() {
|
||||
redirect("/dashboard/settings?tab=agents");
|
||||
}
|
||||
@@ -1,95 +1,114 @@
|
||||
import { PageParams } from "@/types/next";
|
||||
import {PageParams} from "@/types/next";
|
||||
import {
|
||||
Page,
|
||||
PageActions,
|
||||
PageContent,
|
||||
PageHeader,
|
||||
PageTitle,
|
||||
Page,
|
||||
PageContent,
|
||||
PageHeader,
|
||||
PageTitle,
|
||||
} from "@/features/layout/page";
|
||||
import { currentUser } from "@/lib/auth/current-user";
|
||||
import { getActiveMember, getOrganization } from "@/lib/auth/auth";
|
||||
import { notFound } from "next/navigation";
|
||||
import { Metadata } from "next";
|
||||
import { OrganizationTabs } from "@/components/wrappers/dashboard/organization/tabs/organization-tabs";
|
||||
import { getOrganizationChannels } from "@/db/services/notification-channel";
|
||||
import { computeOrganizationPermissions } from "@/lib/acl/organization-acl";
|
||||
import { getOrganizationStorageChannels } from "@/db/services/storage-channel";
|
||||
import { DeleteOrganizationButton } from "@/components/wrappers/dashboard/organization/delete-organization-button";
|
||||
import { EditOrganizationDialog } from "@/features/organization/components/edit-organization.dialog";
|
||||
import { db } from "@/db";
|
||||
import { isNull } from "drizzle-orm";
|
||||
import {currentUser} from "@/lib/auth/current-user";
|
||||
import {getActiveMember, getOrganization} from "@/lib/auth/auth";
|
||||
import {notFound} from "next/navigation";
|
||||
import {Metadata} from "next";
|
||||
import {OrganizationTabs} from "@/components/wrappers/dashboard/organization/tabs/organization-tabs";
|
||||
import {getOrganizationChannels} from "@/db/services/notification-channel";
|
||||
import {computeOrganizationPermissions} from "@/lib/acl/organization-acl";
|
||||
import {getOrganizationStorageChannels} from "@/db/services/storage-channel";
|
||||
import {DeleteOrganizationButton} from "@/components/wrappers/dashboard/organization/delete-organization-button";
|
||||
import {EditOrganizationDialog} from "@/features/organization/components/edit-organization.dialog";
|
||||
import {db} from "@/db";
|
||||
import {isNull} from "drizzle-orm";
|
||||
import * as drizzleDb from "@/db";
|
||||
import { eq } from "drizzle-orm";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {getOrganizationAgents} from "@/db/services/agent";
|
||||
import {Tooltip, TooltipContent, TooltipTrigger} from "@/components/ui/tooltip";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Settings",
|
||||
title: "Settings",
|
||||
};
|
||||
|
||||
export default async function RoutePage(props: PageParams<{ slug: string }>) {
|
||||
const organization = await getOrganization({});
|
||||
const user = await currentUser();
|
||||
const activeMember = await getActiveMember();
|
||||
const organization = await getOrganization({});
|
||||
const user = await currentUser();
|
||||
const activeMember = await getActiveMember();
|
||||
|
||||
if (!organization || !activeMember || !user) {
|
||||
notFound();
|
||||
}
|
||||
if (!organization || !activeMember || !user) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
const notificationChannels = await getOrganizationChannels(organization.id);
|
||||
const storageChannels = await getOrganizationStorageChannels(organization.id);
|
||||
const permissions = computeOrganizationPermissions(activeMember);
|
||||
const notificationChannels = await getOrganizationChannels(organization.id);
|
||||
const storageChannels = await getOrganizationStorageChannels(organization.id);
|
||||
const agents = await getOrganizationAgents(organization.id);
|
||||
const permissions = computeOrganizationPermissions(activeMember);
|
||||
|
||||
const users = await db.query.user.findMany({
|
||||
where: (fields) => isNull(fields.deletedAt),
|
||||
});
|
||||
const users = await db.query.user.findMany({
|
||||
where: (fields) => isNull(fields.deletedAt),
|
||||
});
|
||||
|
||||
const organizationWithMembers = await db.query.organization.findFirst({
|
||||
where: eq(drizzleDb.schemas.organization.id, organization.id),
|
||||
with: {
|
||||
members: {
|
||||
const organizationWithMembers = await db.query.organization.findFirst({
|
||||
where: eq(drizzleDb.schemas.organization.id, organization.id),
|
||||
with: {
|
||||
user: true,
|
||||
projects: true,
|
||||
members: {
|
||||
with: {
|
||||
user: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
if (!organizationWithMembers) notFound();
|
||||
if (!organizationWithMembers) notFound();
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader>
|
||||
<PageTitle className="flex flex-col md:flex-row items-center justify-between w-full ">
|
||||
<div className="min-w-full md:min-w-fit ">Organization settings</div>
|
||||
<div className="flex items-center gap-2 md:justify-between w-full ">
|
||||
<div className="flex items-center gap-2">
|
||||
{permissions.canManageSettings &&
|
||||
organization.slug !== "default" && (
|
||||
<EditOrganizationDialog
|
||||
organization={organizationWithMembers}
|
||||
users={users}
|
||||
currentUser={user}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{permissions.canManageDangerZone &&
|
||||
organization.slug !== "default" && (
|
||||
<DeleteOrganizationButton
|
||||
organizationSlug={organization.slug}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</PageTitle>
|
||||
</PageHeader>
|
||||
<PageContent>
|
||||
<OrganizationTabs
|
||||
activeMember={activeMember}
|
||||
organization={organization}
|
||||
notificationChannels={notificationChannels}
|
||||
storageChannels={storageChannels}
|
||||
/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
);
|
||||
return (
|
||||
<Page>
|
||||
<PageHeader>
|
||||
<PageTitle className="flex flex-col md:flex-row items-center justify-between w-full ">
|
||||
<div className="min-w-full md:min-w-fit ">Organization settings</div>
|
||||
<div className="flex items-center gap-2 md:justify-between w-full ">
|
||||
<div className="flex items-center gap-2">
|
||||
{permissions.canManageSettings &&
|
||||
organization.slug !== "default" && (
|
||||
<EditOrganizationDialog
|
||||
organization={organizationWithMembers}
|
||||
users={users}
|
||||
currentUser={user}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{permissions.canManageDangerZone &&
|
||||
organization.slug !== "default" && (
|
||||
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div>
|
||||
<DeleteOrganizationButton
|
||||
disabled={organizationWithMembers.projects.length > 0}
|
||||
organizationSlug={organization.slug}
|
||||
/>
|
||||
</div>
|
||||
|
||||
</TooltipTrigger>
|
||||
{organizationWithMembers.projects.length > 0 && (
|
||||
<TooltipContent>
|
||||
<p>Your organization has some projects associated with it. Please delete them before deleting the organization.</p>
|
||||
</TooltipContent>
|
||||
)}
|
||||
</Tooltip>
|
||||
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</PageTitle>
|
||||
</PageHeader>
|
||||
<PageContent>
|
||||
<OrganizationTabs
|
||||
activeMember={activeMember}
|
||||
organization={organization}
|
||||
notificationChannels={notificationChannels}
|
||||
storageChannels={storageChannels}
|
||||
agents={agents}
|
||||
/>
|
||||
</PageContent>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import {Building2, Database, DatabaseBackup, Folder, RefreshCcw, Server, Workflo
|
||||
import {currentUser} from "@/lib/auth/current-user";
|
||||
import {notFound} from "next/navigation";
|
||||
import {db} from "@/db";
|
||||
import {asc, inArray} from "drizzle-orm";
|
||||
import {and, asc, eq, inArray} from "drizzle-orm";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {listOrganizations} from "@/lib/auth/auth";
|
||||
import {Metadata} from "next";
|
||||
@@ -26,7 +26,7 @@ export default async function RoutePage(props: PageParams<{}>) {
|
||||
const agents = await db.query.agent.findMany({});
|
||||
|
||||
const projects = await db.query.project.findMany({
|
||||
where: inArray(drizzleDb.schemas.project.organizationId, organizationIds),
|
||||
where: and(inArray(drizzleDb.schemas.project.organizationId, organizationIds), eq(drizzleDb.schemas.project.isArchived, false)),
|
||||
});
|
||||
|
||||
const projectIds = projects.map(project => project.id);
|
||||
|
||||
@@ -9,8 +9,4 @@ export default async function Index() {
|
||||
redirect(`/dashboard/home`);
|
||||
}
|
||||
redirect("/login");
|
||||
//Do not delete
|
||||
// return (
|
||||
// <Home/>
|
||||
// );
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {NextResponse} from "next/server";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {and, eq} from "drizzle-orm";
|
||||
import {db} from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {logger} from "@/lib/logger";
|
||||
@@ -12,7 +12,7 @@ export function withAgentCheck(handler: Function) {
|
||||
const agentId = (await context.params).agentId;
|
||||
|
||||
const agent = await db.query.agent.findFirst({
|
||||
where: eq(drizzleDb.schemas.agent.id, agentId),
|
||||
where: and(eq(drizzleDb.schemas.agent.id, agentId), eq(drizzleDb.schemas.agent.isArchived, false)),
|
||||
});
|
||||
|
||||
if (!agent) {
|
||||
|
||||
@@ -70,10 +70,10 @@ export const PATCH = withAgentCheck(async (request: Request, {params, agent}: {
|
||||
if (hasSuccessfulStorage && backup.status !== "success") {
|
||||
await db
|
||||
.update(drizzleDb.schemas.backup)
|
||||
.set({
|
||||
.set(withUpdatedAt({
|
||||
status: "success",
|
||||
fileSize: fileSize,
|
||||
})
|
||||
}))
|
||||
.where(eq(drizzleDb.schemas.backup.id, backup.id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {db} from "@/db";
|
||||
import {and, eq} from "drizzle-orm";
|
||||
import {sendNotificationsBackupRestore} from "@/features/notifications/helpers";
|
||||
import {logger} from "@/lib/logger";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
|
||||
const log = logger.child({module: "api/agent/restore"});
|
||||
|
||||
@@ -34,7 +35,7 @@ export async function POST(
|
||||
}
|
||||
|
||||
const agent = await db.query.agent.findFirst({
|
||||
where: eq(drizzleDb.schemas.agent.id, agentId)
|
||||
where: and(eq(drizzleDb.schemas.agent.id, agentId), eq(drizzleDb.schemas.agent.isArchived, false)),
|
||||
})
|
||||
if (!agent) {
|
||||
return NextResponse.json({error: "Agent not found"}, {status: 404})
|
||||
@@ -62,7 +63,7 @@ export async function POST(
|
||||
|
||||
await db
|
||||
.update(drizzleDb.schemas.restoration)
|
||||
.set({status: body.status as RestorationStatus})
|
||||
.set(withUpdatedAt({status: body.status as RestorationStatus}))
|
||||
.where(eq(drizzleDb.schemas.restoration.id, restoration.id));
|
||||
|
||||
await sendNotificationsBackupRestore(database, body.status == "failed" ? "error_restore" : "success_restore");
|
||||
|
||||
@@ -183,7 +183,7 @@ export async function handleDatabases(body: Body, agent: Agent, lastContact: Dat
|
||||
} else {
|
||||
await dbClient
|
||||
.update(drizzleDb.schemas.restoration)
|
||||
.set({status: "failed"})
|
||||
.set(withUpdatedAt({status: "failed"}))
|
||||
.where(eq(drizzleDb.schemas.restoration.id, restoration.id));
|
||||
|
||||
const errorMessage = "Failed to get backup URL";
|
||||
@@ -194,14 +194,14 @@ export async function handleDatabases(body: Body, agent: Agent, lastContact: Dat
|
||||
log.error({error: err, name: "handleDatabases"}, "Restoration crashed unexpectedly");
|
||||
await dbClient
|
||||
.update(drizzleDb.schemas.restoration)
|
||||
.set({status: "failed"})
|
||||
.set(withUpdatedAt({status: "failed"}))
|
||||
.where(eq(drizzleDb.schemas.restoration.id, restoration.id));
|
||||
continue;
|
||||
}
|
||||
|
||||
await dbClient
|
||||
.update(drizzleDb.schemas.restoration)
|
||||
.set({status: "ongoing"})
|
||||
.set(withUpdatedAt({status: "ongoing"}))
|
||||
.where(eq(drizzleDb.schemas.restoration.id, restoration.id));
|
||||
}
|
||||
const storages = await getDatabaseStorageChannels(databaseUpdated.id)
|
||||
|
||||
@@ -3,7 +3,7 @@ import {handleDatabases} from "./helpers";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {db} from "@/db";
|
||||
import {EDbmsSchema} from "@/db/schema/types";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {and, eq} from "drizzle-orm";
|
||||
import {isUuidv4} from "@/utils/verify-uuid";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
import {logger} from "@/lib/logger";
|
||||
@@ -31,7 +31,7 @@ export async function POST(
|
||||
) {
|
||||
try {
|
||||
const agentId = (await params).agentId
|
||||
log.info(`Agent ID: ${agentId}`)
|
||||
log.debug(`Agent ID: ${agentId}`)
|
||||
const body: Body = await request.json();
|
||||
const lastContact = new Date();
|
||||
let message: string
|
||||
@@ -46,7 +46,7 @@ export async function POST(
|
||||
}
|
||||
|
||||
const agent = await db.query.agent.findFirst({
|
||||
where: eq(drizzleDb.schemas.agent.id, agentId),
|
||||
where: and(eq(drizzleDb.schemas.agent.id, agentId), eq(drizzleDb.schemas.agent.isArchived, false)),
|
||||
})
|
||||
|
||||
if (!agent) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/dockerfile/Dockerfile
|
||||
target: prod
|
||||
ports:
|
||||
- '8887:80'
|
||||
environment:
|
||||
TZ: "Europe/Paris"
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- portabase-e2e-data:/data
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
|
||||
db:
|
||||
image: postgres:18-alpine
|
||||
ports:
|
||||
- "5433:5432"
|
||||
volumes:
|
||||
- postgres-e2e-data:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_DB=devdb
|
||||
- POSTGRES_USER=devuser
|
||||
- POSTGRES_PASSWORD=changeme
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U devuser -d devdb"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
volumes:
|
||||
portabase-e2e-data:
|
||||
postgres-e2e-data:
|
||||
+10
-1
@@ -12,7 +12,7 @@ services:
|
||||
- POSTGRES_USER=devuser
|
||||
- POSTGRES_PASSWORD=changeme
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U devuser -d devdb"]
|
||||
test: [ "CMD-SHELL", "pg_isready -U devuser -d devdb" ]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
@@ -32,5 +32,14 @@ services:
|
||||
- ./private/uploads/tmp:/data/uploads/tmp
|
||||
user: "1000:1000"
|
||||
|
||||
mailpit:
|
||||
image: axllent/mailpit:latest
|
||||
container_name: portabase-mailpit-dev
|
||||
hostname: mailpit
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8025:8025"
|
||||
- "1025:1025"
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {users} from "./helpers/auth";
|
||||
import {changeUserRole, create, switchToDefault} from "./helpers/access-management";
|
||||
import {LOCAL_STORAGE_PATH} from "./helpers/session";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const firstOrganization = "Organization A";
|
||||
const secondOrganization = "Organization B";
|
||||
|
||||
test.describe.serial(() => {
|
||||
test("Create an organization from organizations page", async ({page}) => {
|
||||
await page.goto("/dashboard/admin/organizations");
|
||||
await expect(page.getByRole("heading", {name: "Active organizations"})).toBeVisible();
|
||||
|
||||
await create(page, "button", firstOrganization);
|
||||
|
||||
await expect(page.getByText(/Organization has been successfully created\./i)).toBeVisible();
|
||||
await expect(page).toHaveURL("/dashboard/admin/organizations");
|
||||
await expect(page.getByRole("button", {name: firstOrganization, exact: true})).toBeVisible();
|
||||
|
||||
await switchToDefault(page);
|
||||
});
|
||||
|
||||
test("Create an organization from sidebar button", async ({page}) => {
|
||||
await page.goto("/dashboard/home");
|
||||
await expect(page.getByRole("heading", {name: "Dashboard"})).toBeVisible();
|
||||
|
||||
await create(page, "sidebar", secondOrganization);
|
||||
|
||||
await expect(page.getByText(/Organization has been successfully created\./i)).toBeVisible();
|
||||
await expect(page).toHaveURL("/dashboard/home");
|
||||
await expect(page.getByRole("button", {name: secondOrganization, exact: true})).toBeVisible();
|
||||
|
||||
await switchToDefault(page);
|
||||
});
|
||||
|
||||
test("Change John Doe's role from pending to user", async ({page}) => {
|
||||
await page.goto("/dashboard/admin/users");
|
||||
await expect(page.getByText(users.normal.email, {exact: true})).toBeVisible();
|
||||
|
||||
const userRow = page.locator("tr").filter({hasText: users.normal.email}).first();
|
||||
await expect(userRow).toBeVisible();
|
||||
await userRow.locator("button").last().click();
|
||||
await page.getByRole('menuitem', {name: 'Role'}).click();
|
||||
|
||||
await expect(page.getByRole("heading", {name: "Change the user's role"})).toBeVisible();
|
||||
|
||||
await changeUserRole(page, "user")
|
||||
|
||||
await expect(page.getByText("User role changed successfully.")).toBeVisible();
|
||||
await expect(page.locator("tr").filter({hasText: users.normal.email}).getByText("user", {exact: true})).toBeVisible();
|
||||
});
|
||||
|
||||
test("Add John Doe to Organization A", async ({page}) => {
|
||||
await page.goto("/dashboard/admin/organizations");
|
||||
await expect(page.getByRole("heading", {name: "Active organizations"})).toBeVisible();
|
||||
|
||||
const organizationRow = page.locator("tr").filter({hasText: firstOrganization}).first();
|
||||
await expect(organizationRow).toBeVisible();
|
||||
await organizationRow.locator('a[href*="/dashboard/admin/organizations/"], a[href*="organizations/"]').click();
|
||||
|
||||
await expect(page.getByText(firstOrganization, {exact: true})).toBeVisible();
|
||||
await page.getByRole("button", {name: /Add member/i}).click();
|
||||
await expect(page.getByRole("heading", {name: "Add member to your organization"})).toBeVisible();
|
||||
|
||||
await page.getByPlaceholder("Enter a user email").fill(users.normal.email);
|
||||
await page.getByRole("option", {name: new RegExp(users.normal.email, "i")}).click();
|
||||
await page.getByRole("button", {name: "Confirm"}).click();
|
||||
|
||||
await expect(page.getByText("Member successfully added!")).toBeVisible();
|
||||
await expect(page.getByText(users.normal.email, {exact: true})).toBeVisible();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,116 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {execSync} from "child_process";
|
||||
import fs from "fs";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
import {createAgentWithDockerDatabases} from "./helpers/agent-cli";
|
||||
import {create, edit, get, remove} from "./helpers/agent";
|
||||
import {LOCAL_STORAGE_PATH} from "./helpers/session";
|
||||
|
||||
const agent = {
|
||||
aName: "Agent A",
|
||||
aUpdatedName: "Agent A Updated",
|
||||
bName: "Agent B",
|
||||
description: "Agent created by Playwright E2E",
|
||||
updatedDescription: "Agent updated by Playwright E2E",
|
||||
};
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
test.describe.serial(() => {
|
||||
let agentWorkspace: string | null = null;
|
||||
|
||||
test("Create agent A from empty state", async ({page}) => {
|
||||
await page.goto("/dashboard/agents");
|
||||
await expect(page.getByRole("heading", {name: "Agents"})).toBeVisible();
|
||||
await expect(page.getByText("Create new Agent", {exact: true})).toBeVisible();
|
||||
await create(page, "emptyState", agent.aName, agent.description);
|
||||
|
||||
await expect(page.getByText("Success creating agent")).toBeVisible();
|
||||
await expect(get(page, agent.aName)).toBeVisible();
|
||||
await expect(page.getByText("Create new Agent", {exact: true})).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("Edit agent A", async ({page}) => {
|
||||
await page.goto("/dashboard/agents");
|
||||
await expect(page.getByRole("heading", {name: "Agents"})).toBeVisible();
|
||||
await expect(get(page, agent.aName)).toBeVisible();
|
||||
|
||||
await edit(page, agent.aName, agent.aUpdatedName, agent.updatedDescription);
|
||||
|
||||
await expect(page.getByText("Success updating agent")).toBeVisible();
|
||||
await expect(page.getByText(agent.aUpdatedName, {exact: true})).toBeVisible();
|
||||
await expect(page.getByText(agent.updatedDescription, {exact: true})).toBeVisible();
|
||||
});
|
||||
|
||||
test("Create agent B from classic button", async ({page}) => {
|
||||
await page.goto("/dashboard/agents");
|
||||
await expect(page.getByRole("heading", {name: "Agents"})).toBeVisible();
|
||||
await expect(page.getByRole("button", {name: /Create Agent/i})).toBeVisible();
|
||||
await create(page, "button", agent.bName, agent.description);
|
||||
|
||||
await expect(page.getByText("Success creating agent")).toBeVisible();
|
||||
await expect(get(page, agent.bName)).toBeVisible();
|
||||
});
|
||||
|
||||
test("Delete Agent B", async ({page}) => {
|
||||
await page.goto("/dashboard/agents");
|
||||
await expect(page.getByRole("heading", {name: "Agents"})).toBeVisible();
|
||||
await expect(get(page, agent.bName)).toBeVisible();
|
||||
await remove(page, agent.bName);
|
||||
|
||||
await expect(page.getByText("Agent has been successfully deleted.")).toBeVisible();
|
||||
await expect(page).toHaveURL("/dashboard/agents");
|
||||
await expect(page.getByText(agent.bName)).toHaveCount(0);
|
||||
});
|
||||
|
||||
// test("Launch the updated agent", async ({page}) => {
|
||||
// await page.goto("/dashboard/agents");
|
||||
// await expect(page.getByRole("heading", {name: "Agents"})).toBeVisible();
|
||||
// await get(page, agent.aName).click();
|
||||
//
|
||||
// await expect(page).toHaveURL(/\/dashboard\/agents\/.+/);
|
||||
// await expect(page.getByText(agent.aName, {exact: true})).toBeVisible();
|
||||
// await expect(page.getByText("Registration & Setup")).toBeVisible();
|
||||
//
|
||||
// const commandInput = page.locator("input[readonly]").first();
|
||||
// await page.locator("input[readonly]").first().locator("xpath=following-sibling::button[1]").click();
|
||||
// const command = await commandInput.inputValue();
|
||||
//
|
||||
// agentWorkspace = fs.mkdtempSync(path.join(os.tmpdir(), "portabase-agent-"));
|
||||
// await createAgentWithDockerDatabases(command, agentWorkspace);
|
||||
// execSync(`portabase start "${agent.aName}"`, {
|
||||
// cwd: agentWorkspace,
|
||||
// stdio: "pipe",
|
||||
// timeout: 120_000,
|
||||
// });
|
||||
//
|
||||
// await expect(page.getByText("Never connected.")).toHaveCount(0, {timeout: 120_000});
|
||||
// await expect(page.getByText("Action Required")).toHaveCount(0);
|
||||
// });
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (agentWorkspace) {
|
||||
try {
|
||||
execSync(`portabase stop "${agent.aName}"`, {
|
||||
cwd: agentWorkspace,
|
||||
stdio: "pipe",
|
||||
timeout: 30_000,
|
||||
});
|
||||
} catch {
|
||||
}
|
||||
|
||||
try {
|
||||
execSync(`portabase uninstall --force "${agent.aName}"`, {
|
||||
cwd: agentWorkspace,
|
||||
stdio: "pipe",
|
||||
timeout: 30_000,
|
||||
});
|
||||
} catch {
|
||||
}
|
||||
|
||||
fs.rmSync(agentWorkspace, {recursive: true, force: true});
|
||||
agentWorkspace = null;
|
||||
}
|
||||
});
|
||||
});
|
||||
+14
-45
@@ -1,43 +1,17 @@
|
||||
import {test, expect, Page} from '@playwright/test';
|
||||
import {test, expect} from '@playwright/test';
|
||||
import {login, register, users} from "./helpers/auth";
|
||||
import {LOCAL_STORAGE_PATH} from "./helpers/session";
|
||||
|
||||
const TIMEOUT = undefined
|
||||
// const TIMEOUT = 5000
|
||||
|
||||
type UserCredentials = {
|
||||
username: string
|
||||
email: string
|
||||
password: string
|
||||
}
|
||||
test.use({storageState: LOCAL_STORAGE_PATH})
|
||||
|
||||
|
||||
const users: Record<string, UserCredentials> = {
|
||||
admin: {username: 'Admin', email: 'admin@example.com', password: 'testPASS123456!'},
|
||||
normal: {username: 'John Doe', email: 'john.doe@example.com', password: 'testPASS123456!'},
|
||||
}
|
||||
|
||||
async function register(page: Page, name: string, email: string, password: string, confirmPassword: string) {
|
||||
await page.locator('input[name="name"]').fill(name)
|
||||
await page.locator('input[name="email"]').fill(email)
|
||||
await page.locator('input[name="password"]').fill(password)
|
||||
await page.locator('input[name="confirmPassword"]').fill(confirmPassword)
|
||||
|
||||
await page.click('button[type="submit"]')
|
||||
}
|
||||
|
||||
async function login(page: Page, email: string, password: string) {
|
||||
await page.locator('input[name="email"]').fill(email)
|
||||
await page.locator('input[name="password"]').fill(password)
|
||||
|
||||
await page.locator('button:has-text("Login")').click()
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
//TODO
|
||||
}
|
||||
|
||||
test.describe.serial('User signup and login flows', () => {
|
||||
test.describe.serial( () => {
|
||||
|
||||
test('Redirect to login if not connected', async ({page}) => {
|
||||
await page.goto('/dashboard/projects');
|
||||
await expect(page).toHaveURL("login?redirect=%2Fdashboard%2Fprojects");
|
||||
await expect(page).toHaveURL("login?redirect=%2Fdashboard%2Fprojects", {timeout: TIMEOUT});
|
||||
});
|
||||
|
||||
test('Password too short', async ({page}) => {
|
||||
@@ -85,7 +59,7 @@ test.describe.serial('User signup and login flows', () => {
|
||||
|
||||
await register(page, users["admin"].username, users["admin"].email, users["admin"].password, users["admin"].password)
|
||||
|
||||
await expect(page).toHaveURL('/login')
|
||||
await expect(page).toHaveURL('/login', {timeout: TIMEOUT})
|
||||
})
|
||||
|
||||
test('User already exists.', async ({page}) => {
|
||||
@@ -108,7 +82,7 @@ test.describe.serial('User signup and login flows', () => {
|
||||
|
||||
await register(page, users["normal"].username, users["normal"].email, users["normal"].password, users["normal"].password)
|
||||
|
||||
await expect(page).toHaveURL('login')
|
||||
await expect(page).toHaveURL('/login', {timeout: TIMEOUT})
|
||||
})
|
||||
|
||||
test('Failed login because account not active', async ({page}) => {
|
||||
@@ -120,16 +94,11 @@ test.describe.serial('User signup and login flows', () => {
|
||||
})
|
||||
|
||||
test('Successful login', async ({page}) => {
|
||||
await page.goto('login')
|
||||
await page.goto('/login')
|
||||
await login(page, users["admin"].email, users["admin"].password)
|
||||
|
||||
await expect(page).toHaveURL('/dashboard/home')
|
||||
await expect(page).toHaveURL('/dashboard/home', {timeout: TIMEOUT})
|
||||
await expect(page.getByRole('link', {name: 'Logo Portabase'})).toBeVisible()
|
||||
await page.context().storageState({path: LOCAL_STORAGE_PATH})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
// test('Successful logout', async ({page}) => {
|
||||
// await logout()
|
||||
// await expect(page).toHaveURL('/login')
|
||||
// })
|
||||
@@ -0,0 +1,32 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import fs from "fs";
|
||||
import {logout} from "./helpers/auth";
|
||||
import {LOCAL_STORAGE_PATH} from "./helpers/session";
|
||||
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
test.describe( () => {
|
||||
test.afterAll(async () => {
|
||||
if (fs.existsSync(LOCAL_STORAGE_PATH)) {
|
||||
fs.unlinkSync(LOCAL_STORAGE_PATH);
|
||||
}
|
||||
});
|
||||
|
||||
test("Remove shared storage state", async ({page}) => {
|
||||
await test.step("Logout shared authenticated session", async () => {
|
||||
if (!fs.existsSync(LOCAL_STORAGE_PATH)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(LOCAL_STORAGE_PATH, "utf-8").trim();
|
||||
if (!content || content === "{}") {
|
||||
return;
|
||||
}
|
||||
|
||||
await page.goto('/dashboard/home');
|
||||
await logout(page);
|
||||
await expect(page).toHaveURL(/\/login(?:\?.*)?$/);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
import {Page} from "@playwright/test";
|
||||
|
||||
export function getUserRow(page: Page, email: string) {
|
||||
return page.locator("tr").filter({hasText: email}).first();
|
||||
}
|
||||
|
||||
export function getOrganizationRow(page: Page, organizationName: string) {
|
||||
return page.locator("tr").filter({hasText: organizationName}).first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an organization from the selected entrypoint.
|
||||
*
|
||||
* Available entrypoints:
|
||||
* - `button`: the organizations page create button.
|
||||
* - `sidebar`: the sidebar organization switcher.
|
||||
*
|
||||
* Executes from:
|
||||
* - `/dashboard/admin/organizations` for "button" entrypoint
|
||||
* - any `/dashboard/**` page for "sidebar" entrypoint
|
||||
*/
|
||||
export async function create(page: Page, entrypoint: "button" | "sidebar", name: string) {
|
||||
if (entrypoint === "sidebar") {
|
||||
await page.getByRole("button", {name: "Default Organization"}).click();
|
||||
await page.getByText("Create organization", {exact: true}).click();
|
||||
} else {
|
||||
await page.getByRole("button", {name: /Create a new organization/i}).click();
|
||||
}
|
||||
|
||||
await page.getByLabel("Name").fill(name);
|
||||
await page.getByRole("button", {name: "Create"}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch the active organization from the sidebar switcher.
|
||||
*
|
||||
* Executes from: any `/dashboard/**` if the sidebar is visible.
|
||||
*/
|
||||
export async function switchTo(page: Page, name: string) {
|
||||
await page.getByTestId('organization-dropdown').click();
|
||||
await page.getByRole('menuitem', {name: name}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch back to the default organization.
|
||||
*
|
||||
* Executes from: any `/dashboard/**` if the sidebar is visible.
|
||||
*/
|
||||
export async function switchToDefault(page: Page) {
|
||||
await switchTo(page, "Default Organization");
|
||||
}
|
||||
|
||||
const ROLE_LABELS = {
|
||||
pending: "Pending",
|
||||
user: "User",
|
||||
admin: "Admin",
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Change the global role of a user from the admin users role modal.
|
||||
*
|
||||
* Executes from: the "Change the user's role" dialog opened from `/dashboard/admin/users`.
|
||||
*/
|
||||
export async function changeUserRole(page: Page, role: keyof typeof ROLE_LABELS) {
|
||||
const roleOption = ROLE_LABELS[role];
|
||||
|
||||
await page.getByRole("combobox").click();
|
||||
await page.getByRole("option", {name: roleOption}).click();
|
||||
await page.getByRole("button", {name: "Validate"}).click();
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
import * as pty from "node-pty";
|
||||
|
||||
type InteractiveStep = {
|
||||
match: RegExp;
|
||||
reply: string;
|
||||
};
|
||||
|
||||
function normalizeOutput(output: string) {
|
||||
return output.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Run an interactive CLI command and answer prompts in sequence.
|
||||
* Entry point:
|
||||
* - `command` is the full CLI command executed in the PTY.
|
||||
* - `cwd` is the local workspace where the command is launched.
|
||||
* - `steps` defines which prompt text is matched and which reply is sent.
|
||||
* - `timeoutMs` controls when the command is aborted if it stalls.
|
||||
* Executes from: not page-bound; runs from a local test workspace on the Node.js side.
|
||||
*/
|
||||
export async function runInteractiveCommand(
|
||||
command: string,
|
||||
cwd: string,
|
||||
steps: InteractiveStep[],
|
||||
timeoutMs: number = 120_000,
|
||||
) {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const child = pty.spawn("sh", ["-lc", command], {
|
||||
cwd,
|
||||
env: {
|
||||
...process.env,
|
||||
TERM: "xterm-256color",
|
||||
},
|
||||
cols: 120,
|
||||
rows: 30,
|
||||
});
|
||||
|
||||
let currentStep = 0;
|
||||
let output = "";
|
||||
const timer = setTimeout(() => {
|
||||
child.kill();
|
||||
reject(new Error(`Interactive command timed out.\n\nCommand: ${command}\n\nOutput:\n${normalizeOutput(output)}`));
|
||||
}, timeoutMs);
|
||||
|
||||
const handleChunk = (chunk: string) => {
|
||||
output += chunk;
|
||||
const normalizedOutput = normalizeOutput(output);
|
||||
|
||||
while (currentStep < steps.length && steps[currentStep].match.test(normalizedOutput)) {
|
||||
child.write(steps[currentStep].reply);
|
||||
currentStep += 1;
|
||||
}
|
||||
};
|
||||
|
||||
child.onData(handleChunk);
|
||||
child.onExit(({exitCode}) => {
|
||||
clearTimeout(timer);
|
||||
if (exitCode === 0) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
reject(new Error(`Interactive command failed with exit code ${exitCode}.\n\nCommand: ${command}\n\nOutput:\n${normalizeOutput(output)}`));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and configure a Portabase agent with two Docker-backed databases.
|
||||
* Entry point:
|
||||
* - `command` is the CLI setup command copied from the agent details page.
|
||||
* - `cwd` is the local workspace where the agent is installed.
|
||||
* - this helper answers the wizard for PostgreSQL first, then MariaDB.
|
||||
* Executes from: not page-bound; runs from a local test workspace on the Node.js side.
|
||||
*/
|
||||
export async function createAgentWithDockerDatabases(command: string, cwd: string) {
|
||||
await runInteractiveCommand(command, cwd, [
|
||||
{
|
||||
match: /configure.*database|add.*database/i,
|
||||
reply: "y\n",
|
||||
},
|
||||
{
|
||||
match: /docker.*new local container|manual.*external|external.*existing/i,
|
||||
reply: "\r",
|
||||
},
|
||||
{
|
||||
match: /postgresql|mariadb/i,
|
||||
reply: "\r",
|
||||
},
|
||||
{
|
||||
match: /another.*database|add.*another|configure.*another/i,
|
||||
reply: "y\n",
|
||||
},
|
||||
{
|
||||
match: /docker.*new local container|manual.*external|external.*existing/i,
|
||||
reply: "\r",
|
||||
},
|
||||
{
|
||||
match: /postgresql|mariadb/i,
|
||||
reply: "\u001B[B\r",
|
||||
},
|
||||
{
|
||||
match: /another.*database|add.*another|configure.*another/i,
|
||||
reply: "n\n",
|
||||
},
|
||||
]);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import {Page} from "@playwright/test";
|
||||
|
||||
|
||||
/**
|
||||
* Locate an agent card in the list.
|
||||
|
||||
* Executes from: `/dashboard/agents`.
|
||||
*/
|
||||
export function get(page: Page, name: string) {
|
||||
return page.locator('a[href^="/dashboard/agents"]').filter({hasText: name}).first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an agent from the selected entrypoint.
|
||||
*
|
||||
* Available entrypoints:
|
||||
* - `button`: the classic create button.
|
||||
* - `emptyState`: the empty-state CTA.
|
||||
* - `auto`: uses the classic create button and falls back to the empty-state CTA.
|
||||
*
|
||||
* Executes from: `/dashboard/agents`.
|
||||
*/
|
||||
export async function create(page: Page, entrypoint: "auto" | "emptyState" | "button" = "auto", agentName: string, description: string) {
|
||||
if (entrypoint === "auto") {
|
||||
const createButton = page.getByRole("button", {name: /Create Agent/i});
|
||||
if (await createButton.isVisible()) await page.getByRole("button", {name: /Create Agent/i}).click();
|
||||
await page.getByText("Create new Agent", {exact: true}).click();
|
||||
} else if (entrypoint === "button") {
|
||||
await page.getByRole("button", {name: /Create Agent/i}).click();
|
||||
} else if (entrypoint === "emptyState") {
|
||||
await page.getByText("Create new Agent", {exact: true}).click();
|
||||
}
|
||||
|
||||
await page.getByLabel("Name").fill(agentName);
|
||||
await page.getByLabel("Description").fill(description);
|
||||
await page.getByRole("button", {name: "Create"}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an existing agent (name and description) from its details page.
|
||||
*
|
||||
* Executes from: `/dashboard/agents/[agentId]`.
|
||||
*/
|
||||
export async function edit(page: Page, currentName: string, updatedName: string, updatedDescription: string) {
|
||||
await get(page, currentName).click();
|
||||
|
||||
await page
|
||||
.getByRole("button", {name: /Delete Agent/i})
|
||||
.locator("xpath=ancestor::div[1]/preceding-sibling::div[1]/*[1]")
|
||||
.click();
|
||||
|
||||
await page.getByLabel("Name").fill(updatedName);
|
||||
await page.getByLabel("Description").fill(updatedDescription);
|
||||
await page.getByRole("button", {name: "Update"}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an agent from its details page.
|
||||
|
||||
* Executes from: `/dashboard/agents/[agentId]`.
|
||||
*/
|
||||
export async function remove(page: Page, name: string) {
|
||||
await get(page, name).click();
|
||||
await page.getByRole("button", {name: /Delete Agent/i}).click();
|
||||
await page.getByRole("button", {name: "Delete", exact: true}).click();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import {Page} from "@playwright/test";
|
||||
|
||||
export type UserCredentials = {
|
||||
username: string
|
||||
email: string
|
||||
password: string
|
||||
}
|
||||
|
||||
export const users: Record<string, UserCredentials> = {
|
||||
admin: {username: "Admin", email: "admin@example.com", password: "testPASS123456!"},
|
||||
normal: {username: "John Doe", email: "john.doe@example.com", password: "testPASS123456!"},
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill and submit the registration form.
|
||||
*
|
||||
* Executes from: `/register`.
|
||||
*/
|
||||
export async function register(page: Page, name: string, email: string, password: string, confirmPassword: string) {
|
||||
await page.locator('input[name="name"]').fill(name)
|
||||
await page.locator('input[name="email"]').fill(email)
|
||||
await page.locator('input[name="password"]').fill(password)
|
||||
await page.locator('input[name="confirmPassword"]').fill(confirmPassword)
|
||||
|
||||
await page.click('button[type="submit"]')
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill and submit the login form.
|
||||
*
|
||||
* Executes from: `/login`.
|
||||
*/
|
||||
export async function login(page: Page, email: string, password: string) {
|
||||
await page.locator('input[name="email"]').fill(email)
|
||||
await page.locator('input[name="password"]').fill(password)
|
||||
|
||||
await page.locator('button:has-text("Login")').click()
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out the current authenticated user.
|
||||
*
|
||||
* Executes from: any authenticated `/dashboard/**` page.
|
||||
*/
|
||||
export async function logout(page: Page) {
|
||||
const profileButton = page.getByTestId('profile-dropdown')
|
||||
await profileButton.first().click();
|
||||
|
||||
await page.getByRole("menuitem").filter({hasText: /Logout/i}).click();
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
const REQUIRED_E2E_ENV_VARS = [
|
||||
"E2E_NOTIFICATION_SMTP_HOST",
|
||||
"E2E_NOTIFICATION_SMTP_PORT",
|
||||
"E2E_NOTIFICATION_SMTP_USER",
|
||||
"E2E_NOTIFICATION_SMTP_PASSWORD",
|
||||
"E2E_NOTIFICATION_SMTP_FROM",
|
||||
"E2E_NOTIFICATION_SMTP_TO",
|
||||
"E2E_NOTIFICATION_SLACK_WEBHOOK",
|
||||
"E2E_NOTIFICATION_DISCORD_WEBHOOK",
|
||||
"E2E_NOTIFICATION_TELEGRAM_BOT_TOKEN",
|
||||
"E2E_NOTIFICATION_TELEGRAM_CHAT_ID",
|
||||
"E2E_NOTIFICATION_TELEGRAM_TOPIC_ID",
|
||||
"E2E_NOTIFICATION_GOTIFY_SERVER_URL",
|
||||
"E2E_NOTIFICATION_GOTIFY_APP_TOKEN",
|
||||
"E2E_NOTIFICATION_NTFY_TOPIC",
|
||||
"E2E_NOTIFICATION_NTFY_SERVER_URL",
|
||||
"E2E_NOTIFICATION_NTFY_TOKEN",
|
||||
"E2E_NOTIFICATION_NTFY_USERNAME",
|
||||
"E2E_NOTIFICATION_NTFY_PASSWORD",
|
||||
"E2E_NOTIFICATION_WEBHOOK_URL",
|
||||
"E2E_NOTIFICATION_WEBHOOK_SECRET_HEADER",
|
||||
"E2E_NOTIFICATION_WEBHOOK_SECRET",
|
||||
"E2E_STORAGE_AWS_S3_ENDPOINT_URL",
|
||||
"E2E_STORAGE_AWS_S3_REGION",
|
||||
"E2E_STORAGE_AWS_S3_ACCESS_KEY",
|
||||
"E2E_STORAGE_AWS_S3_SECRET_KEY",
|
||||
"E2E_STORAGE_AWS_S3_BUCKET_NAME",
|
||||
"E2E_STORAGE_AWS_S3_PORT",
|
||||
"E2E_STORAGE_R2_ENDPOINT_URL",
|
||||
"E2E_STORAGE_R2_REGION",
|
||||
"E2E_STORAGE_R2_ACCESS_KEY",
|
||||
"E2E_STORAGE_R2_SECRET_KEY",
|
||||
"E2E_STORAGE_R2_BUCKET_NAME",
|
||||
"E2E_STORAGE_R2_PORT",
|
||||
"E2E_STORAGE_GOOGLE_DRIVE_CLIENT_ID",
|
||||
"E2E_STORAGE_GOOGLE_DRIVE_CLIENT_SECRET",
|
||||
"E2E_STORAGE_GOOGLE_DRIVE_FOLDER_ID",
|
||||
] as const;
|
||||
|
||||
function assertRequiredEnvVars() {
|
||||
const missingVars = REQUIRED_E2E_ENV_VARS.filter((name) => {
|
||||
const value = process.env[name]?.trim();
|
||||
return !value;
|
||||
});
|
||||
|
||||
if (missingVars.length > 0) {
|
||||
throw new Error(
|
||||
`Missing required environment variables:\n${missingVars.map((name) => `- ${name}`).join("\n")}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
assertRequiredEnvVars();
|
||||
|
||||
export function getEnv(name: string): string {
|
||||
const value = process.env[name]?.trim();
|
||||
if (!value) {
|
||||
throw new Error(`Missing required environment variable: ${name}`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import {Page} from "@playwright/test";
|
||||
|
||||
|
||||
/**
|
||||
* Locate a notification channel card in the list.
|
||||
*
|
||||
* Executes from: `/dashboard/notifications/channels`.
|
||||
*/
|
||||
export function get(page: Page, channelName: string) {
|
||||
return page.locator('div.block.transition-all.duration-200.rounded-xl', {
|
||||
has: page.locator('h3', {hasText: channelName}),
|
||||
}).first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the edit dialog for an existing notification channel.
|
||||
*
|
||||
* Executes from: `/dashboard/notifications/channels`.
|
||||
*/
|
||||
export async function edit(page: Page, channelName: string) {
|
||||
const card = get(page, channelName);
|
||||
await card.locator("button").nth(1).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing notification channel.
|
||||
*
|
||||
* Executes from: `/dashboard/notifications/channels`.
|
||||
*/
|
||||
export async function remove(page: Page, channelName: string) {
|
||||
const card = get(page, channelName);
|
||||
await card.locator("button").nth(2).click();
|
||||
await page.getByRole("button", {name: "Delete"}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the notification channel creation form.
|
||||
*
|
||||
* Available entrypoints:
|
||||
* - `button`: the classic add button.
|
||||
* - `emptyState`: the empty-state CTA.
|
||||
* - `auto` use the classic add button and falls back to the empty-state CTA.
|
||||
*
|
||||
* Executes from: `/dashboard/notifications/channels`.
|
||||
*/
|
||||
export async function create(
|
||||
page: Page,
|
||||
provider: "Discord" | "Gotify" | "ntfy.sh" | "Slack" | "Email" | "Telegram" | "Webhook",
|
||||
channelName: string,
|
||||
fillConfig: (page: Page) => Promise<void>,
|
||||
entrypoint: "auto" | "emptyState" | "button" = "auto",
|
||||
) {
|
||||
if (entrypoint === "auto") {
|
||||
const addButton = page.getByRole("button", {name: /Add notification channel/i});
|
||||
if (await addButton.isVisible()) await page.getByRole("button", {name: /Add notification channel/i}).click();
|
||||
else await page.getByRole("button", {name: /No notification channels configured yet/i}).click();
|
||||
} else if (entrypoint === "button") {
|
||||
await page.getByRole("button", {name: /Add notification channel/i}).click();
|
||||
} else if (entrypoint === "emptyState") {
|
||||
await page.getByRole("button", {name: /No notification channels configured yet/i}).click();
|
||||
}
|
||||
|
||||
await page.getByText(provider, {exact: true}).click();
|
||||
await page.getByLabel(/Channel Name/).fill(channelName);
|
||||
await fillConfig(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the notification channel creation form.
|
||||
*
|
||||
* Executes from: the add notification channel dialog opened from `/dashboard/notifications/channels`.
|
||||
*/
|
||||
export async function submit(page: Page) {
|
||||
await page.getByRole("button", {name: "Add Channel"}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the edit dialog for a notification channel and trigger the test action.
|
||||
*
|
||||
* Executes from: `/dashboard/notifications/channels`.
|
||||
*/
|
||||
export async function testFromEdit(page: Page, channelName: string) {
|
||||
await edit(page, channelName);
|
||||
await page.getByRole("button", {name: /Test Channel/i}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the current notification channel dialog without saving.
|
||||
*
|
||||
* Executes from: the add or edit notification channel dialog.
|
||||
*/
|
||||
export async function cancel(page: Page) {
|
||||
await page.getByRole("button", {name: "Cancel"}).click();
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import {Page} from "@playwright/test";
|
||||
|
||||
|
||||
/**
|
||||
* Locate a project card in the list.
|
||||
*
|
||||
* Executes from: `/dashboard/projects`.
|
||||
*/
|
||||
export function get(page: Page, projectName: string) {
|
||||
return page.locator('a[href^="/dashboard/projects/"]').filter({hasText: projectName}).first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a project from the selected entrypoint.
|
||||
*
|
||||
* Available entrypoints:
|
||||
* - `emptyState`: the empty-state CTA.
|
||||
* - `button`: the classic create button.
|
||||
*
|
||||
* * Executes from: `/dashboard/projects`.
|
||||
*/
|
||||
export async function create(page: Page, entrypoint: "emptyState" | "button", projectName: string) {
|
||||
if (entrypoint === "emptyState") {
|
||||
await page.getByText("Create new Project", {exact: true}).click();
|
||||
} else {
|
||||
await page.getByRole("button", {name: /Create Project/i}).click();
|
||||
}
|
||||
|
||||
await page.getByLabel("Name").fill(projectName);
|
||||
await page.getByRole("button", {name: "Create"}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an existing project from its details page.
|
||||
*
|
||||
* Executes from: `/dashboard/projects/[projectId]`.
|
||||
*/
|
||||
export async function edit(page: Page, currentName: string, updatedName: string) {
|
||||
await get(page, currentName).click();
|
||||
|
||||
await page
|
||||
.getByRole("button", {name: /Delete Project/i})
|
||||
.locator("xpath=ancestor::div[1]/preceding-sibling::div[1]/*[1]")
|
||||
.click();
|
||||
|
||||
await page.getByLabel("Name").fill(updatedName);
|
||||
await page.getByRole("button", {name: "Update"}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing project from its details page.
|
||||
*
|
||||
* Executes from: `/dashboard/projects/[projectId]`.
|
||||
* */
|
||||
export async function remove(page: Page, projectName: string) {
|
||||
await get(page, projectName).click();
|
||||
await page.getByRole("button", {name: /Delete Project/i}).click();
|
||||
await page.getByRole("button", {name: "Delete", exact: true}).click();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const LOCAL_STORAGE_PATH = "./e2e/local-storage.json";
|
||||
@@ -0,0 +1,103 @@
|
||||
import {Page} from "@playwright/test";
|
||||
|
||||
|
||||
/**
|
||||
* Locate a storage channel card in the channels list.
|
||||
*
|
||||
* Executes from: `/dashboard/storages/channels`.
|
||||
*/
|
||||
export function get(page: Page, channelName: string) {
|
||||
return page.locator('div.block.transition-all.duration-200.rounded-xl', {
|
||||
has: page.locator('h3', {hasText: channelName}),
|
||||
}).first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the storage channel creation form.
|
||||
*
|
||||
* Available entrypoints:
|
||||
* - `button`: the classic add button.
|
||||
* - `emptyState`: the empty-state CTA.
|
||||
* - `auto`: uses the classic add button and falls back to the empty-state CTA.
|
||||
*
|
||||
* Executes from: `/dashboard/storages/channels`.
|
||||
*/
|
||||
export async function create(
|
||||
page: Page,
|
||||
provider: "S3" | "Google Drive",
|
||||
channelName: string,
|
||||
fillConfig: (page: Page) => Promise<void>,
|
||||
entrypoint: "auto" | "emptyState" | "button" = "auto",
|
||||
) {
|
||||
if (entrypoint === "auto") {
|
||||
const addButton = page.getByRole("button", {name: /Add storage channel/i});
|
||||
if (await addButton.isVisible()) await page.getByRole("button", {name: /Add storage channel/i}).click();
|
||||
else await page.getByText("No storage channels configured yet", {exact: true}).click();
|
||||
} else if (entrypoint === "button") {
|
||||
await page.getByRole("button", {name: /Add storage channel/i}).click();
|
||||
} else if (entrypoint === "emptyState") {
|
||||
await page.getByText("No storage channels configured yet", {exact: true}).click();
|
||||
}
|
||||
|
||||
await page.getByText(provider, {exact: true}).click();
|
||||
await page.getByLabel(/Channel Name/).fill(channelName);
|
||||
await fillConfig(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the edit dialog for an existing storage channel.
|
||||
*
|
||||
* Executes from: `/dashboard/storages/channels`.
|
||||
*/
|
||||
export async function edit(page: Page, channelName: string) {
|
||||
const card = get(page, channelName);
|
||||
await card.locator("button").nth(1).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an existing storage channel.
|
||||
*
|
||||
* Executes from: `/dashboard/storages/channels`.
|
||||
*/
|
||||
export async function remove(page: Page, channelName: string) {
|
||||
const card = get(page, channelName);
|
||||
await card.locator("button").nth(2).click();
|
||||
await page.getByRole("button", {name: "Delete"}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the storage connection test in the current dialog.
|
||||
*
|
||||
* Executes from: the add or edit storage channel dialog opened from `/dashboard/storages/channels`.
|
||||
*/
|
||||
export async function testConnection(page: Page) {
|
||||
await page.getByRole("button", {name: /Test Storage/i}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit the storage channel creation form.
|
||||
*
|
||||
* Executes from: the add storage channel dialog opened from `/dashboard/storages/channels`.
|
||||
*/
|
||||
export async function submit(page: Page) {
|
||||
await page.getByRole("button", {name: "Add Channel"}).click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the edit dialog for a storage channel and trigger the test action.
|
||||
*
|
||||
* Executes from: `/dashboard/storages/channels`.
|
||||
*/
|
||||
export async function testFromEdit(page: Page, channelName: string) {
|
||||
await edit(page, channelName);
|
||||
await testConnection(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the current storage channel dialog without saving.
|
||||
*
|
||||
* Executes from: the add or edit storage channel dialog.
|
||||
*/
|
||||
export async function cancel(page: Page) {
|
||||
await page.getByRole("button", {name: "Cancel"}).click();
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {
|
||||
cancel, create, get, remove, submit, testFromEdit,
|
||||
} from "../helpers/notification";
|
||||
import {getEnv} from "../helpers/env";
|
||||
import {LOCAL_STORAGE_PATH} from "../helpers/session";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const validChannelName = "Discord E2E Required";
|
||||
const invalidChannelName = "Discord E2E Invalid";
|
||||
|
||||
// test.describe.serial("Valid channel", () => {
|
||||
// test("Create and test a valid Discord channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await create(page, "Discord", validChannelName, async (page) => {
|
||||
// await page.getByLabel(/Discord Webhook URL/).fill(getEnv("E2E_NOTIFICATION_DISCORD_WEBHOOK"));
|
||||
// });
|
||||
// await expect(page.getByRole("heading", {name: "Add Notification Channel"})).toBeVisible();
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, validChannelName)).toBeVisible();
|
||||
//
|
||||
// await testFromEdit(page, validChannelName);
|
||||
// await expect(page.getByRole("heading", {name: "Edit Notification Channel"})).toBeVisible();
|
||||
// await expect(page.getByText("Sent to Discord")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// await expect(page.getByRole("heading", {name: "Edit Notification Channel"})).toHaveCount(0);
|
||||
// });
|
||||
//
|
||||
// test("Edit and test a valid Discord channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await expect(get(page, validChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, validChannelName);
|
||||
// await expect(page.getByRole("heading", {name: "Edit Notification Channel"})).toBeVisible();
|
||||
// await expect(page.getByText("Sent to Discord")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// await expect(page.getByRole("heading", {name: "Edit Notification Channel"})).toHaveCount(0);
|
||||
// });
|
||||
// });
|
||||
|
||||
test.describe.serial("Invalid channel", () => {
|
||||
test("Create and test invalid Discord channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await create(page, "Discord", invalidChannelName, async (page) => {
|
||||
await page.getByLabel(/Discord Webhook URL/).fill("https://discord.com/api/webhooks/123456789012345678/wrong-discord-webhook-token");
|
||||
});
|
||||
await expect(page.getByRole("heading", {name: "Add Notification Channel"})).toBeVisible();
|
||||
await submit(page);
|
||||
await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
|
||||
await testFromEdit(page, invalidChannelName);
|
||||
await expect(page.getByRole("heading", {name: "Edit Notification Channel"})).toBeVisible();
|
||||
await expect(page.getByText("An error occurred while testing the notification channel, check your configuration")).toBeVisible();
|
||||
await cancel(page);
|
||||
await expect(page.getByRole("heading", {name: "Edit Notification Channel"})).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("Delete invalid Discord channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await remove(page, invalidChannelName);
|
||||
await expect(page.getByText("Notification channel has been successfully removed.")).toBeVisible();
|
||||
await expect(page.getByText(invalidChannelName)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {
|
||||
cancel, create, get, remove, submit, testFromEdit,
|
||||
} from "../helpers/notification";
|
||||
import {getEnv} from "../helpers/env";
|
||||
import {LOCAL_STORAGE_PATH} from "../helpers/session";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const validChannelName = "Gotify E2E Required";
|
||||
const invalidChannelName = "Gotify E2E Invalid";
|
||||
|
||||
// test.describe.serial("Valid channel", () => {
|
||||
// test("Create and test a valid Gotify channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await create(page, "Gotify", validChannelName, async (page) => {
|
||||
// await page.getByLabel(/Gotify Server URL/).fill(getEnv("E2E_NOTIFICATION_GOTIFY_SERVER_URL"));
|
||||
// await page.getByLabel(/Application Token/).fill(getEnv("E2E_NOTIFICATION_GOTIFY_APP_TOKEN"));
|
||||
// });
|
||||
// await expect(page.getByRole("heading", {name: "Add Notification Channel"})).toBeVisible();
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, validChannelName)).toBeVisible();
|
||||
//
|
||||
// await testFromEdit(page, validChannelName);
|
||||
// await expect(page.getByText("Sent to Gotify")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
//
|
||||
// test("Edit and test a valid Gotify channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await expect(get(page, validChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, validChannelName);
|
||||
// await expect(page.getByText("Sent to Gotify")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
// });
|
||||
|
||||
test.describe.serial("Invalid channel", () => {
|
||||
test("Create and test invalid Gotify channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await create(page, "Gotify", invalidChannelName, async (page) => {
|
||||
await page.getByLabel(/Gotify Server URL/).fill(getEnv("E2E_NOTIFICATION_GOTIFY_SERVER_URL"));
|
||||
await page.getByLabel(/Application Token/).fill("wrong-gotify-app-token");
|
||||
});
|
||||
await expect(page.getByRole("heading", {name: "Add Notification Channel"})).toBeVisible();
|
||||
await submit(page);
|
||||
await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await testFromEdit(page, invalidChannelName);
|
||||
await expect(page.getByText("An error occurred while testing the notification channel, check your configuration")).toBeVisible();
|
||||
await cancel(page);
|
||||
});
|
||||
|
||||
test("Delete invalid Gotify channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await remove(page, invalidChannelName);
|
||||
await expect(page.getByText("Notification channel has been successfully removed.")).toBeVisible();
|
||||
await expect(page.getByText(invalidChannelName)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {
|
||||
cancel, create, get, remove, submit, testFromEdit,
|
||||
} from "../helpers/notification";
|
||||
import {getEnv} from "../helpers/env";
|
||||
import {LOCAL_STORAGE_PATH} from "../helpers/session";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const requiredChannelName = "Ntfy E2E Required";
|
||||
const optionalChannelName = "Ntfy E2E Optional";
|
||||
const invalidChannelName = "Ntfy E2E Invalid";
|
||||
|
||||
// test.describe.serial("Valid channels", () => {
|
||||
// test("Create and test a valid Ntfy channel with only required fields", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await create(page, "ntfy.sh", requiredChannelName, async (page) => {
|
||||
// await page.getByLabel(/Topic Name/).fill(getEnv("E2E_NOTIFICATION_NTFY_TOPIC"));
|
||||
// });
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, requiredChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, requiredChannelName);
|
||||
// await expect(page.getByText("Sent to ntfy")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
//
|
||||
// test("Create and test a valid Ntfy channel with optional fields", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await create(page, "ntfy.sh", optionalChannelName, async (page) => {
|
||||
// await page.getByLabel(/Topic Name/).fill(getEnv("E2E_NOTIFICATION_NTFY_TOPIC"));
|
||||
// await page.getByLabel(/^Server URL$/).fill(getEnv("E2E_NOTIFICATION_NTFY_SERVER_URL"));
|
||||
// await page.getByLabel(/^Access Token$/).fill(getEnv("E2E_NOTIFICATION_NTFY_TOKEN"));
|
||||
// await page.getByLabel(/^Basic Auth Username$/).fill(getEnv("E2E_NOTIFICATION_NTFY_USERNAME"));
|
||||
// await page.getByLabel(/^Basic Auth Password$/).fill(getEnv("E2E_NOTIFICATION_NTFY_PASSWORD"));
|
||||
// });
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, optionalChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, optionalChannelName);
|
||||
// await expect(page.getByText("Sent to ntfy")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
// });
|
||||
|
||||
test.describe.serial("Invalid channel", () => {
|
||||
test("Create and test invalid Ntfy channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await create(page, "ntfy.sh", invalidChannelName, async (page) => {
|
||||
await page.getByLabel(/Topic Name/).fill("wrong-ntfy-topic");
|
||||
await page.getByLabel(/^Server URL$/).fill(getEnv("E2E_NOTIFICATION_NTFY_SERVER_URL"));
|
||||
await page.getByLabel(/^Access Token$/).fill("wrong-ntfy-token");
|
||||
});
|
||||
await submit(page);
|
||||
await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await testFromEdit(page, invalidChannelName);
|
||||
await expect(page.getByText("An error occurred while testing the notification channel, check your configuration")).toBeVisible();
|
||||
await cancel(page);
|
||||
});
|
||||
|
||||
test("Delete invalid Ntfy channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await remove(page, invalidChannelName);
|
||||
await expect(page.getByText("Notification channel has been successfully removed.")).toBeVisible();
|
||||
await expect(page.getByText(invalidChannelName)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {
|
||||
cancel, create, get, remove, submit, testFromEdit,
|
||||
} from "../helpers/notification";
|
||||
import {getEnv} from "../helpers/env";
|
||||
import {LOCAL_STORAGE_PATH} from "../helpers/session";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const validChannelName = "Slack E2E Required";
|
||||
const invalidChannelName = "Slack E2E Invalid";
|
||||
|
||||
// test.describe.serial("Valid channel", () => {
|
||||
// test("Create and test a valid Slack channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await create(page, "Slack", validChannelName, async (page) => {
|
||||
// await page.getByLabel(/Slack Webhook URL/).fill(getEnv("E2E_NOTIFICATION_SLACK_WEBHOOK"));
|
||||
// });
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, validChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, validChannelName);
|
||||
// await expect(page.getByText("Sent to Slack")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
//
|
||||
// test("Edit and test a valid Slack E2E channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await expect(get(page, validChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, validChannelName);
|
||||
// await expect(page.getByText("Sent to Slack")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
// });
|
||||
|
||||
test.describe.serial("Invalid channel", () => {
|
||||
test("Create and test invalid Slack channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await create(page, "Slack", invalidChannelName, async (page) => {
|
||||
await page.getByLabel(/Slack Webhook URL/).fill("https://WRONG_SLACK_WEBHOOK");
|
||||
});
|
||||
await submit(page);
|
||||
await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await testFromEdit(page, invalidChannelName);
|
||||
await expect(page.getByText("An error occurred while testing the notification channel, check your configuration")).toBeVisible();
|
||||
await cancel(page);
|
||||
});
|
||||
|
||||
test("Delete invalid Slack channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await remove(page, invalidChannelName);
|
||||
await expect(page.getByText("Notification channel has been successfully removed.")).toBeVisible();
|
||||
await expect(page.getByText(invalidChannelName)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {getEnv} from "../helpers/env";
|
||||
import {
|
||||
cancel, create, get, remove, submit, testFromEdit,
|
||||
} from "../helpers/notification";
|
||||
import {LOCAL_STORAGE_PATH} from "../helpers/session";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const validChannelName = "SMTP E2E Required";
|
||||
const invalidChannelName = "SMTP E2E Invalid";
|
||||
const successMessage = `Email sent: ${getEnv("E2E_NOTIFICATION_SMTP_TO")}`;
|
||||
|
||||
// test.describe.serial("Valid channel", () => {
|
||||
// test("Create and test a valid SMTP channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await create(page, "Email", validChannelName, async (page) => {
|
||||
// await page.getByLabel(/SMTP Host/).fill(getEnv("E2E_NOTIFICATION_SMTP_HOST"));
|
||||
// await page.getByLabel(/SMTP Port/).fill(getEnv("E2E_NOTIFICATION_SMTP_PORT"));
|
||||
// await page.getByLabel(/Username/).fill(getEnv("E2E_NOTIFICATION_SMTP_USER"));
|
||||
// await page.getByLabel(/Password/).fill(getEnv("E2E_NOTIFICATION_SMTP_PASSWORD"));
|
||||
// await page.getByLabel(/From Email/).fill(getEnv("E2E_NOTIFICATION_SMTP_FROM"));
|
||||
// await page.getByLabel(/To Email/).fill(getEnv("E2E_NOTIFICATION_SMTP_TO"));
|
||||
// });
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, validChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, validChannelName);
|
||||
// await expect(page.getByText(successMessage)).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
//
|
||||
// test("Edit and test a valid SMTP channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await expect(get(page, validChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, validChannelName);
|
||||
// await expect(page.getByText(successMessage)).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
// });
|
||||
|
||||
test.describe.serial("Invalid channel", () => {
|
||||
test("Create and test invalid SMTP E2E channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await create(page, "Email", invalidChannelName, async (page) => {
|
||||
await page.getByLabel(/SMTP Host/).fill("smtp.invalid");
|
||||
await page.getByLabel(/SMTP Port/).fill(getEnv("E2E_NOTIFICATION_SMTP_PORT"));
|
||||
await page.getByLabel(/Username/).fill(getEnv("E2E_NOTIFICATION_SMTP_USER"));
|
||||
await page.getByLabel(/Password/).fill("wrong-password");
|
||||
await page.getByLabel(/From Email/).fill(getEnv("E2E_NOTIFICATION_SMTP_FROM"));
|
||||
await page.getByLabel(/To Email/).fill(getEnv("E2E_NOTIFICATION_SMTP_TO"));
|
||||
});
|
||||
await submit(page);
|
||||
await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await testFromEdit(page, invalidChannelName);
|
||||
await expect(page.getByText("An error occurred while testing the notification channel, check your configuration")).toBeVisible();
|
||||
await cancel(page);
|
||||
});
|
||||
|
||||
test("Delete invalid SMTP channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await remove(page, invalidChannelName);
|
||||
await expect(page.getByText("Notification channel has been successfully removed.")).toBeVisible();
|
||||
await expect(page.getByText(invalidChannelName)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {
|
||||
cancel, create, get, remove, submit, testFromEdit,
|
||||
} from "../helpers/notification";
|
||||
import {getEnv} from "../helpers/env";
|
||||
import {LOCAL_STORAGE_PATH} from "../helpers/session";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const requiredChannelName = "Telegram E2E Required";
|
||||
const optionalChannelName = "Telegram E2E Optional";
|
||||
const invalidChannelName = "Telegram E2E Invalid";
|
||||
|
||||
// test.describe.serial("Valid channels", () => {
|
||||
// test("Create and test a valid Telegram channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await create(page, "Telegram", requiredChannelName, async (page) => {
|
||||
// await page.getByLabel(/Telegram Bot Token/).fill(getEnv("E2E_NOTIFICATION_TELEGRAM_BOT_TOKEN"));
|
||||
// await page.getByLabel(/Telegram Chat ID/).fill(getEnv("E2E_NOTIFICATION_TELEGRAM_CHAT_ID"));
|
||||
// });
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, requiredChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, requiredChannelName);
|
||||
// await expect(page.getByText("Sent to Telegram")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
//
|
||||
// test("Create and test a valid Telegram channel with Topic ID", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await create(page, "Telegram", optionalChannelName, async (page) => {
|
||||
// await page.getByLabel(/Telegram Bot Token/).fill(getEnv("E2E_NOTIFICATION_TELEGRAM_BOT_TOKEN"));
|
||||
// await page.getByLabel(/Telegram Chat ID/).fill(getEnv("E2E_NOTIFICATION_TELEGRAM_CHAT_ID"));
|
||||
// await page.getByLabel(/Telegram Topic ID/).fill(getEnv("E2E_NOTIFICATION_TELEGRAM_TOPIC_ID"));
|
||||
// });
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, optionalChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, optionalChannelName);
|
||||
// await expect(page.getByText("Sent to Telegram")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
// });
|
||||
|
||||
test.describe.serial("Invalid channel", () => {
|
||||
test("Create and test invalid Telegram channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await create(page, "Telegram", invalidChannelName, async (page) => {
|
||||
await page.getByLabel(/Telegram Bot Token/).fill("wrong-telegram-bot-token");
|
||||
await page.getByLabel(/Telegram Chat ID/).fill(getEnv("E2E_NOTIFICATION_TELEGRAM_CHAT_ID"));
|
||||
await page.getByLabel(/Telegram Topic ID/).fill(getEnv("E2E_NOTIFICATION_TELEGRAM_TOPIC_ID"));
|
||||
});
|
||||
await submit(page);
|
||||
await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await testFromEdit(page, invalidChannelName);
|
||||
await expect(page.getByText("An error occurred while testing the notification channel, check your configuration")).toBeVisible();
|
||||
await cancel(page);
|
||||
});
|
||||
|
||||
test("Delete invalid Telegram channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await remove(page, invalidChannelName);
|
||||
await expect(page.getByText("Notification channel has been successfully removed.")).toBeVisible();
|
||||
await expect(page.getByText(invalidChannelName)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {
|
||||
cancel, create, get, remove, submit, testFromEdit,
|
||||
} from "../helpers/notification";
|
||||
import {getEnv} from "../helpers/env";
|
||||
import {LOCAL_STORAGE_PATH} from "../helpers/session";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const requiredChannelName = "Webhook E2E Required";
|
||||
const optionalChannelName = "Webhook E2E Optional";
|
||||
const invalidChannelName = "Webhook E2E Invalid";
|
||||
|
||||
// test.describe.serial("Valid channels", () => {
|
||||
// test("Create and test a valid Webhook channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await create(page, "Webhook", requiredChannelName, async (page) => {
|
||||
// await page.getByLabel(/Webhook URL/).fill(getEnv("E2E_NOTIFICATION_WEBHOOK_URL"));
|
||||
// });
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, requiredChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, requiredChannelName);
|
||||
// await expect(page.getByText("Sent to Webhook")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
//
|
||||
// test("Create and test a valid Webhook channel with optional header", async ({page}) => {
|
||||
// await page.goto("/dashboard/notifications/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
// await create(page, "Webhook", optionalChannelName, async (page) => {
|
||||
// await page.getByLabel(/Webhook URL/).fill(getEnv("E2E_NOTIFICATION_WEBHOOK_URL"));
|
||||
// await page.getByLabel(/^Header Name$/).fill(getEnv("E2E_NOTIFICATION_WEBHOOK_SECRET_HEADER"));
|
||||
// await page.getByLabel(/^Secret Value$/).fill(getEnv("E2E_NOTIFICATION_WEBHOOK_SECRET"));
|
||||
// });
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, optionalChannelName)).toBeVisible();
|
||||
// await testFromEdit(page, optionalChannelName);
|
||||
// await expect(page.getByText("Sent to Webhook")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
// });
|
||||
|
||||
test.describe.serial("Invalid channel", () => {
|
||||
test("Create and test invalid Webhook channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await create(page, "Webhook", invalidChannelName, async (page) => {
|
||||
await page.getByLabel(/Webhook URL/).fill("https://webhook.example.com/api/wrong-webhook");
|
||||
await page.getByLabel(/^Header Name$/).fill(getEnv("E2E_NOTIFICATION_WEBHOOK_SECRET_HEADER"));
|
||||
await page.getByLabel(/^Secret Value$/).fill("wrong-webhook-secret");
|
||||
});
|
||||
await submit(page);
|
||||
await expect(page.getByText("Notification channel has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await testFromEdit(page, invalidChannelName);
|
||||
await expect(page.getByText("An error occurred while testing the notification channel, check your configuration")).toBeVisible();
|
||||
await cancel(page);
|
||||
});
|
||||
|
||||
test("Delete invalid Webhook E2E channel", async ({page}) => {
|
||||
await page.goto("/dashboard/notifications/channels");
|
||||
await expect(page.getByRole("heading", {name: "Notification channels"})).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await remove(page, invalidChannelName);
|
||||
await expect(page.getByText("Notification channel has been successfully removed.")).toBeVisible();
|
||||
await expect(page.getByText(invalidChannelName)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {create, edit, get, remove} from "./helpers/project";
|
||||
import {LOCAL_STORAGE_PATH} from "./helpers/session";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const project = {
|
||||
emptyStateName: "Project A",
|
||||
buttonName: "Project B",
|
||||
updatedButtonName: "Project B Updated",
|
||||
};
|
||||
|
||||
test.describe.serial(() => {
|
||||
test("Create a project from empty state", async ({page}) => {
|
||||
await page.goto("/dashboard/projects");
|
||||
await expect(page.getByRole("heading", {name: "Projects"})).toBeVisible();
|
||||
await expect(page.getByText("Create new Project", {exact: true})).toBeVisible();
|
||||
|
||||
await create(page, "emptyState", project.emptyStateName);
|
||||
|
||||
await expect(page.getByText("Project has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, project.emptyStateName)).toBeVisible();
|
||||
await expect(page.getByText("Create new Project", {exact: true})).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("Create a project from classic button", async ({page}) => {
|
||||
await page.goto("/dashboard/projects");
|
||||
await expect(page.getByRole("heading", {name: "Projects"})).toBeVisible();
|
||||
await expect(get(page, project.emptyStateName)).toBeVisible();
|
||||
|
||||
await create(page, "button", project.buttonName);
|
||||
|
||||
await expect(page.getByText("Project has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, project.buttonName)).toBeVisible();
|
||||
});
|
||||
|
||||
test("Edit the second created project", async ({page}) => {
|
||||
await page.goto("/dashboard/projects");
|
||||
await expect(page.getByRole("heading", {name: "Projects"})).toBeVisible();
|
||||
await expect(get(page, project.buttonName)).toBeVisible();
|
||||
|
||||
await edit(page, project.buttonName, project.updatedButtonName);
|
||||
|
||||
await expect(page.getByText("Project has been successfully updated.")).toBeVisible();
|
||||
await expect(page.getByText(project.updatedButtonName, {exact: true})).toBeVisible();
|
||||
});
|
||||
|
||||
test("Delete the second created project", async ({page}) => {
|
||||
await page.goto("/dashboard/projects");
|
||||
await expect(page.getByRole("heading", {name: "Projects"})).toBeVisible();
|
||||
await expect(get(page, project.updatedButtonName)).toBeVisible();
|
||||
|
||||
await remove(page, project.updatedButtonName);
|
||||
|
||||
await expect(page).toHaveURL("/dashboard/projects");
|
||||
await expect(page.getByText("Projects has been successfully archived.")).toBeVisible();
|
||||
await expect(page.getByText(project.updatedButtonName)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import {test} from "@playwright/test";
|
||||
import fs from "fs";
|
||||
import {LOCAL_STORAGE_PATH} from "./helpers/session";
|
||||
|
||||
test.describe(() => {
|
||||
test.beforeAll(async () => {
|
||||
if (fs.existsSync(LOCAL_STORAGE_PATH)) fs.unlinkSync(LOCAL_STORAGE_PATH);
|
||||
fs.writeFileSync(LOCAL_STORAGE_PATH, JSON.stringify({}));
|
||||
});
|
||||
|
||||
test("Prepare shared storage state", async () => {
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {getEnv} from "../helpers/env";
|
||||
import {LOCAL_STORAGE_PATH} from "../helpers/session";
|
||||
import {
|
||||
cancel, create, get, remove, submit, testConnection, testFromEdit,
|
||||
} from "../helpers/storage";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const requiredChannelName = "Google Drive E2E Required";
|
||||
const invalidChannelName = "Google Drive E2E Invalid";
|
||||
|
||||
// test.describe.serial("Valid channel", () => {
|
||||
// test("Create and test a valid Google Drive channel", async ({page}) => {
|
||||
// await page.goto("/dashboard/storages/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Storage channels"})).toBeVisible();
|
||||
// await create(page, "Google Drive", requiredChannelName, async (page) => {
|
||||
// await page.getByLabel(/Client ID/).fill(getEnv("E2E_STORAGE_GOOGLE_DRIVE_CLIENT_ID"));
|
||||
// await page.getByLabel(/Client Secret/).fill(getEnv("E2E_STORAGE_GOOGLE_DRIVE_CLIENT_SECRET"));
|
||||
// await page.getByLabel(/Folder ID/).fill(getEnv("E2E_STORAGE_GOOGLE_DRIVE_FOLDER_ID"));
|
||||
// });
|
||||
// await expect(page.getByRole("heading", {name: "Add Storage Channel"})).toBeVisible();
|
||||
// await testConnection(page);
|
||||
// await expect(page.getByText("Successfully connected to storage channel")).toBeVisible();
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Storage channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, requiredChannelName)).toBeVisible();
|
||||
//
|
||||
// await testFromEdit(page, requiredChannelName);
|
||||
// await expect(page.getByRole("heading", {name: "Edit Storage Channel"})).toBeVisible();
|
||||
// await expect(page.getByText("Successfully connected to storage channel")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
// });
|
||||
|
||||
test.describe.serial("Invalid channel", () => {
|
||||
test("Create and test invalid Google Drive channel", async ({page}) => {
|
||||
await page.goto("/dashboard/storages/channels");
|
||||
await expect(page.getByRole("heading", {name: "Storage channels"})).toBeVisible();
|
||||
await create(page, "Google Drive", invalidChannelName, async (page) => {
|
||||
await page.getByLabel(/Client ID/).fill(getEnv("E2E_STORAGE_GOOGLE_DRIVE_CLIENT_ID"));
|
||||
await page.getByLabel(/Client Secret/).fill("wrong-google-drive-client-secret");
|
||||
await page.getByLabel(/Folder ID/).fill(getEnv("E2E_STORAGE_GOOGLE_DRIVE_FOLDER_ID"));
|
||||
});
|
||||
await testConnection(page);
|
||||
await expect(page.getByText("An error occurred while testing the storage channel")).toBeVisible();
|
||||
await submit(page);
|
||||
await expect(page.getByText("Storage channel has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
});
|
||||
|
||||
test("Delete invalid Google Drive E2E channel", async ({page}) => {
|
||||
await page.goto("/dashboard/storages/channels");
|
||||
await expect(page.getByRole("heading", {name: "Storage channels"})).toBeVisible();
|
||||
await expect(get(page, invalidChannelName)).toBeVisible();
|
||||
await remove(page, invalidChannelName);
|
||||
await expect(page.getByText("Storage channel has been successfully removed.")).toBeVisible();
|
||||
await expect(page.getByText(invalidChannelName)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,121 @@
|
||||
import {expect, test} from "@playwright/test";
|
||||
import {getEnv} from "../helpers/env";
|
||||
import {LOCAL_STORAGE_PATH} from "../helpers/session";
|
||||
import {
|
||||
cancel, create, get, remove, submit, testConnection, testFromEdit,
|
||||
} from "../helpers/storage";
|
||||
|
||||
test.use({storageState: LOCAL_STORAGE_PATH});
|
||||
|
||||
const providers = [
|
||||
{
|
||||
title: "AWS S3",
|
||||
requiredChannelName: "AWS S3 E2E Required",
|
||||
optionalChannelName: "AWS S3 E2E Optional",
|
||||
invalidChannelName: "AWS S3 E2E Invalid",
|
||||
endpointUrl: getEnv("E2E_STORAGE_AWS_S3_ENDPOINT_URL"),
|
||||
region: getEnv("E2E_STORAGE_AWS_S3_REGION"),
|
||||
accessKey: getEnv("E2E_STORAGE_AWS_S3_ACCESS_KEY"),
|
||||
secretKey: getEnv("E2E_STORAGE_AWS_S3_SECRET_KEY"),
|
||||
bucketName: getEnv("E2E_STORAGE_AWS_S3_BUCKET_NAME"),
|
||||
port: getEnv("E2E_STORAGE_AWS_S3_PORT"),
|
||||
invalidAccessKey: "wrong-aws-access-key",
|
||||
invalidSecretKey: "wrong-aws-secret-key",
|
||||
},
|
||||
{
|
||||
title: "Cloudflare R2",
|
||||
requiredChannelName: "Cloudflare R2 E2E Required",
|
||||
optionalChannelName: "Cloudflare R2 E2E Optional",
|
||||
invalidChannelName: "Cloudflare R2 E2E Invalid",
|
||||
endpointUrl: getEnv("E2E_STORAGE_R2_ENDPOINT_URL"),
|
||||
region: getEnv("E2E_STORAGE_R2_REGION"),
|
||||
accessKey: getEnv("E2E_STORAGE_R2_ACCESS_KEY"),
|
||||
secretKey: getEnv("E2E_STORAGE_R2_SECRET_KEY"),
|
||||
bucketName: getEnv("E2E_STORAGE_R2_BUCKET_NAME"),
|
||||
port: getEnv("E2E_STORAGE_R2_PORT"),
|
||||
invalidAccessKey: "wrong-r2-access-key",
|
||||
invalidSecretKey: "wrong-r2-secret-key",
|
||||
},
|
||||
] as const;
|
||||
|
||||
for (const provider of providers) {
|
||||
test.describe(provider.title, () => {
|
||||
// test.describe.serial("Valid channels", () => {
|
||||
// test(`Create and test a valid ${provider.title} channel`, async ({page}) => {
|
||||
// await page.goto("/dashboard/storages/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Storage channels"})).toBeVisible();
|
||||
// await create(page, "S3", provider.requiredChannelName, async (page) => {
|
||||
// await page.getByLabel(/Endpoint URL/).fill(provider.endpointUrl);
|
||||
// await page.getByLabel(/Access Key/).fill(provider.accessKey);
|
||||
// await page.getByLabel(/Secret Key/).fill(provider.secretKey);
|
||||
// await page.getByLabel(/Bucket name/).fill(provider.bucketName);
|
||||
// });
|
||||
// await expect(page.getByRole("heading", {name: "Add Storage Channel"})).toBeVisible();
|
||||
// await testConnection(page);
|
||||
// await expect(page.getByText("Successfully connected to storage channel")).toBeVisible();
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Storage channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, provider.requiredChannelName)).toBeVisible();
|
||||
//
|
||||
// await testFromEdit(page, provider.requiredChannelName);
|
||||
// await expect(page.getByRole("heading", {name: "Edit Storage Channel"})).toBeVisible();
|
||||
// await expect(page.getByText("Successfully connected to storage channel")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
//
|
||||
// test(`Create and test a valid ${provider.title} channel with optional region and port`, async ({page}) => {
|
||||
// await page.goto("/dashboard/storages/channels");
|
||||
// await expect(page.getByRole("heading", {name: "Storage channels"})).toBeVisible();
|
||||
// await create(page, "S3", provider.optionalChannelName, async (page) => {
|
||||
// await page.getByLabel(/Endpoint URL/).fill(provider.endpointUrl);
|
||||
// await page.getByLabel(/^Region$/).fill(provider.region);
|
||||
// await page.getByLabel(/Access Key/).fill(provider.accessKey);
|
||||
// await page.getByLabel(/Secret Key/).fill(provider.secretKey);
|
||||
// await page.getByLabel(/Bucket name/).fill(provider.bucketName);
|
||||
// await page.getByLabel(/^Port$/).fill(provider.port);
|
||||
// });
|
||||
// await expect(page.getByRole("heading", {name: "Add Storage Channel"})).toBeVisible();
|
||||
// await testConnection(page);
|
||||
// await expect(page.getByText("Successfully connected to storage channel")).toBeVisible();
|
||||
// await submit(page);
|
||||
// await expect(page.getByText("Storage channel has been successfully created.")).toBeVisible();
|
||||
// await expect(get(page, provider.optionalChannelName)).toBeVisible();
|
||||
//
|
||||
// await testFromEdit(page, provider.optionalChannelName);
|
||||
// await expect(page.getByRole("heading", {name: "Edit Storage Channel"})).toBeVisible();
|
||||
// await expect(page.getByText("Successfully connected to storage channel")).toBeVisible();
|
||||
// await cancel(page);
|
||||
// });
|
||||
// });
|
||||
|
||||
test.describe.serial("Invalid channel", () => {
|
||||
test(`Create and test invalid ${provider.title} channel`, async ({page}) => {
|
||||
await page.goto("/dashboard/storages/channels");
|
||||
await expect(page.getByRole("heading", {name: "Storage channels"})).toBeVisible();
|
||||
await create(page, "S3", provider.invalidChannelName, async (page) => {
|
||||
await page.getByLabel(/Endpoint URL/).fill(provider.endpointUrl);
|
||||
await page.getByLabel(/^Region$/).fill(provider.region);
|
||||
await page.getByLabel(/Access Key/).fill(provider.invalidAccessKey);
|
||||
await page.getByLabel(/Secret Key/).fill(provider.invalidSecretKey);
|
||||
await page.getByLabel(/Bucket name/).fill(provider.bucketName);
|
||||
await page.getByLabel(/^Port$/).fill(provider.port);
|
||||
});
|
||||
await expect(page.getByRole("heading", {name: "Add Storage Channel"})).toBeVisible();
|
||||
await testConnection(page);
|
||||
await expect(page.getByText("An error occurred while testing the storage channel")).toBeVisible();
|
||||
await submit(page);
|
||||
await expect(page.getByText("Storage channel has been successfully created.")).toBeVisible();
|
||||
await expect(get(page, provider.invalidChannelName)).toBeVisible();
|
||||
});
|
||||
|
||||
test(`Delete invalid ${provider.title} channel`, async ({page}) => {
|
||||
await page.goto("/dashboard/storages/channels");
|
||||
await expect(page.getByRole("heading", {name: "Storage channels"})).toBeVisible();
|
||||
await expect(get(page, provider.invalidChannelName)).toBeVisible();
|
||||
await remove(page, provider.invalidChannelName);
|
||||
await expect(page.getByText("Storage channel has been successfully removed.")).toBeVisible();
|
||||
await expect(page.getByText(provider.invalidChannelName)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
+23
-21
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "portabase",
|
||||
"version": "1.10.0",
|
||||
"version": "1.14.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev --turbopack -p 8887",
|
||||
@@ -15,8 +15,9 @@
|
||||
"release": "release-it"
|
||||
},
|
||||
"dependencies": {
|
||||
"@better-auth/passkey": "^1.5.6",
|
||||
"@better-auth/sso": "^1.5.6",
|
||||
"@better-auth/core": "1.6.2",
|
||||
"@better-auth/passkey": "1.6.2",
|
||||
"@better-auth/sso": "1.6.2",
|
||||
"@hookform/resolvers": "^5.2.2",
|
||||
"@radix-ui/react-accordion": "^1.2.12",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.15",
|
||||
@@ -48,45 +49,45 @@
|
||||
"@radix-ui/react-tooltip": "^1.2.8",
|
||||
"@react-email/components": "^0.0.41",
|
||||
"@t3-oss/env-nextjs": "^0.13.11",
|
||||
"@tanstack/react-query": "^5.95.2",
|
||||
"@tanstack/react-query": "^5.97.0",
|
||||
"@tanstack/react-table": "^8.21.3",
|
||||
"@types/nodemailer": "^6.4.23",
|
||||
"@types/ws": "^8.18.1",
|
||||
"@zenstackhq/runtime": "2.14.2",
|
||||
"argon2": "^0.43.1",
|
||||
"bcrypt": "^6.0.0",
|
||||
"better-auth": "1.5.6",
|
||||
"better-auth": "1.6.2",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
"date-fns": "^4.1.0",
|
||||
"dockerode": "^4.0.10",
|
||||
"dotenv": "^16.6.1",
|
||||
"drizzle-orm": "^0.43.1",
|
||||
"drizzle-zod": "^0.7.1",
|
||||
"drizzle-orm": "0.45.2",
|
||||
"drizzle-zod": "0.8.3",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
"googleapis": "^170.1.0",
|
||||
"input-otp": "^1.4.2",
|
||||
"lucide-react": "^0.553.0",
|
||||
"minio": "^8.0.7",
|
||||
"motion": "^12.38.0",
|
||||
"next": "16.2.1",
|
||||
"next": "16.2.3",
|
||||
"next-safe-action": "^7.10.8",
|
||||
"next-themes": "^0.4.6",
|
||||
"node-cron": "^4.2.1",
|
||||
"node-forge": "^1.4.0",
|
||||
"nodemailer": "^7.0.13",
|
||||
"nodemailer": "8.0.5",
|
||||
"npm-check-updates": "^18.3.1",
|
||||
"pg": "^8.20.0",
|
||||
"pino": "^10.3.1",
|
||||
"pino-pretty": "^13.1.3",
|
||||
"prettier": "^3.8.1",
|
||||
"react": "^19.2.4",
|
||||
"prettier": "^3.8.2",
|
||||
"react": "^19.2.5",
|
||||
"react-day-picker": "9.7.0",
|
||||
"react-dom": "^19.2.4",
|
||||
"react-dom": "^19.2.5",
|
||||
"react-dropzone": "^14.4.1",
|
||||
"react-email": "^4.3.2",
|
||||
"react-hook-form": "^7.72.0",
|
||||
"react-hook-form": "^7.72.1",
|
||||
"react-qr-code": "^2.0.18",
|
||||
"react-resizable-panels": "^3.0.6",
|
||||
"react-twc": "^1.5.1",
|
||||
@@ -101,32 +102,33 @@
|
||||
"uuid": "^11.1.0",
|
||||
"vaul": "^1.1.2",
|
||||
"ws": "^8.20.0",
|
||||
"zod": "^3.25.76"
|
||||
"zod": "4.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/react": "^6.0.2",
|
||||
"@playwright/test": "1.58.2",
|
||||
"@react-email/preview-server": "4.3.2",
|
||||
"@react-email/render": "^2.0.4",
|
||||
"@react-email/render": "^2.0.6",
|
||||
"@release-it/bumper": "^7.0.5",
|
||||
"@release-it/conventional-changelog": "^10.0.6",
|
||||
"@tailwindcss/postcss": "^4.2.2",
|
||||
"@types/eslint-plugin-tailwindcss": "^3.17.0",
|
||||
"@types/node": "^22.19.15",
|
||||
"@types/node": "^22.19.17",
|
||||
"@types/node-forge": "^1.3.14",
|
||||
"@types/pg": "^8.20.0",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@zenstackhq/openapi": "^2.22.1",
|
||||
"@zenstackhq/tanstack-query": "^2.22.2",
|
||||
"baseline-browser-mapping": "^2.10.12",
|
||||
"baseline-browser-mapping": "^2.10.17",
|
||||
"drizzle-kit": "^0.31.10",
|
||||
"esbuild": "^0.27.4",
|
||||
"esbuild": "^0.27.7",
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-config-next": "^16.2.1",
|
||||
"eslint-config-next": "^16.2.3",
|
||||
"eslint-plugin-tailwindcss": "^3.18.2",
|
||||
"framer-motion": "^12.38.0",
|
||||
"postcss": "^8.5.8",
|
||||
"node-pty": "^1.1.0",
|
||||
"postcss": "8.5.10",
|
||||
"release-it": "^19.2.4",
|
||||
"tailwindcss": "^4.2.2",
|
||||
"tsx": "^4.21.0",
|
||||
@@ -134,5 +136,5 @@
|
||||
"typescript": "^5.9.3",
|
||||
"zenstack": "2.14.2"
|
||||
},
|
||||
"packageManager": "pnpm@10.33.0"
|
||||
"packageManager": "pnpm@11.1.2+sha512.415a1cc25974731e75455c1468371be74c5aa5fb7621b50d4056d222451609f11412f23fd602e6169f1e060466641f798597e1be961a10688836a67b16569499"
|
||||
}
|
||||
|
||||
+46
-46
@@ -1,12 +1,12 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
// import dotenv from 'dotenv';
|
||||
// import path from 'path';
|
||||
// dotenv.config({ path: path.resolve(__dirname, '.env') });
|
||||
dotenv.config({ path: path.resolve(__dirname, '.env') });
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
@@ -25,55 +25,55 @@ export default defineConfig({
|
||||
reporter: 'html',
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('')`. */
|
||||
...devices['Desktop Chrome'],
|
||||
baseURL: process.env.PROJECT_URL,
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: 'on-first-retry',
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: { ...devices['Desktop Chrome'] },
|
||||
},
|
||||
/* Configure projects and dependency order */
|
||||
projects: [
|
||||
{
|
||||
name: 'setup',
|
||||
testMatch: '**/setup.spec.ts',
|
||||
},
|
||||
{
|
||||
name: 'auth',
|
||||
testMatch: '**/auth.spec.ts',
|
||||
dependencies: ['setup'],
|
||||
},
|
||||
{
|
||||
name: 'access-management',
|
||||
testMatch: '**/access-management.spec.ts',
|
||||
dependencies: ['auth'],
|
||||
},
|
||||
{
|
||||
name: 'notification',
|
||||
testMatch: '**/notification/**/*.spec.ts',
|
||||
dependencies: ['access-management'],
|
||||
},
|
||||
{
|
||||
name: 'storage',
|
||||
testMatch: '**/storage/**/*.spec.ts',
|
||||
dependencies: ['access-management'],
|
||||
},
|
||||
{
|
||||
name: 'agent',
|
||||
testMatch: '**/agent.spec.ts',
|
||||
dependencies: ['access-management'],
|
||||
},
|
||||
|
||||
{
|
||||
name: 'firefox',
|
||||
use: { ...devices['Desktop Firefox'] },
|
||||
},
|
||||
{
|
||||
name: 'project',
|
||||
testMatch: '**/project.spec.ts',
|
||||
dependencies: ['access-management'],
|
||||
},
|
||||
{
|
||||
name: 'cleanup',
|
||||
testMatch: '**/cleanup.spec.ts',
|
||||
dependencies: ['agent', 'storage', 'notification', 'project'],
|
||||
},
|
||||
]
|
||||
|
||||
{
|
||||
name: 'webkit',
|
||||
use: { ...devices['Desktop Safari'] },
|
||||
},
|
||||
|
||||
/* Test against mobile viewports. */
|
||||
{
|
||||
name: 'Mobile Chrome',
|
||||
use: { ...devices['Pixel 5'] },
|
||||
},
|
||||
{
|
||||
name: 'Mobile Safari',
|
||||
use: { ...devices['iPhone 12'] },
|
||||
},
|
||||
|
||||
/* Test against branded browsers. */
|
||||
// {
|
||||
// name: 'Microsoft Edge',
|
||||
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
|
||||
// },
|
||||
// {
|
||||
// name: 'Google Chrome',
|
||||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
|
||||
// },
|
||||
],
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
// webServer: {
|
||||
// command: 'docker compose up -d && make up',
|
||||
// url: 'http://localhost:8887',
|
||||
// reuseExistingServer: !process.env.CI,
|
||||
// },
|
||||
});
|
||||
|
||||
Generated
+2589
-2053
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,19 @@
|
||||
allowBuilds:
|
||||
'@prisma/client': true
|
||||
'@prisma/engines': true
|
||||
argon2: true
|
||||
bcrypt: true
|
||||
cpu-features: true
|
||||
esbuild: true
|
||||
node-pty: true
|
||||
prisma: true
|
||||
protobufjs: true
|
||||
sharp: true
|
||||
ssh2: true
|
||||
unrs-resolver: true
|
||||
zenstack: true
|
||||
ignoredBuiltDependencies:
|
||||
- node-pty
|
||||
onlyBuiltDependencies:
|
||||
- '@prisma/client'
|
||||
- '@prisma/engines'
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 71 KiB |
@@ -6,7 +6,7 @@ import z from "zod";
|
||||
import { db } from "@/db";
|
||||
import {action} from "@/lib/safe-actions/actions";
|
||||
|
||||
//todo: to be continued...
|
||||
//TODO: to be continued...
|
||||
export const forgotPasswordAction = action
|
||||
.schema(
|
||||
z.object({
|
||||
|
||||
@@ -44,7 +44,7 @@ export function BreadCrumbsWrapper() {
|
||||
)
|
||||
}
|
||||
|
||||
const FORBIDDEN_LINKS = ["organization", "dashboard", "database", "admin", "settings", "notifications"];
|
||||
const FORBIDDEN_LINKS = ["organization", "dashboard", "database", "admin", "notifications", "storages"];
|
||||
|
||||
|
||||
export function BreadCrumbs({}: BreadCrumbsProps) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import React, { ComponentType, useState } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
import { PaginationNavigation } from "@/components/wrappers/common/pagination/pagination-navigation";
|
||||
import { PaginationSize } from "@/components/wrappers/common/pagination/pagination-size";
|
||||
|
||||
interface CardsWithPaginationProps<T> {
|
||||
className?: string;
|
||||
@@ -13,19 +14,21 @@ interface CardsWithPaginationProps<T> {
|
||||
cardsPerPage?: number;
|
||||
numberOfColumns?: number;
|
||||
maxVisiblePages?: number;
|
||||
pageSizeOptions?: number[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export function CardsWithPagination<T>(props: CardsWithPaginationProps<T>) {
|
||||
const { className, organizationSlug, data, cardItem, cardsPerPage = 5, numberOfColumns = 1, maxVisiblePages = 3, ...rest } = props;
|
||||
const { className, organizationSlug, data, cardItem, cardsPerPage = 5, numberOfColumns = 1, maxVisiblePages = 3, pageSizeOptions, ...rest } = props;
|
||||
|
||||
const CardItem = cardItem;
|
||||
|
||||
const [pageSize, setPageSize] = useState(cardsPerPage);
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const totalPages = Math.ceil(data.length / cardsPerPage);
|
||||
const totalPages = Math.ceil(data.length / pageSize);
|
||||
|
||||
const indexOfLastCard = currentPage * cardsPerPage;
|
||||
const indexOfFirstCard = indexOfLastCard - cardsPerPage;
|
||||
const indexOfLastCard = currentPage * pageSize;
|
||||
const indexOfFirstCard = indexOfLastCard - pageSize;
|
||||
const currentCards = data.slice(indexOfFirstCard, indexOfLastCard);
|
||||
|
||||
const goToPage = (pageNumber: number) => {
|
||||
@@ -40,6 +43,14 @@ export function CardsWithPagination<T>(props: CardsWithPaginationProps<T>) {
|
||||
goToPage(Math.min(totalPages, currentPage + 1));
|
||||
};
|
||||
|
||||
const handlePageSizeChange = (newSize: number) => {
|
||||
if (!Number.isFinite(newSize) || newSize < 1) return;
|
||||
setPageSize(newSize);
|
||||
setCurrentPage(1);
|
||||
};
|
||||
|
||||
const showSizeSelector = pageSizeOptions && pageSizeOptions.length > 0;
|
||||
|
||||
return (
|
||||
<div className={cn("flex flex-col h-full justify-between", className)}>
|
||||
<div className={cn(`grid h-max auto-rows-min gap-4 md:grid-cols-${numberOfColumns}`)}>
|
||||
@@ -47,15 +58,24 @@ export function CardsWithPagination<T>(props: CardsWithPaginationProps<T>) {
|
||||
<CardItem key={key} data={card} organizationSlug={organizationSlug} {...rest} />
|
||||
))}
|
||||
</div>
|
||||
<PaginationNavigation
|
||||
className="justify-end mt-4"
|
||||
totalPages={totalPages}
|
||||
currentPage={currentPage}
|
||||
goToPage={goToPage}
|
||||
goToPrevPage={goToPrevPage}
|
||||
goToNextPage={goToNextPage}
|
||||
maxVisiblePages={maxVisiblePages}
|
||||
/>
|
||||
<div className="flex items-center justify-end mt-4 gap-4">
|
||||
{showSizeSelector && (
|
||||
<PaginationSize
|
||||
pageSize={pageSize}
|
||||
onPageSizeChange={handlePageSizeChange}
|
||||
pageSizeOptions={pageSizeOptions}
|
||||
/>
|
||||
)}
|
||||
<PaginationNavigation
|
||||
className="justify-end"
|
||||
totalPages={totalPages}
|
||||
currentPage={currentPage}
|
||||
goToPage={goToPage}
|
||||
goToPrevPage={goToPrevPage}
|
||||
goToNextPage={goToNextPage}
|
||||
maxVisiblePages={maxVisiblePages}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Link from "next/link";
|
||||
import {cn} from "@/lib/utils";
|
||||
import {Plus} from "lucide-react";
|
||||
import {CircleSlash2, Plus} from "lucide-react";
|
||||
import {forwardRef, HTMLAttributes} from "react";
|
||||
|
||||
type EmptyStatePlaceholderProps = {
|
||||
@@ -8,25 +8,32 @@ type EmptyStatePlaceholderProps = {
|
||||
onClick?: () => void;
|
||||
text: string;
|
||||
className?: string;
|
||||
state?: string
|
||||
} & HTMLAttributes<HTMLDivElement>;
|
||||
|
||||
export const EmptyStatePlaceholder = forwardRef<HTMLDivElement, EmptyStatePlaceholderProps>(({
|
||||
url,
|
||||
onClick,
|
||||
text,
|
||||
className,
|
||||
...props
|
||||
}, ref) => {
|
||||
url,
|
||||
onClick,
|
||||
text,
|
||||
state,
|
||||
className,
|
||||
...props
|
||||
}, ref) => {
|
||||
const Container = (
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-full flex-col items-center justify-center w-full rounded-2xl border border-dashed border-muted p-6 lg:p-10",
|
||||
"hover:bg-muted/50 transition-colors text-muted-foreground hover:text-primary text-center space-y-4",
|
||||
"transition-colors text-muted-foreground text-center space-y-4",
|
||||
state != "empty" && "hover:bg-muted/50 hover:text-primary",
|
||||
(onClick || url) && "cursor-pointer"
|
||||
)}
|
||||
onClick={onClick}
|
||||
>
|
||||
<Plus className="w-5 h-5 lg:w-6 lg:h-6" />
|
||||
{state == "empty" ?
|
||||
<CircleSlash2 className="w-5 h-5 lg:w-6 lg:h-6"/>
|
||||
:
|
||||
<Plus className="w-5 h-5 lg:w-6 lg:h-6"/>
|
||||
}
|
||||
<p className="text-sm">{text}</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export type PaginationSizeProps = {
|
||||
className?: string;
|
||||
pageSize: number;
|
||||
onPageSizeChange: (size: number) => void;
|
||||
pageSizeOptions?: number[];
|
||||
};
|
||||
|
||||
export const PaginationSize = (props: PaginationSizeProps) => {
|
||||
const { className, onPageSizeChange, pageSizeOptions = [10, 20, 30, 40, 50] } = props;
|
||||
const effectivePageSize = pageSizeOptions.includes(props.pageSize) ? props.pageSize : pageSizeOptions[0];
|
||||
|
||||
return (
|
||||
<div className={cn("flex items-center justify-end sm:justify-center space-x-2", className)}>
|
||||
<p className="whitespace-nowrap text-sm font-medium hidden md:block">Cards per page</p>
|
||||
<Select
|
||||
value={`${effectivePageSize}`}
|
||||
onValueChange={(value) => onPageSizeChange(Number(value))}
|
||||
>
|
||||
<SelectTrigger className="h-8 w-[4.5rem]" aria-label="Cards per page">
|
||||
<SelectValue placeholder={effectivePageSize} />
|
||||
</SelectTrigger>
|
||||
<SelectContent side="top">
|
||||
{pageSizeOptions.map((size) => (
|
||||
<SelectItem key={size} value={`${size}`}>
|
||||
{size}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
+2
-3
@@ -202,9 +202,9 @@ export const ChannelForm = ({onSuccessAction, organization, defaultValues, kind}
|
||||
name="name"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Channel Name</FormLabel>
|
||||
<FormLabel>Channel Name *</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder={`My ${selectedProviderDetails?.label} Channel`}
|
||||
<Input {...field} placeholder={`e.g. ${selectedProviderDetails?.label} Channel`}
|
||||
value={field.value ?? ""}/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
@@ -252,4 +252,3 @@ export const ChannelForm = ({onSuccessAction, organization, defaultValues, kind}
|
||||
</Form>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -22,11 +22,11 @@ export const NotifierDiscordForm = ({ form }: NotifierDiscordFormProps) => {
|
||||
name="config.discordWebhook"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Discord Webhook URL</FormLabel>
|
||||
<FormLabel>Discord Webhook URL *</FormLabel>
|
||||
<FormControl>
|
||||
<PasswordInput
|
||||
{...field}
|
||||
placeholder="https://discord.com/api/webhooks/..."
|
||||
placeholder="e.g. https://discord.com/api/webhooks/..."
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
|
||||
+4
-4
@@ -23,9 +23,9 @@ export const NotifierGotifyForm = ({ form }: NotifierGotifyFormProps) => {
|
||||
name="config.gotifyServerUrl"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Gotify Server URL</FormLabel>
|
||||
<FormLabel>Gotify Server URL *</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="https://gotify.example.com" />
|
||||
<Input {...field} placeholder="e.g. https://gotify.example.com" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -36,9 +36,9 @@ export const NotifierGotifyForm = ({ form }: NotifierGotifyFormProps) => {
|
||||
name="config.gotifyAppToken"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Application Token</FormLabel>
|
||||
<FormLabel>Application Token *</FormLabel>
|
||||
<FormControl>
|
||||
<PasswordInput {...field} placeholder="A1b2C3d4E5f6G7h" />
|
||||
<PasswordInput {...field} placeholder="e.g. gotify-app-token" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
||||
+10
-10
@@ -18,9 +18,9 @@ export const NotifierNtfyForm = ({form}: NotifierNtfyFormProps) => {
|
||||
name="config.ntfyTopic"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Topic Name</FormLabel>
|
||||
<FormLabel>Topic Name *</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="my-secret-topic"/>
|
||||
<Input {...field} placeholder="e.g. team-alerts"/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
</FormItem>
|
||||
@@ -32,9 +32,9 @@ export const NotifierNtfyForm = ({form}: NotifierNtfyFormProps) => {
|
||||
name="config.ntfyServerUrl"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Server URL (Optional)</FormLabel>
|
||||
<FormLabel>Server URL</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="https://ntfy.sh (default)"/>
|
||||
<Input {...field} placeholder="e.g. https://ntfy.example.com"/>
|
||||
</FormControl>
|
||||
<p className="text-xs text-muted-foreground">Leave empty to use the official ntfy.sh server.</p>
|
||||
<FormMessage/>
|
||||
@@ -47,9 +47,9 @@ export const NotifierNtfyForm = ({form}: NotifierNtfyFormProps) => {
|
||||
name="config.ntfyToken"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Access Token (Optional)</FormLabel>
|
||||
<FormLabel>Access Token</FormLabel>
|
||||
<FormControl>
|
||||
<PasswordInput {...field} placeholder="tk_..."/>
|
||||
<PasswordInput {...field} placeholder="e.g. tk_xxxxx"/>
|
||||
</FormControl>
|
||||
<p className="text-xs text-muted-foreground">Only required for protected topics or self-hosted instances with auth.</p>
|
||||
<FormMessage/>
|
||||
@@ -64,9 +64,9 @@ export const NotifierNtfyForm = ({form}: NotifierNtfyFormProps) => {
|
||||
name="config.ntfyUsername"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Basic Auth Username (Optional)</FormLabel>
|
||||
<FormLabel>Basic Auth Username</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="username"/>
|
||||
<Input {...field} placeholder="e.g. notifier-user"/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
</FormItem>
|
||||
@@ -78,9 +78,9 @@ export const NotifierNtfyForm = ({form}: NotifierNtfyFormProps) => {
|
||||
name="config.ntfyPassword"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Basic Auth Password (Optional)</FormLabel>
|
||||
<FormLabel>Basic Auth Password</FormLabel>
|
||||
<FormControl>
|
||||
<PasswordInput placeholder="password" {...field} />
|
||||
<PasswordInput placeholder="e.g. notifier-password" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
</FormItem>
|
||||
|
||||
+2
-2
@@ -22,11 +22,11 @@ export const NotifierSlackForm = ({ form }: NotifierSmtpFormProps) => {
|
||||
name="config.slackWebhook"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Slack Webhook URL</FormLabel>
|
||||
<FormLabel>Slack Webhook URL *</FormLabel>
|
||||
<FormControl>
|
||||
<PasswordInput
|
||||
{...field}
|
||||
placeholder="https://hooks.slack.com/services/..."
|
||||
placeholder="e.g. https://hooks.slack.com/services/..."
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
|
||||
+12
-12
@@ -19,9 +19,9 @@ export const NotifierSmtpForm = ({form}: NotifierSmtpFormProps) => {
|
||||
name="config.host"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>SMTP Host</FormLabel>
|
||||
<FormLabel>SMTP Host *</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="smtp.gmail.com" {...field} value={field.value ?? ""}/>
|
||||
<Input placeholder="e.g. smtp.example.com" {...field} value={field.value ?? ""}/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
</FormItem>
|
||||
@@ -32,9 +32,9 @@ export const NotifierSmtpForm = ({form}: NotifierSmtpFormProps) => {
|
||||
name="config.port"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>SMTP Port</FormLabel>
|
||||
<FormLabel>SMTP Port *</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="456" type="number" {...field} value={field.value ?? ""}/>
|
||||
<Input placeholder="e.g. 587" type="number" {...field} value={field.value ?? ""}/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
</FormItem>
|
||||
@@ -45,9 +45,9 @@ export const NotifierSmtpForm = ({form}: NotifierSmtpFormProps) => {
|
||||
name="config.user"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Username</FormLabel>
|
||||
<FormLabel>Username *</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="contact@example.com" {...field} value={field.value ?? ""}/>
|
||||
<Input placeholder="e.g. noreply@example.com" {...field} value={field.value ?? ""}/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
</FormItem>
|
||||
@@ -58,7 +58,7 @@ export const NotifierSmtpForm = ({form}: NotifierSmtpFormProps) => {
|
||||
name="config.password"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Password</FormLabel>
|
||||
<FormLabel>Password *</FormLabel>
|
||||
<FormControl>
|
||||
<PasswordInput
|
||||
{...field}
|
||||
@@ -75,9 +75,9 @@ export const NotifierSmtpForm = ({form}: NotifierSmtpFormProps) => {
|
||||
name="config.from"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>From Email</FormLabel>
|
||||
<FormLabel>From Email *</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder={`"Portabase" <example@portabase.io>`} {...field}
|
||||
<Input placeholder={`e.g. "Portabase" <noreply@example.com>`} {...field}
|
||||
value={field.value ?? ""}/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
@@ -90,9 +90,9 @@ export const NotifierSmtpForm = ({form}: NotifierSmtpFormProps) => {
|
||||
name="config.to"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>To Email</FormLabel>
|
||||
<FormLabel>To Email *</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder={"contact@portabase.io, contact2@portabase.io"} {...field}
|
||||
<Input placeholder={"e.g. alerts@example.com, team@example.com"} {...field}
|
||||
value={field.value ?? ""}/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
@@ -102,4 +102,4 @@ export const NotifierSmtpForm = ({form}: NotifierSmtpFormProps) => {
|
||||
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -23,11 +23,11 @@ export const NotifierTelegramForm = ({ form }: NotifierTelegramFormProps) => {
|
||||
name="config.telegramBotToken"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Telegram Bot Token</FormLabel>
|
||||
<FormLabel>Telegram Bot Token *</FormLabel>
|
||||
<FormControl>
|
||||
<PasswordInput
|
||||
{...field}
|
||||
placeholder="123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
|
||||
placeholder="e.g. 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
@@ -39,9 +39,9 @@ export const NotifierTelegramForm = ({ form }: NotifierTelegramFormProps) => {
|
||||
name="config.telegramChatId"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Telegram Chat ID</FormLabel>
|
||||
<FormLabel>Telegram Chat ID *</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="-100123456789 or 123456789" />
|
||||
<Input {...field} placeholder="e.g. -100123456789 or 123456789" />
|
||||
</FormControl>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
You must start the conversation with the bot first (
|
||||
@@ -69,7 +69,7 @@ export const NotifierTelegramForm = ({ form }: NotifierTelegramFormProps) => {
|
||||
<FormItem>
|
||||
<FormLabel>Telegram Topic ID</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="123456" />
|
||||
<Input {...field} placeholder="e.g. 123456" />
|
||||
</FormControl>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Unique identifier for the target message thread (topic) of the
|
||||
|
||||
+6
-6
@@ -23,9 +23,9 @@ export const NotifierWebhookForm = ({ form }: NotifierWebhookFormProps) => {
|
||||
name="config.webhookUrl"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Webhook URL</FormLabel>
|
||||
<FormLabel>Webhook URL *</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="https://example.com/api/webhook" />
|
||||
<Input {...field} placeholder="e.g. https://example.com/api/webhook" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -38,9 +38,9 @@ export const NotifierWebhookForm = ({ form }: NotifierWebhookFormProps) => {
|
||||
name="config.webhookSecretHeader"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Header Name (Optional)</FormLabel>
|
||||
<FormLabel>Header Name</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="X-Webhook-Secret" />
|
||||
<Input {...field} placeholder="e.g. X-Webhook-Secret" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -53,9 +53,9 @@ export const NotifierWebhookForm = ({ form }: NotifierWebhookFormProps) => {
|
||||
name="config.webhookSecret"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Secret Value (Optional)</FormLabel>
|
||||
<FormLabel>Secret Value</FormLabel>
|
||||
<FormControl>
|
||||
<PasswordInput {...field} placeholder="Secret value..." />
|
||||
<PasswordInput {...field} placeholder="e.g. webhook-secret" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
||||
+5
-5
@@ -96,9 +96,9 @@ export const StorageGoogleDriveForm = ({form}: StorageGoogleDriveFormProps) => {
|
||||
name="config.clientId"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Client ID</FormLabel>
|
||||
<FormLabel>Client ID *</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="xxxx.apps.googleusercontent.com"/>
|
||||
<Input {...field} placeholder="e.g. xxxx.apps.googleusercontent.com"/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
</FormItem>
|
||||
@@ -110,7 +110,7 @@ export const StorageGoogleDriveForm = ({form}: StorageGoogleDriveFormProps) => {
|
||||
name="config.clientSecret"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Client Secret</FormLabel>
|
||||
<FormLabel>Client Secret *</FormLabel>
|
||||
<FormControl>
|
||||
<PasswordInput {...field} />
|
||||
</FormControl>
|
||||
@@ -124,9 +124,9 @@ export const StorageGoogleDriveForm = ({form}: StorageGoogleDriveFormProps) => {
|
||||
name="config.folderId"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Folder ID</FormLabel>
|
||||
<FormLabel>Folder ID *</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} />
|
||||
<Input {...field} placeholder="e.g. 1AbCdEfGhIjKlMnOpQrStUvWxYz"/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
</FormItem>
|
||||
|
||||
+10
-10
@@ -24,9 +24,9 @@ export const StorageS3Form = ({ form }: StorageS3FormProps) => {
|
||||
name="config.endPointUrl"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Endpoint URL</FormLabel>
|
||||
<FormLabel>Endpoint URL *</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="s3.amazonaws.com" />
|
||||
<Input {...field} placeholder="e.g. s3.amazonaws.com" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -39,7 +39,7 @@ export const StorageS3Form = ({ form }: StorageS3FormProps) => {
|
||||
<FormItem>
|
||||
<FormLabel>Region</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="us-east-1" />
|
||||
<Input {...field} placeholder="e.g. us-east-1" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -50,9 +50,9 @@ export const StorageS3Form = ({ form }: StorageS3FormProps) => {
|
||||
name="config.accessKey"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Access Key</FormLabel>
|
||||
<FormLabel>Access Key *</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="A1b2C3d4E5f6G7h" />
|
||||
<Input {...field} placeholder="e.g. AKIA..." />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -63,9 +63,9 @@ export const StorageS3Form = ({ form }: StorageS3FormProps) => {
|
||||
name="config.secretKey"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Secret Key</FormLabel>
|
||||
<FormLabel>Secret Key *</FormLabel>
|
||||
<FormControl>
|
||||
<PasswordInput {...field} placeholder="A1b2C3d4E5f6G7h" />
|
||||
<PasswordInput {...field} placeholder="e.g. s3-secret-key" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -76,9 +76,9 @@ export const StorageS3Form = ({ form }: StorageS3FormProps) => {
|
||||
name="config.bucketName"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Bucket name</FormLabel>
|
||||
<FormLabel>Bucket name *</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} placeholder="portabase-dev" />
|
||||
<Input {...field} placeholder="e.g. backups-prod" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -91,7 +91,7 @@ export const StorageS3Form = ({ form }: StorageS3FormProps) => {
|
||||
<FormItem>
|
||||
<FormLabel>Port</FormLabel>
|
||||
<FormControl>
|
||||
<Input {...field} type="number" placeholder="443" />
|
||||
<Input {...field} type="number" placeholder="e.g. 443" />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import {z} from "zod";
|
||||
|
||||
export const ChannelsOrganizationSchema = z.object({
|
||||
organizations: z.array(z.string())
|
||||
organizations: z.array(z.string().uuid())
|
||||
});
|
||||
|
||||
export type ChannelsOrganizationType = z.infer<typeof ChannelsOrganizationSchema>;
|
||||
|
||||
+3
-2
@@ -5,6 +5,7 @@ import { eq } from "drizzle-orm";
|
||||
import { db } from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
|
||||
export const updateEmailSettingsAction = userAction
|
||||
.schema(
|
||||
@@ -18,9 +19,9 @@ export const updateEmailSettingsAction = userAction
|
||||
|
||||
const [updatedSettings] = await db
|
||||
.update(drizzleDb.schemas.setting)
|
||||
.set({
|
||||
.set(withUpdatedAt({
|
||||
...data,
|
||||
})
|
||||
}))
|
||||
.where(eq(drizzleDb.schemas.setting.name, name))
|
||||
.returning();
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ export const EmailFormSchema = z.object({
|
||||
smtpHost: z.string(),
|
||||
smtpPort: z.string(),
|
||||
smtpUser: z.string(),
|
||||
smtpSecure: z.boolean()
|
||||
});
|
||||
|
||||
export type EmailFormType = z.infer<typeof EmailFormSchema>;
|
||||
|
||||
@@ -30,6 +30,7 @@ import {render} from "@react-email/components";
|
||||
import EmailSettingsTest from "@/components/emails/email-settings-test";
|
||||
import {ButtonWithLoading} from "@/components/wrappers/common/button/button-with-loading";
|
||||
import {Send} from "lucide-react";
|
||||
import {Switch} from "@/components/ui/switch";
|
||||
|
||||
export type EmailFormProps = {
|
||||
defaultValues?: EmailFormType;
|
||||
@@ -178,6 +179,23 @@ export const EmailForm = (props: EmailFormProps) => {
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="smtpSecure"
|
||||
render={({field}) => (
|
||||
<FormItem>
|
||||
<FormLabel>Secure</FormLabel>
|
||||
<FormControl>
|
||||
<Switch
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage/>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<div className="flex justify-between gap-4">
|
||||
{props.defaultValues?.smtpFrom && (
|
||||
<Tooltip>
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ import {z} from "zod";
|
||||
import {
|
||||
DefaultNotificationSchema
|
||||
} from "@/components/wrappers/dashboard/admin/settings/notification/settings-notification.schema";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
|
||||
export const updateNotificationSettingsAction = userAction
|
||||
.schema(
|
||||
@@ -24,9 +25,9 @@ export const updateNotificationSettingsAction = userAction
|
||||
try {
|
||||
const [updatedSettings] = await db
|
||||
.update(drizzleDb.schemas.setting)
|
||||
.set({
|
||||
.set(withUpdatedAt({
|
||||
defaultNotificationChannelId: data.notificationChannelId ?? null,
|
||||
})
|
||||
}))
|
||||
.where(eq(drizzleDb.schemas.setting.name, name))
|
||||
.returning();
|
||||
return {
|
||||
|
||||
@@ -8,6 +8,7 @@ import {ServerActionResult} from "@/types/action-type";
|
||||
import {Setting} from "@/db/schema/01_setting";
|
||||
import {z} from "zod";
|
||||
import {DefaultStorageSchema} from "@/components/wrappers/dashboard/admin/settings/storage/settings-storage.schema";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
|
||||
export const updateStorageSettingsAction = userAction
|
||||
.schema(
|
||||
@@ -22,10 +23,10 @@ export const updateStorageSettingsAction = userAction
|
||||
try {
|
||||
const [updatedSettings] = await db
|
||||
.update(drizzleDb.schemas.setting)
|
||||
.set({
|
||||
.set(withUpdatedAt({
|
||||
defaultStorageChannelId: data.storageChannelId,
|
||||
encryption: data.encryption,
|
||||
})
|
||||
}))
|
||||
.where(eq(drizzleDb.schemas.setting.name, name))
|
||||
.returning();
|
||||
return {
|
||||
|
||||
+3
-1
@@ -6,6 +6,7 @@ import { S3FormSchema, StorageSwitchSchema } from "@/components/wrappers/dashboa
|
||||
import { eq } from "drizzle-orm";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
|
||||
export const updateS3SettingsAction = userAction
|
||||
.schema(
|
||||
@@ -19,7 +20,7 @@ export const updateS3SettingsAction = userAction
|
||||
|
||||
const [updatedSettings] = await db
|
||||
.update(drizzleDb.schemas.setting)
|
||||
.set({ ...data })
|
||||
.set(withUpdatedAt({ ...data }))
|
||||
.where(eq(drizzleDb.schemas.setting.name, name))
|
||||
.returning();
|
||||
|
||||
@@ -40,6 +41,7 @@ export const updateStorageSettingsAction = userAction
|
||||
|
||||
const [updatedSettings] = await db
|
||||
.update(drizzleDb.schemas.setting)
|
||||
// @ts-ignore
|
||||
.set({ ...data })
|
||||
.where(eq(drizzleDb.schemas.setting.name, name))
|
||||
.returning();
|
||||
|
||||
@@ -15,6 +15,7 @@ import {useAgentUpdateCheck} from "@/features/agents/hooks/use-agent-update-chec
|
||||
|
||||
export type agentCardProps = {
|
||||
data: AgentWith;
|
||||
organizationView?: boolean;
|
||||
};
|
||||
|
||||
export const AgentCard = (props: agentCardProps) => {
|
||||
@@ -34,7 +35,7 @@ export const AgentCard = (props: agentCardProps) => {
|
||||
|
||||
return (
|
||||
<Link
|
||||
href={`/dashboard/agents/${agent.id}`}
|
||||
href={props.organizationView ? `/dashboard/settings/agents/${agent.id}`: `/dashboard/agents/${agent.id}`}
|
||||
className="group block transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-xl"
|
||||
>
|
||||
<Card className="flex flex-row items-center p-4 gap-5 transition-all border-border/50 bg-card hover:bg-accent/50 hover:border-primary/50 group-hover:shadow-md overflow-hidden">
|
||||
|
||||
@@ -9,8 +9,10 @@ import {deleteAgentAction} from "@/components/wrappers/dashboard/agent/button-de
|
||||
import {useIsMobile} from "@/hooks/use-mobile";
|
||||
|
||||
export type ButtonDeleteAgentProps = {
|
||||
text?: string;
|
||||
agentId: string;
|
||||
text?: string,
|
||||
agentId: string,
|
||||
organizationId?: string
|
||||
organizationIds?: string[]
|
||||
};
|
||||
|
||||
export const ButtonDeleteAgent = (props: ButtonDeleteAgentProps) => {
|
||||
@@ -18,11 +20,11 @@ export const ButtonDeleteAgent = (props: ButtonDeleteAgentProps) => {
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: () => deleteAgentAction(props.agentId),
|
||||
mutationFn: () => deleteAgentAction({agentId: props.agentId, organizationId: props.organizationId, organizationIds: props.organizationIds}),
|
||||
onSuccess: async (result: any) => {
|
||||
if (result.data?.success) {
|
||||
toast.success(result.data.actionSuccess.message);
|
||||
router.push("/dashboard/agents");
|
||||
router.push(props.organizationId ? "/dashboard/settings?tab=agents" : "/dashboard/agents");
|
||||
} else {
|
||||
toast.error(result.data.actionError.message || "Unknown error occurred.");
|
||||
}
|
||||
@@ -35,7 +37,7 @@ export const ButtonDeleteAgent = (props: ButtonDeleteAgentProps) => {
|
||||
description="Are you sure you want to remove this agent? This action cannot be undone."
|
||||
button={{
|
||||
main: {
|
||||
text: props.text ? !isMobile ? props.text: "" : "",
|
||||
text: props.text ? !isMobile ? props.text : "" : "",
|
||||
variant: "outline",
|
||||
icon: <Trash2 color="red"/>,
|
||||
},
|
||||
|
||||
+121
-37
@@ -3,51 +3,135 @@
|
||||
import {z} from "zod";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {and, eq, inArray} from "drizzle-orm";
|
||||
import {db} from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {Agent} from "@/db/schema/08_agent";
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import {zString} from "@/lib/zod";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
|
||||
export const deleteAgentAction = userAction.schema(z.string()).action(async ({parsedInput}): Promise<ServerActionResult<Agent>> => {
|
||||
try {
|
||||
export const deleteAgentAction = userAction
|
||||
.schema(
|
||||
z.object({
|
||||
agentId: zString(),
|
||||
organizationId: zString().optional(),
|
||||
organizationIds: z.array(z.string()).optional()
|
||||
})
|
||||
)
|
||||
.action(async ({parsedInput}): Promise<ServerActionResult<Agent>> => {
|
||||
const {agentId, organizationId, organizationIds} = parsedInput;
|
||||
|
||||
// const deletedAgent: Agent[] = await db.delete(drizzleDb.schemas.agent).where(eq(drizzleDb.schemas.agent.id, parsedInput)).returning();
|
||||
try {
|
||||
let projectIds: string[] = [];
|
||||
|
||||
const uuid = uuidv4();
|
||||
const uuid = uuidv4();
|
||||
if (organizationId) {
|
||||
await db
|
||||
.delete(drizzleDb.schemas.organizationAgent)
|
||||
.where(
|
||||
and(
|
||||
eq(drizzleDb.schemas.organizationAgent.organizationId, organizationId),
|
||||
eq(drizzleDb.schemas.organizationAgent.agentId, agentId)
|
||||
)
|
||||
);
|
||||
|
||||
const updatedAgent = await db
|
||||
.update(drizzleDb.schemas.agent)
|
||||
.set({
|
||||
isArchived: true,
|
||||
slug: uuid,
|
||||
})
|
||||
.where(eq(drizzleDb.schemas.agent.id, parsedInput))
|
||||
.returning();
|
||||
const organization = await db.query.organization.findFirst({
|
||||
where: eq(drizzleDb.schemas.organization.id, organizationId),
|
||||
with: {
|
||||
projects: true,
|
||||
}
|
||||
});
|
||||
|
||||
projectIds = organization?.projects?.map(project => project.id) ?? [];
|
||||
|
||||
|
||||
if (!updatedAgent[0]) {
|
||||
throw new Error("Agent not found or update failed");
|
||||
} else if (organizationIds) {
|
||||
|
||||
const organizationsToRemoveDetails = await db.query.organization.findMany({
|
||||
where: inArray(drizzleDb.schemas.organization.id, organizationIds),
|
||||
with: {
|
||||
projects: true
|
||||
}
|
||||
});
|
||||
|
||||
projectIds = organizationsToRemoveDetails.flatMap(org =>
|
||||
org.projects.map(project => project.id)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (projectIds?.length > 0) {
|
||||
const databases = await db.query.database.findMany({
|
||||
where: (db, {inArray}) => inArray(db.projectId, projectIds),
|
||||
columns: {id: true}
|
||||
});
|
||||
|
||||
const databaseIds = databases.map(d => d.id);
|
||||
|
||||
await db
|
||||
.update(drizzleDb.schemas.database)
|
||||
.set(withUpdatedAt({
|
||||
backupPolicy: null,
|
||||
projectId: null
|
||||
}))
|
||||
.where(inArray(drizzleDb.schemas.database.projectId, projectIds))
|
||||
.execute();
|
||||
|
||||
await db.delete(drizzleDb.schemas.retentionPolicy)
|
||||
.where(inArray(drizzleDb.schemas.retentionPolicy.databaseId, databaseIds))
|
||||
.execute();
|
||||
|
||||
await db.delete(drizzleDb.schemas.alertPolicy)
|
||||
.where(inArray(drizzleDb.schemas.alertPolicy.databaseId, databaseIds))
|
||||
.execute();
|
||||
|
||||
await db.delete(drizzleDb.schemas.storagePolicy)
|
||||
.where(inArray(drizzleDb.schemas.storagePolicy.databaseId, databaseIds))
|
||||
.execute();
|
||||
}
|
||||
|
||||
|
||||
const updatedAgent = await db
|
||||
.update(drizzleDb.schemas.agent)
|
||||
.set(withUpdatedAt({
|
||||
isArchived: true,
|
||||
slug: uuid,
|
||||
deletedAt: new Date()
|
||||
}))
|
||||
.where(eq(drizzleDb.schemas.agent.id, agentId))
|
||||
.returning();
|
||||
|
||||
|
||||
if (!updatedAgent[0]) {
|
||||
return {
|
||||
success: false,
|
||||
actionError: {
|
||||
message: "Agent not found or update failed",
|
||||
status: 404,
|
||||
messageParams: {agentId: agentId},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
value: updatedAgent[0],
|
||||
actionSuccess: {
|
||||
message: "Agent has been successfully deleted.",
|
||||
messageParams: {projectId: agentId},
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
actionError: {
|
||||
message: "Failed to delete agent.",
|
||||
status: 500,
|
||||
cause: error instanceof Error ? error.message : "Unknown error",
|
||||
messageParams: {agentId: agentId},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
success: true,
|
||||
value: updatedAgent[0],
|
||||
actionSuccess: {
|
||||
message: "Agent has been successfully deleted.",
|
||||
messageParams: {projectId: parsedInput},
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
actionError: {
|
||||
message: "Failed to delete agent.",
|
||||
status: 500,
|
||||
cause: error instanceof Error ? error.message : "Unknown error",
|
||||
messageParams: {projectId: parsedInput},
|
||||
},
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ export const LoggedInButtonClient = ({ user, sessions, currentSession, accounts,
|
||||
accounts={accounts}
|
||||
providers={providers}
|
||||
>
|
||||
<SidebarMenuButton type="button" className="h-auto justify-between py-2">
|
||||
<SidebarMenuButton type="button" className="h-auto justify-between py-2" data-testid="profile-dropdown">
|
||||
<div className="flex items-center gap-2">
|
||||
<Avatar className="size-6">
|
||||
<AvatarFallback>{user.name[0].toUpperCase()}</AvatarFallback>
|
||||
|
||||
@@ -16,7 +16,7 @@ import {UpdateNotification} from "@/features/updates/components/update-notificat
|
||||
export function AppSidebar() {
|
||||
const projectName = env.PROJECT_NAME;
|
||||
return (
|
||||
<Sidebar collapsible="icon" >
|
||||
<Sidebar collapsible="icon">
|
||||
<SidebarHeader>
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem>
|
||||
@@ -32,8 +32,8 @@ export function AppSidebar() {
|
||||
<SidebarMenuCustomMain/>
|
||||
</SidebarContent>
|
||||
|
||||
<UpdateNotification />
|
||||
|
||||
<UpdateNotification/>
|
||||
|
||||
<SidebarMenu className="mb-2">
|
||||
<SidebarMenuItem className="p-2">
|
||||
<LoggedInButton/>
|
||||
|
||||
@@ -7,7 +7,8 @@ import {
|
||||
Layers,
|
||||
ChartArea,
|
||||
ShieldHalf,
|
||||
Building, UserRoundCog, Mail, PackageOpen, Logs, Megaphone, Blocks, Warehouse, BookOpen
|
||||
Building, UserRoundCog, Mail, PackageOpen, Logs, Megaphone, Blocks, Warehouse, BookOpen, Hammer,
|
||||
ChevronsLeftRightEllipsis
|
||||
} from "lucide-react";
|
||||
import {SidebarGroupItem, SidebarMenuCustomBase} from "@/components/wrappers/dashboard/common/sidebar/menu-sidebar";
|
||||
import {authClient} from "@/lib/auth/auth-client";
|
||||
@@ -32,7 +33,17 @@ export const SidebarMenuCustomMain = () => {
|
||||
const groupContent: SidebarGroupItem["group_content"] = [
|
||||
{title: "Projects", url: "/projects", icon: Layers, details: true, type: "item"},
|
||||
{title: "Statistics", url: "/statistics", icon: ChartArea, type: "item"},
|
||||
{title: "Settings", url: "/settings", icon: Settings, details: true, type: "item"}
|
||||
{title: "Settings", url: "/settings", icon: Settings, details: true, type: "item"},
|
||||
{
|
||||
title: "Tools",
|
||||
url: "/tools",
|
||||
icon: Hammer,
|
||||
details: true,
|
||||
type: "collapse",
|
||||
submenu: [
|
||||
{title: "Migration", url: "/migration", icon: ChevronsLeftRightEllipsis, type: "item"},
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -69,8 +80,8 @@ export const SidebarMenuCustomMain = () => {
|
||||
details: true,
|
||||
type: "collapse",
|
||||
submenu: [
|
||||
{ title: "Channels", url: "/notifications/channels", icon: Blocks, type: "item" },
|
||||
{ title: "Activity Logs", url: "/notifications/logs", icon: Logs, type: "item" },
|
||||
{title: "Channels", url: "/notifications/channels", icon: Blocks, type: "item"},
|
||||
{title: "Activity Logs", url: "/notifications/logs", icon: Logs, type: "item"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -80,7 +91,7 @@ export const SidebarMenuCustomMain = () => {
|
||||
details: true,
|
||||
type: "collapse",
|
||||
submenu: [
|
||||
{ title: "Channels", url: "/storages/channels", icon: Blocks, type: "item" },
|
||||
{title: "Channels", url: "/storages/channels", icon: Blocks, type: "item"},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -91,7 +102,13 @@ export const SidebarMenuCustomMain = () => {
|
||||
type: "collapse",
|
||||
submenu: [
|
||||
{title: "Users", url: "/admin/users", icon: Users, type: "item"},
|
||||
{title: "Organizations", url: "/admin/organizations", icon: Building, type: "item", details: true},
|
||||
{
|
||||
title: "Organizations",
|
||||
url: "/admin/organizations",
|
||||
icon: Building,
|
||||
type: "item",
|
||||
details: true
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -105,7 +122,7 @@ export const SidebarMenuCustomMain = () => {
|
||||
}
|
||||
|
||||
items.push(
|
||||
{
|
||||
{
|
||||
label: "Resources",
|
||||
type: "list",
|
||||
group_content: [
|
||||
|
||||
@@ -38,7 +38,7 @@ export const ImportModal = ({database}: ImportModalProps) => {
|
||||
<Separator className="mt-3 "/>
|
||||
<UploadBackupZone
|
||||
onSuccessAction={() => setOpen(false)}
|
||||
databaseId={database.id}/>
|
||||
database={database}/>
|
||||
</DialogHeader>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
@@ -9,13 +9,15 @@ import {ButtonWithLoading} from "@/components/wrappers/common/button/button-with
|
||||
import {toast} from "sonner";
|
||||
import {uploadBackupAction} from "@/components/wrappers/dashboard/database/import/upload-backup.action";
|
||||
import {Card, CardContent} from "@/components/ui/card";
|
||||
import {DatabaseWith} from "@/db/schema/07_database";
|
||||
import {getFileHeadersBasedOnDbms} from "@/utils/common";
|
||||
|
||||
type UploadRetentionZoneProps = {
|
||||
onSuccessAction?: () => void;
|
||||
databaseId: string;
|
||||
database: DatabaseWith;
|
||||
};
|
||||
|
||||
export const UploadBackupZone = ({onSuccessAction, databaseId}: UploadRetentionZoneProps) => {
|
||||
export const UploadBackupZone = ({onSuccessAction, database}: UploadRetentionZoneProps) => {
|
||||
const queryClient = useQueryClient();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -30,7 +32,7 @@ export const UploadBackupZone = ({onSuccessAction, databaseId}: UploadRetentionZ
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
formData.append("databaseId", databaseId);
|
||||
formData.append("databaseId", database.id);
|
||||
|
||||
const result = await uploadBackupAction(formData)
|
||||
|
||||
@@ -38,7 +40,7 @@ export const UploadBackupZone = ({onSuccessAction, databaseId}: UploadRetentionZ
|
||||
if (inner?.success) {
|
||||
toast.success(inner.actionSuccess?.message);
|
||||
onSuccessAction?.()
|
||||
queryClient.invalidateQueries({queryKey: ["database-data", databaseId]});
|
||||
queryClient.invalidateQueries({queryKey: ["database-data", database.id]});
|
||||
router.refresh();
|
||||
} else {
|
||||
toast.error(inner?.actionError?.message);
|
||||
@@ -47,19 +49,18 @@ export const UploadBackupZone = ({onSuccessAction, databaseId}: UploadRetentionZ
|
||||
console.error(err);
|
||||
toast.error("An error occurred while upload in the backup");
|
||||
} finally {
|
||||
queryClient.invalidateQueries({queryKey: ["database-data", databaseId]});
|
||||
queryClient.invalidateQueries({queryKey: ["database-data", database.id]});
|
||||
setIsProcessing(false);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const acceptDbImportFiles = getFileHeadersBasedOnDbms(database.dbms)
|
||||
|
||||
const fileKindDescription = Object.values(acceptDbImportFiles)
|
||||
.flat()
|
||||
.join(", ");
|
||||
|
||||
const acceptDbImportFiles: Record<string, string[]> = {
|
||||
"application/sql": [".sql"],
|
||||
"application/x-sql": [".sql"],
|
||||
"text/plain": [".sql"],
|
||||
"application/octet-stream": [".dump"],
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -67,11 +68,11 @@ export const UploadBackupZone = ({onSuccessAction, databaseId}: UploadRetentionZ
|
||||
<UploadLoader label="Uploading database backup…"/>
|
||||
) : (
|
||||
<DropZoneFile
|
||||
accept={acceptDbImportFiles}
|
||||
accept={getFileHeadersBasedOnDbms(database.dbms)}
|
||||
maxSize={2 * 1024 * 1024 * 1024}
|
||||
maxFiles={1}
|
||||
description="Import database backup"
|
||||
fileKind="Database file (.sql, .dump)"
|
||||
fileKind={`Database file (${fileKindDescription})`}
|
||||
dragMessage="Click or drag a database dump here"
|
||||
onFileDropAction={(file: File) => setFile(file)}
|
||||
/>
|
||||
@@ -86,8 +87,6 @@ export const UploadBackupZone = ({onSuccessAction, databaseId}: UploadRetentionZ
|
||||
</ButtonWithLoading>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ export function CreateOrganizationModal({
|
||||
onOpenChange(false);
|
||||
await authClient.organization.setActive({organizationSlug: result.data.value.slug});
|
||||
onSuccess?.();
|
||||
toast.success(result.data.actionSuccess?.message || "Organization Created.");
|
||||
toast.success(result.data.actionSuccess?.message);
|
||||
form.reset()
|
||||
router.replace(redirect);
|
||||
} else {
|
||||
|
||||
@@ -10,6 +10,7 @@ import {useIsMobile} from "@/hooks/use-mobile";
|
||||
|
||||
export type DeleteOrganizationButtonProps = {
|
||||
organizationSlug: string;
|
||||
disabled?: boolean
|
||||
};
|
||||
|
||||
export const DeleteOrganizationButton = (props: DeleteOrganizationButtonProps) => {
|
||||
@@ -51,6 +52,7 @@ export const DeleteOrganizationButton = (props: DeleteOrganizationButtonProps) =
|
||||
main: {
|
||||
text: !isMobile ? "Delete Organization" : "",
|
||||
variant: "outline",
|
||||
disabled: props.disabled,
|
||||
icon: <Trash2 color="red"/>,
|
||||
},
|
||||
confirm: {
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
"use client"
|
||||
|
||||
import {
|
||||
ArrowRight,
|
||||
CheckCircle2,
|
||||
Circle,
|
||||
Loader2,
|
||||
Play,
|
||||
Server,
|
||||
FolderOpen,
|
||||
HardDrive,
|
||||
} from "lucide-react"
|
||||
import {cn} from "@/lib/utils"
|
||||
import {ProjectWithDatabasesAndBackups as ProjectWith} from "@/db/schema/06_project";
|
||||
import {Backup, DatabaseWith} from "@/db/schema/07_database";
|
||||
import {ButtonWithLoading} from "@/components/wrappers/common/button/button-with-loading";
|
||||
|
||||
interface MigrationFlowProps {
|
||||
sourceProject: ProjectWith | null
|
||||
sourceDatabase: DatabaseWith | null
|
||||
selectedBackups: Backup[]
|
||||
targetProject: ProjectWith | null
|
||||
targetDatabase: DatabaseWith | null
|
||||
status: MigrationStatus
|
||||
onStartMigration: () => void
|
||||
canStart: boolean
|
||||
}
|
||||
|
||||
export type MigrationStatus = "idle" | "migrating" | "completed" | "error"
|
||||
|
||||
|
||||
export function MigrationFlow({
|
||||
sourceProject,
|
||||
sourceDatabase,
|
||||
selectedBackups,
|
||||
targetProject,
|
||||
targetDatabase,
|
||||
status,
|
||||
onStartMigration,
|
||||
canStart,
|
||||
}: MigrationFlowProps) {
|
||||
|
||||
const steps = [
|
||||
{
|
||||
id: "source-project",
|
||||
label: "Source Project",
|
||||
description: "Choose source project",
|
||||
completed: sourceProject !== null,
|
||||
active: status === "idle" && !sourceProject,
|
||||
},
|
||||
{
|
||||
id: "source-database",
|
||||
label: "Source Database",
|
||||
description: "Select database",
|
||||
completed: sourceDatabase !== null,
|
||||
active: status === "idle" && sourceProject !== null && !sourceDatabase,
|
||||
},
|
||||
{
|
||||
id: "backups",
|
||||
label: "Select Backups",
|
||||
description: "Choose backups to migrate",
|
||||
completed: selectedBackups.length > 0,
|
||||
active: status === "idle" && sourceDatabase !== null && selectedBackups.length === 0,
|
||||
},
|
||||
{
|
||||
id: "target-project",
|
||||
label: "Target Project",
|
||||
description: "Choose destination project",
|
||||
completed: targetProject !== null,
|
||||
active: status === "idle" && selectedBackups.length > 0 && !targetProject,
|
||||
},
|
||||
{
|
||||
id: "target-database",
|
||||
label: "Target Database",
|
||||
description: "Select destination database",
|
||||
completed: targetDatabase !== null,
|
||||
active: status === "idle" && targetProject !== null && !targetDatabase,
|
||||
},
|
||||
{
|
||||
id: "migrate",
|
||||
label: "Migrate Data",
|
||||
description: "Transfer to target",
|
||||
completed: status === "completed",
|
||||
active: status === "migrating",
|
||||
},
|
||||
]
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col rounded-xl border border-border bg-card">
|
||||
<div className="border-b border-border px-5 py-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10">
|
||||
<ArrowRight className="h-5 w-5 text-primary"/>
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="font-semibold text-foreground">Migration Flow</h2>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{status === "idle" && "Configure your migration"}
|
||||
{status === "migrating" && "Migration in progress..."}
|
||||
{status === "completed" && "Migration completed!"}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 overflow-y-auto p-5">
|
||||
<div className="mb-6 flex flex-col gap-3">
|
||||
{steps.map((step, index) => (
|
||||
<div key={step.id} className="flex items-start gap-3">
|
||||
<div className="flex flex-col items-center">
|
||||
<div
|
||||
className={cn(
|
||||
"flex h-7 w-7 items-center justify-center rounded-full border-2 transition-all",
|
||||
step.completed
|
||||
? "border-emerald-500 bg-emerald-500 text-white"
|
||||
: step.active
|
||||
? "border-primary bg-primary/10 text-primary"
|
||||
: "border-muted-foreground/30 bg-muted text-muted-foreground"
|
||||
)}
|
||||
>
|
||||
{step.completed ? (
|
||||
<CheckCircle2 className="h-4 w-4"/>
|
||||
) : step.active && status === "migrating" ? (
|
||||
<Loader2 className="h-3.5 w-3.5 animate-spin"/>
|
||||
) : (
|
||||
<Circle className="h-3.5 w-3.5"/>
|
||||
)}
|
||||
</div>
|
||||
{index < steps.length - 1 && (
|
||||
<div
|
||||
className={cn(
|
||||
"mt-1 h-6 w-0.5",
|
||||
step.completed ? "bg-emerald-500" : "bg-border"
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="pt-0.5">
|
||||
<p
|
||||
className={cn(
|
||||
"text-sm font-medium",
|
||||
step.completed || step.active
|
||||
? "text-foreground"
|
||||
: "text-muted-foreground"
|
||||
)}
|
||||
>
|
||||
{step.label}
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">{step.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{(sourceProject || targetProject) && (
|
||||
<div className="mb-6 rounded-lg border border-border bg-muted/30 p-4">
|
||||
<h3 className="mb-3 text-sm font-medium text-foreground">
|
||||
Migration Summary
|
||||
</h3>
|
||||
<div className="flex flex-col gap-2.5 text-sm">
|
||||
{/* Source */}
|
||||
{sourceProject && (
|
||||
<div className="flex items-start gap-2">
|
||||
<FolderOpen className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"/>
|
||||
<div className="min-w-0">
|
||||
<span className="text-muted-foreground">From: </span>
|
||||
<span className="font-medium text-foreground">
|
||||
{sourceProject.name}
|
||||
</span>
|
||||
{sourceDatabase && (
|
||||
<span className="text-muted-foreground">
|
||||
{" "}/ {sourceDatabase.name}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{selectedBackups.length > 0 && (
|
||||
<div className="flex items-center gap-2">
|
||||
<HardDrive className="h-4 w-4 text-muted-foreground"/>
|
||||
<span className="text-muted-foreground">Backups:</span>
|
||||
<span className="font-medium text-foreground">
|
||||
{selectedBackups.length}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{targetProject && (
|
||||
<div className="flex items-start gap-2">
|
||||
<Server className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"/>
|
||||
<div className="min-w-0">
|
||||
<span className="text-muted-foreground">To: </span>
|
||||
<span className="font-medium text-foreground">
|
||||
{targetProject.name}
|
||||
</span>
|
||||
{targetDatabase && (
|
||||
<span className="text-muted-foreground">
|
||||
{" "}/ {targetDatabase.name}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{status === "completed" && (
|
||||
<div className="mb-6 rounded-lg border border-emerald-500/20 bg-emerald-500/10 p-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<CheckCircle2 className="h-5 w-5 text-emerald-600"/>
|
||||
<span className="font-medium text-emerald-600">
|
||||
Migration completed successfully!
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="border-t border-border p-5">
|
||||
|
||||
<ButtonWithLoading
|
||||
className={cn(
|
||||
"flex w-full items-center justify-center gap-2 rounded-lg px-4 py-3 font-medium transition-all",
|
||||
canStart
|
||||
? "bg-primary text-primary-foreground hover:bg-primary/90"
|
||||
: "cursor-not-allowed bg-muted text-muted-foreground"
|
||||
)}
|
||||
onClick={onStartMigration}
|
||||
disabled={!canStart}
|
||||
isPending={status === "migrating"}
|
||||
size="lg"
|
||||
type="button"
|
||||
>
|
||||
|
||||
{status === "migrating" ? (
|
||||
<>
|
||||
Migrating...
|
||||
</>
|
||||
) : status === "completed" ? (
|
||||
<>
|
||||
<CheckCircle2 className="h-4 w-4"/>
|
||||
Completed
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Play className="h-4 w-4"/>
|
||||
Start Migration
|
||||
</>
|
||||
)}
|
||||
</ButtonWithLoading>
|
||||
|
||||
{!canStart && status === "idle" && (
|
||||
<p className="mt-2 text-center text-xs text-muted-foreground">
|
||||
{!sourceProject
|
||||
? "Select a source project"
|
||||
: !sourceDatabase
|
||||
? "Select a source database"
|
||||
: selectedBackups.length === 0
|
||||
? "Select at least one backup"
|
||||
: !targetProject
|
||||
? "Select a target project"
|
||||
: !targetDatabase
|
||||
? "Select a target database"
|
||||
: "Ready to start"}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
"use client"
|
||||
|
||||
import {useState, useMemo} from "react"
|
||||
import {ProjectWithDatabasesAndBackups as ProjectWith} from "@/db/schema/06_project"
|
||||
import {SourcePanel} from "@/components/wrappers/dashboard/organization/migration/source-panel"
|
||||
import {Backup, DatabaseWith} from "@/db/schema/07_database"
|
||||
import {MigrationFlow, MigrationStatus} from "@/components/wrappers/dashboard/organization/migration/migration-flow"
|
||||
import {TargetPanel} from "@/components/wrappers/dashboard/organization/migration/target-panel"
|
||||
import {useMutation} from "@tanstack/react-query";
|
||||
import {toast} from "sonner";
|
||||
import {migrationAction} from "@/components/wrappers/dashboard/organization/migration/migration.action";
|
||||
import {useRouter} from "next/navigation";
|
||||
|
||||
interface MigrationToolProps {
|
||||
projects: ProjectWith[]
|
||||
}
|
||||
|
||||
export const MigrationTool = ({projects}: MigrationToolProps) => {
|
||||
const [sourceProject, setSourceProject] = useState<ProjectWith | null>(null)
|
||||
const [sourceDatabase, setSourceDatabase] = useState<DatabaseWith | null>(null)
|
||||
const [selectedBackups, setSelectedBackups] = useState<Backup[]>([])
|
||||
const router = useRouter()
|
||||
const [targetProject, setTargetProject] = useState<ProjectWith | null>(null)
|
||||
const [targetDatabase, setTargetDatabase] = useState<DatabaseWith | null>(null)
|
||||
|
||||
const [migrationStatus, setMigrationStatus] = useState<MigrationStatus>("idle")
|
||||
const [_migrationProgress, setMigrationProgress] = useState(0)
|
||||
|
||||
const sourceDbKind = sourceDatabase?.dbms
|
||||
|
||||
const isTargetEnabled = useMemo(() => {
|
||||
return migrationStatus === "idle" &&
|
||||
sourceDatabase !== null &&
|
||||
selectedBackups.length > 0
|
||||
}, [sourceDatabase, migrationStatus, selectedBackups])
|
||||
|
||||
const filteredProjects = useMemo(() => {
|
||||
if (!sourceDbKind) return []
|
||||
|
||||
return projects.map((project) => ({
|
||||
...project,
|
||||
databases: project.databases.filter((db) => {
|
||||
const sameKind = db.dbms === sourceDbKind
|
||||
const notSource = db.id !== sourceDatabase?.id
|
||||
return sameKind && notSource
|
||||
}),
|
||||
}))
|
||||
}, [projects, sourceDbKind, sourceDatabase])
|
||||
|
||||
const handleSelectSourceProject = (project: ProjectWith | null) => {
|
||||
setSourceProject(project)
|
||||
setSourceDatabase(null)
|
||||
setSelectedBackups([])
|
||||
setTargetProject(null)
|
||||
setTargetDatabase(null)
|
||||
}
|
||||
|
||||
const handleSelectSourceDatabase = (database: DatabaseWith | null) => {
|
||||
setSourceDatabase(database)
|
||||
setSelectedBackups([])
|
||||
|
||||
if (targetDatabase && database?.dbms !== targetDatabase.dbms) {
|
||||
setTargetProject(null)
|
||||
setTargetDatabase(null)
|
||||
}
|
||||
|
||||
if (targetDatabase && database?.id === targetDatabase.id) {
|
||||
setTargetProject(null)
|
||||
setTargetDatabase(null)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSelectBackup = (backup: Backup) => {
|
||||
setSelectedBackups((prev) => {
|
||||
const isSelected = prev.some((b) => b.id === backup.id)
|
||||
if (isSelected) {
|
||||
return prev.filter((b) => b.id !== backup.id)
|
||||
}
|
||||
return [...prev, backup]
|
||||
})
|
||||
}
|
||||
|
||||
const handleSelectTargetProject = (project: ProjectWith | null) => {
|
||||
setTargetProject(project)
|
||||
setTargetDatabase(null)
|
||||
}
|
||||
|
||||
const handleSelectTargetDatabase = (database: DatabaseWith | null) => {
|
||||
setTargetDatabase(database)
|
||||
}
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: async () => {
|
||||
if (selectedBackups.length === 0 || !targetDatabase) return
|
||||
setMigrationStatus("migrating")
|
||||
|
||||
const result = await migrationAction({
|
||||
targetDatabaseId: targetDatabase?.id,
|
||||
backupIds: selectedBackups.map((backup) => backup.id)
|
||||
})
|
||||
const inner = result?.data;
|
||||
console.log(inner)
|
||||
if (inner?.success) {
|
||||
toast.success(inner.actionSuccess?.message);
|
||||
handleReset()
|
||||
router.refresh();
|
||||
} else {
|
||||
toast.error(inner?.actionError?.message);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const handleReset = () => {
|
||||
setMigrationStatus("idle")
|
||||
setMigrationProgress(0)
|
||||
setSelectedBackups([])
|
||||
setSourceProject(null)
|
||||
setSourceDatabase(null)
|
||||
setTargetProject(null)
|
||||
setTargetDatabase(null)
|
||||
}
|
||||
|
||||
const canStartMigration =
|
||||
selectedBackups.length > 0 &&
|
||||
targetDatabase !== null &&
|
||||
migrationStatus === "idle"
|
||||
|
||||
return (
|
||||
|
||||
<div className="h-full">
|
||||
<div className="flex flex-col md:grid md:grid-cols-12 gap-6 h-full">
|
||||
<div className="col-span-4">
|
||||
<SourcePanel
|
||||
projects={projects}
|
||||
selectedProject={sourceProject}
|
||||
selectedDatabase={sourceDatabase}
|
||||
selectedBackups={selectedBackups}
|
||||
onSelectProject={handleSelectSourceProject}
|
||||
onSelectDatabase={handleSelectSourceDatabase}
|
||||
onSelectBackup={handleSelectBackup}
|
||||
disabled={migrationStatus !== "idle"}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="col-span-4">
|
||||
<MigrationFlow
|
||||
sourceProject={sourceProject}
|
||||
sourceDatabase={sourceDatabase}
|
||||
selectedBackups={selectedBackups}
|
||||
targetProject={targetProject}
|
||||
targetDatabase={targetDatabase}
|
||||
status={migrationStatus}
|
||||
onStartMigration={() => mutation.mutateAsync()}
|
||||
canStart={canStartMigration}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="col-span-4 min-h-36">
|
||||
<TargetPanel
|
||||
projects={filteredProjects}
|
||||
selectedProject={targetProject}
|
||||
selectedDatabase={targetDatabase}
|
||||
onSelectProject={handleSelectTargetProject}
|
||||
onSelectDatabase={handleSelectTargetDatabase}
|
||||
disabled={!isTargetEnabled}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
"use server"
|
||||
import {userAction} from "@/lib/safe-actions/actions";
|
||||
import {ServerActionResult} from "@/types/action-type";
|
||||
import {z} from "zod";
|
||||
import {db} from "@/db";
|
||||
import * as drizzleDb from "@/db";
|
||||
import {eq, inArray} from "drizzle-orm";
|
||||
import {dispatchStorage} from "@/features/storages/dispatch";
|
||||
import {v4 as uuidv4} from "uuid";
|
||||
import {getTodayISODate} from "@/utils/date-formatting";
|
||||
import {withUpdatedAt} from "@/db/utils";
|
||||
|
||||
export const migrationAction = userAction.schema(
|
||||
z.object({
|
||||
targetDatabaseId: z.string(),
|
||||
backupIds: z.array(z.string()),
|
||||
})
|
||||
).action(async ({ parsedInput }): Promise<ServerActionResult<{}>> => {
|
||||
|
||||
const { targetDatabaseId, backupIds } = parsedInput;
|
||||
|
||||
let hasError = false;
|
||||
|
||||
try {
|
||||
|
||||
const targetDatabase = await db.query.database.findFirst({
|
||||
where: eq(drizzleDb.schemas.database.id, targetDatabaseId),
|
||||
with: {
|
||||
project: true,
|
||||
retentionPolicy: true,
|
||||
alertPolicies: true,
|
||||
storagePolicies: true
|
||||
}
|
||||
});
|
||||
|
||||
if (!targetDatabase) {
|
||||
return {
|
||||
success: false,
|
||||
actionError: {
|
||||
message: "Unable to find target database",
|
||||
status: 404,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const backups = await db.query.backup.findMany({
|
||||
where: inArray(drizzleDb.schemas.backup.id, backupIds),
|
||||
with: {
|
||||
database: true,
|
||||
storages: true
|
||||
}
|
||||
});
|
||||
|
||||
if (backups.length !== backupIds.length) {
|
||||
return {
|
||||
success: false,
|
||||
actionError: {
|
||||
message: "Some backups were not found",
|
||||
status: 400,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
backups.map(async (backup) => {
|
||||
|
||||
const [migratedBackup] = await db
|
||||
.insert(drizzleDb.schemas.backup)
|
||||
.values({
|
||||
status: "ongoing",
|
||||
databaseId: targetDatabaseId,
|
||||
fileSize: backup.fileSize,
|
||||
migrated: true,
|
||||
})
|
||||
.returning();
|
||||
|
||||
const storageResults = await Promise.allSettled(
|
||||
backup.storages.map(async (storage) => {
|
||||
|
||||
const [backupStorage] = await db
|
||||
.insert(drizzleDb.schemas.backupStorage)
|
||||
.values({
|
||||
backupId: migratedBackup.id,
|
||||
storageChannelId: storage.storageChannelId,
|
||||
status: "pending",
|
||||
})
|
||||
.returning();
|
||||
|
||||
const fileName = `${uuidv4()}.tar.gz`;
|
||||
const pathTo = `backups/${getTodayISODate()}/${fileName}`;
|
||||
|
||||
try {
|
||||
const result = await dispatchStorage(
|
||||
{
|
||||
action: "copy",
|
||||
data: {
|
||||
from: storage.path ?? "",
|
||||
to: pathTo,
|
||||
},
|
||||
metadata: {
|
||||
storageId: storage.storageChannelId,
|
||||
fileKind: "backups",
|
||||
},
|
||||
},
|
||||
undefined,
|
||||
storage.storageChannelId
|
||||
);
|
||||
|
||||
if (!result.success) {
|
||||
hasError = true;
|
||||
throw new Error("dispatchStorage failed");
|
||||
}
|
||||
|
||||
await db
|
||||
.update(drizzleDb.schemas.backupStorage)
|
||||
.set(
|
||||
withUpdatedAt({
|
||||
status: "success",
|
||||
path: pathTo,
|
||||
size: backup.fileSize,
|
||||
})
|
||||
)
|
||||
.where(eq(drizzleDb.schemas.backupStorage.id, backupStorage.id));
|
||||
|
||||
return { success: true };
|
||||
|
||||
} catch (error) {
|
||||
|
||||
hasError = true;
|
||||
|
||||
await db
|
||||
.update(drizzleDb.schemas.backupStorage)
|
||||
.set(
|
||||
withUpdatedAt({
|
||||
status: "failed",
|
||||
})
|
||||
)
|
||||
.where(eq(drizzleDb.schemas.backupStorage.id, backupStorage.id));
|
||||
|
||||
return { success: false };
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
const failed = storageResults.some(
|
||||
r => r.status === "rejected" || (r.status === "fulfilled" && !r.value.success)
|
||||
);
|
||||
|
||||
if (failed) hasError = true;
|
||||
|
||||
await db
|
||||
.update(drizzleDb.schemas.backup)
|
||||
.set(
|
||||
withUpdatedAt({
|
||||
status: failed ? "failed" : "success",
|
||||
})
|
||||
)
|
||||
.where(eq(drizzleDb.schemas.backup.id, migratedBackup.id));
|
||||
|
||||
})
|
||||
);
|
||||
|
||||
if (hasError) {
|
||||
return {
|
||||
success: false,
|
||||
actionError: {
|
||||
message: "Migration completed with errors",
|
||||
status: 500,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
value: {},
|
||||
actionSuccess: {
|
||||
message: "Backups successfully migrated.",
|
||||
messageParams: {},
|
||||
},
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
actionError: {
|
||||
message: "Migration failed unexpectedly",
|
||||
status: 500,
|
||||
cause: error instanceof Error ? error.message : "Unknown error",
|
||||
},
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,309 @@
|
||||
"use client"
|
||||
|
||||
import {
|
||||
Database,
|
||||
HardDrive,
|
||||
Calendar,
|
||||
Check,
|
||||
ChevronLeft,
|
||||
FolderOpen,
|
||||
Server,
|
||||
} from "lucide-react"
|
||||
import {cn} from "@/lib/utils"
|
||||
import {ProjectWithDatabasesAndBackups as ProjectWith} from "@/db/schema/06_project";
|
||||
import {Backup, DatabaseWith} from "@/db/schema/07_database";
|
||||
import {ScrollArea} from "@/components/ui/scroll-area";
|
||||
import {formatLocalizedDate} from "@/utils/date-formatting";
|
||||
import {formatBytes, truncateWords} from "@/utils/text";
|
||||
|
||||
type ViewState = "projects" | "databases" | "backups"
|
||||
|
||||
interface SourcePanelProps {
|
||||
projects: ProjectWith[]
|
||||
selectedProject: ProjectWith | null
|
||||
selectedDatabase: DatabaseWith | null
|
||||
selectedBackups: Backup[]
|
||||
onSelectProject: (project: ProjectWith | null) => void
|
||||
onSelectDatabase: (database: DatabaseWith | null) => void
|
||||
onSelectBackup: (backup: Backup) => void
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
export function SourcePanel({
|
||||
projects,
|
||||
selectedProject,
|
||||
selectedDatabase,
|
||||
selectedBackups,
|
||||
onSelectProject,
|
||||
onSelectDatabase,
|
||||
onSelectBackup,
|
||||
disabled,
|
||||
}: SourcePanelProps) {
|
||||
const currentView: ViewState = selectedDatabase
|
||||
? "backups"
|
||||
: selectedProject
|
||||
? "databases"
|
||||
: "projects"
|
||||
|
||||
|
||||
const handleBack = () => {
|
||||
if (currentView === "backups") {
|
||||
onSelectDatabase(null)
|
||||
} else if (currentView === "databases") {
|
||||
onSelectProject(null)
|
||||
}
|
||||
}
|
||||
|
||||
const getHeaderInfo = () => {
|
||||
if (currentView === "backups" && selectedDatabase) {
|
||||
return {
|
||||
title: selectedDatabase.name,
|
||||
subtitle: selectedDatabase.backups?.length? `${selectedBackups.length} of ${selectedDatabase.backups.length} backups selected` : "",
|
||||
icon: <Database className="h-5 w-5 text-primary"/>,
|
||||
}
|
||||
}
|
||||
if (currentView === "databases" && selectedProject) {
|
||||
return {
|
||||
title: selectedProject.name,
|
||||
subtitle: `${selectedProject.databases.length} database${selectedProject.databases.length !== 1 ? "s" : ""} available`,
|
||||
icon: <FolderOpen className="h-5 w-5 text-primary"/>,
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: "Source",
|
||||
subtitle: "Select a project to start",
|
||||
icon: <FolderOpen className="h-5 w-5 text-primary"/>,
|
||||
}
|
||||
}
|
||||
|
||||
const headerInfo = getHeaderInfo()
|
||||
|
||||
return (
|
||||
<div className="rounded-xl border border-border bg-card h-full flex flex-col overflow-hidden">
|
||||
<div className="border-b border-border px-5 py-4">
|
||||
<div className="flex items-center gap-3">
|
||||
{currentView !== "projects" ? (
|
||||
<button
|
||||
onClick={handleBack}
|
||||
disabled={disabled}
|
||||
className="flex h-9 w-9 items-center justify-center rounded-lg bg-secondary transition-colors hover:bg-secondary/80 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
<ChevronLeft className="h-5 w-5 text-secondary-foreground"/>
|
||||
</button>
|
||||
) : (
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10">
|
||||
{headerInfo.icon}
|
||||
</div>
|
||||
)}
|
||||
<div className="min-w-0 flex-1">
|
||||
<h2 className="truncate font-semibold text-foreground">
|
||||
{headerInfo.title}
|
||||
</h2>
|
||||
<p className="text-sm text-muted-foreground">{headerInfo.subtitle}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{currentView !== "projects" && (
|
||||
<div className="mt-3 flex items-center gap-1.5 text-xs text-muted-foreground">
|
||||
<button
|
||||
onClick={() => {
|
||||
onSelectDatabase(null)
|
||||
onSelectProject(null)
|
||||
}}
|
||||
disabled={disabled}
|
||||
className="hover:text-foreground disabled:opacity-50"
|
||||
>
|
||||
Projects
|
||||
</button>
|
||||
{selectedProject && (
|
||||
<>
|
||||
<span>/</span>
|
||||
<button
|
||||
onClick={() => onSelectDatabase(null)}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"truncate hover:text-foreground disabled:opacity-50",
|
||||
currentView === "databases" && "text-foreground"
|
||||
)}
|
||||
>
|
||||
{selectedProject.name}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
{selectedDatabase && (
|
||||
<>
|
||||
<span>/</span>
|
||||
<span className="truncate text-foreground">
|
||||
{selectedDatabase.name}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ScrollArea
|
||||
// Do not remove the radix scroll
|
||||
className="w-full flex-1 [&>[data-radix-scroll-area-viewport]]:max-h-[calc(100vh-320px)]"
|
||||
>
|
||||
<div className="p-4">
|
||||
{currentView === "projects" && (
|
||||
<div className="flex flex-col gap-2">
|
||||
{projects.length === 0 ? (
|
||||
<div
|
||||
className="flex flex-col items-center justify-center rounded-lg border border-dashed border-border p-6 text-center">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
No projects available
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
projects.map((project) => (
|
||||
<button
|
||||
key={project.id}
|
||||
onClick={() => onSelectProject(project)}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"group w-full rounded-lg border border-border bg-card p-4 text-left transition-all",
|
||||
"hover:border-primary/50 hover:bg-accent/50",
|
||||
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||
disabled && "cursor-not-allowed opacity-50"
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
<div
|
||||
className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted">
|
||||
<Server className="h-5 w-5 text-muted-foreground"/>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="truncate font-medium text-foreground">
|
||||
{truncateWords(project.name, 6)}
|
||||
</h3>
|
||||
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
{project.databases.length} database
|
||||
{project.databases.length !== 1 ? "s" : ""}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<ChevronLeft
|
||||
className="h-5 w-5 rotate-180 text-muted-foreground transition-transform group-hover:translate-x-1"/>
|
||||
</div>
|
||||
</button>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{currentView === "databases" && selectedProject && (
|
||||
<div className="flex flex-col gap-2">
|
||||
{selectedProject.databases.length === 0 ? (
|
||||
<div className="py-8 text-center">
|
||||
<Database className="mx-auto h-10 w-10 text-muted-foreground/50"/>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
No databases in this project
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
selectedProject.databases.map((database) => (
|
||||
<button
|
||||
key={database.id}
|
||||
onClick={() => onSelectDatabase(database)}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"group w-full rounded-lg border border-border bg-card p-4 text-left transition-all",
|
||||
"hover:border-primary/50 hover:bg-accent/50",
|
||||
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||
disabled && "cursor-not-allowed opacity-50"
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
<div
|
||||
className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted">
|
||||
<Database className="h-5 w-5 text-muted-foreground"/>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="truncate font-medium text-foreground">
|
||||
{truncateWords(database.name, 6)}
|
||||
</h3>
|
||||
<p className="mt-0.5 text-sm text-muted-foreground">
|
||||
{database.dbms}
|
||||
</p>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
{database?.backups?.length} backup
|
||||
{database?.backups?.length !== 1 ? "s" : ""} available
|
||||
</p>
|
||||
</div>
|
||||
<ChevronLeft
|
||||
className="h-5 w-5 rotate-180 text-muted-foreground transition-transform group-hover:translate-x-1"/>
|
||||
</div>
|
||||
</button>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{currentView === "backups" && selectedDatabase && (
|
||||
<div className="flex flex-col gap-2">
|
||||
{selectedDatabase?.backups?.length === 0 ? (
|
||||
<div className="py-8 text-center">
|
||||
<HardDrive className="mx-auto h-10 w-10 text-muted-foreground/50"/>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
No backups available for this database
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
selectedDatabase?.backups?.map((backup) => {
|
||||
const isSelected = selectedBackups.some((b) => b.id === backup.id)
|
||||
return (
|
||||
<button
|
||||
key={backup.id}
|
||||
onClick={() => onSelectBackup(backup)}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"group relative w-full rounded-lg border p-4 text-left transition-all",
|
||||
"hover:border-primary/50 hover:bg-accent/50",
|
||||
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||
isSelected
|
||||
? "border-primary bg-primary/5"
|
||||
: "border-border bg-card",
|
||||
disabled && "cursor-not-allowed opacity-50"
|
||||
)}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"absolute right-3 top-3 flex h-5 w-5 items-center justify-center rounded-full border-2 transition-all",
|
||||
isSelected
|
||||
? "border-primary bg-primary"
|
||||
: "border-muted-foreground/30 bg-transparent"
|
||||
)}
|
||||
>
|
||||
{isSelected && (
|
||||
<Check className="h-3 w-3 text-primary-foreground"/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mb-3 pr-8">
|
||||
<h3 className="font-medium text-foreground">{backup.id}</h3>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-2 text-xs">
|
||||
<div className="flex items-center gap-1.5 text-muted-foreground">
|
||||
<HardDrive className="h-3.5 w-3.5"/>
|
||||
<span>{formatBytes(backup.fileSize)}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5 text-muted-foreground">
|
||||
<Calendar className="h-3.5 w-3.5"/>
|
||||
<span>{ formatLocalizedDate(backup.createdAt)}</span>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
)
|
||||
})
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
"use client"
|
||||
|
||||
import {
|
||||
Database,
|
||||
Check,
|
||||
ChevronLeft,
|
||||
FolderOpen,
|
||||
Server,
|
||||
} from "lucide-react"
|
||||
import {cn} from "@/lib/utils"
|
||||
import {ProjectWithDatabasesAndBackups as ProjectWith} from "@/db/schema/06_project";
|
||||
import {DatabaseWith} from "@/db/schema/07_database";
|
||||
import {ScrollArea} from "@/components/ui/scroll-area";
|
||||
import {truncateWords} from "@/utils/text";
|
||||
|
||||
type ViewState = "projects" | "databases"
|
||||
|
||||
interface TargetPanelProps {
|
||||
projects: ProjectWith[]
|
||||
selectedProject: ProjectWith | null
|
||||
selectedDatabase: DatabaseWith | null
|
||||
onSelectProject: (project: ProjectWith | null) => void
|
||||
onSelectDatabase: (database: DatabaseWith | null) => void
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
export function TargetPanel({
|
||||
projects,
|
||||
selectedProject,
|
||||
selectedDatabase,
|
||||
onSelectProject,
|
||||
onSelectDatabase,
|
||||
disabled,
|
||||
}: TargetPanelProps) {
|
||||
const currentView: ViewState = selectedProject ? "databases" : "projects"
|
||||
|
||||
const handleBack = () => {
|
||||
onSelectDatabase(null)
|
||||
onSelectProject(null)
|
||||
}
|
||||
|
||||
const getHeaderInfo = () => {
|
||||
if (selectedProject) {
|
||||
return {
|
||||
title: selectedProject.name,
|
||||
subtitle: selectedDatabase
|
||||
? selectedDatabase.name
|
||||
: "Select a target database",
|
||||
icon: <FolderOpen className="h-5 w-5 text-primary"/>,
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: "Target",
|
||||
subtitle: "Select destination project",
|
||||
icon: <Server className="h-5 w-5 text-primary"/>,
|
||||
}
|
||||
}
|
||||
|
||||
const headerInfo = getHeaderInfo()
|
||||
|
||||
return (
|
||||
<div className="rounded-xl border border-border bg-card h-full flex flex-col overflow-hidden">
|
||||
<div className="border-b border-border px-5 py-4">
|
||||
<div className="flex items-center gap-3">
|
||||
{currentView !== "projects" ? (
|
||||
<button
|
||||
onClick={handleBack}
|
||||
disabled={disabled}
|
||||
className="flex h-9 w-9 items-center justify-center rounded-lg bg-secondary transition-colors hover:bg-secondary/80 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
<ChevronLeft className="h-5 w-5 text-secondary-foreground"/>
|
||||
</button>
|
||||
) : (
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10">
|
||||
{headerInfo.icon}
|
||||
</div>
|
||||
)}
|
||||
<div className="min-w-0 flex-1">
|
||||
<h2 className="truncate font-semibold text-foreground">
|
||||
{headerInfo.title}
|
||||
</h2>
|
||||
<p className="text-sm text-muted-foreground">{headerInfo.subtitle}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{currentView !== "projects" && (
|
||||
<div className="mt-3 flex items-center gap-1.5 text-xs text-muted-foreground">
|
||||
<button
|
||||
onClick={handleBack}
|
||||
disabled={disabled}
|
||||
className="hover:text-foreground disabled:opacity-50"
|
||||
>
|
||||
Projects
|
||||
</button>
|
||||
{selectedProject && (
|
||||
<>
|
||||
<span>/</span>
|
||||
<span className="truncate text-foreground">
|
||||
{selectedProject.name}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ScrollArea
|
||||
// Do not remove the radix scroll
|
||||
className="w-full flex-1 [&>[data-radix-scroll-area-viewport]]:max-h-[calc(100vh-320px)]"
|
||||
>
|
||||
<div className="p-4">
|
||||
{currentView === "projects" && (
|
||||
<div className="flex flex-col gap-2">
|
||||
{projects.map((project) => (
|
||||
<button
|
||||
key={project.id}
|
||||
onClick={() => onSelectProject(project)}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"group w-full rounded-lg border border-border bg-card p-4 text-left transition-all",
|
||||
"hover:border-primary/50 hover:bg-accent/50",
|
||||
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||
disabled && "cursor-not-allowed opacity-50"
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
<div
|
||||
className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted">
|
||||
<Server className="h-5 w-5 text-muted-foreground"/>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="truncate font-medium text-foreground">
|
||||
{truncateWords(project.name, 6)}
|
||||
</h3>
|
||||
<div className="mt-1 flex items-center gap-2">
|
||||
</div>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
{project.databases.length} database
|
||||
{project.databases.length !== 1 ? "s" : ""}
|
||||
</p>
|
||||
</div>
|
||||
<ChevronLeft
|
||||
className="h-5 w-5 rotate-180 text-muted-foreground transition-transform group-hover:translate-x-1"/>
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{currentView === "databases" && selectedProject && (
|
||||
<div className="flex flex-col gap-2">
|
||||
{selectedProject.databases.length === 0 ? (
|
||||
<div className="py-8 text-center">
|
||||
<Database className="mx-auto h-10 w-10 text-muted-foreground/50"/>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
No databases in this project
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
selectedProject.databases.map((database) => {
|
||||
const isSelected = selectedDatabase?.id === database.id
|
||||
|
||||
return (
|
||||
<button
|
||||
key={database.id}
|
||||
onClick={() => onSelectDatabase(database)}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"group relative w-full rounded-lg border p-4 text-left transition-all",
|
||||
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||
isSelected
|
||||
? "border-primary bg-primary/5"
|
||||
: "border-border bg-card",
|
||||
(disabled) && "cursor-not-allowed opacity-50"
|
||||
)}
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
"absolute right-3 top-3 flex h-5 w-5 items-center justify-center rounded-full border-2 transition-all",
|
||||
isSelected
|
||||
? "border-primary bg-primary"
|
||||
: "border-muted-foreground/30 bg-transparent"
|
||||
)}
|
||||
>
|
||||
{isSelected && (
|
||||
<Check className="h-3 w-3 text-primary-foreground"/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex items-start gap-3 pr-8">
|
||||
<div
|
||||
className="flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted">
|
||||
<Database className="h-5 w-5 text-muted-foreground"/>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="truncate font-medium text-foreground">
|
||||
{database.name}
|
||||
</h3>
|
||||
<p className="mt-0.5 text-sm text-muted-foreground">
|
||||
{database.dbms}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
)
|
||||
})
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -64,8 +64,8 @@ export function OrganizationCombobox() {
|
||||
onSuccess={handleReload}
|
||||
onOpenChange={setOpenModal}
|
||||
/>
|
||||
<DropdownMenu open={isOpen} onOpenChange={setIsOpen}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<DropdownMenu open={isOpen} onOpenChange={setIsOpen} >
|
||||
<DropdownMenuTrigger data-testid="organization-dropdown" asChild>
|
||||
<SidebarMenuButton
|
||||
size="lg"
|
||||
className={cn(
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
import {OrganizationWithMembers} from "@/db/schema/03_organization";
|
||||
import {cn} from "@/lib/utils";
|
||||
import {Agent} from "@/db/schema/08_agent";
|
||||
import {CardsWithPagination} from "@/components/wrappers/common/cards-with-pagination";
|
||||
import {AgentCard} from "@/components/wrappers/dashboard/agent/agent-card/agent-card";
|
||||
import {AgentDialog} from "@/features/agents/components/agent.dialog";
|
||||
|
||||
export type OrganizationAgentsTabProps = {
|
||||
organization: OrganizationWithMembers;
|
||||
agents: Agent[];
|
||||
};
|
||||
|
||||
export const OrganizationAgentsTab = ({
|
||||
organization,
|
||||
agents,
|
||||
}: OrganizationAgentsTabProps) => {
|
||||
|
||||
const hasAgent = agents.length > 0;
|
||||
return (
|
||||
<div className="flex flex-col gap-y-6 h-full py-4">
|
||||
<div className="h-full flex flex-col gap-y-6">
|
||||
<div className={cn("hidden flex-row justify-between items-start", hasAgent && "flex")}>
|
||||
<div className="max-w-2xl ">
|
||||
<h3 className="text-xl font-semibold text-balance mb-1">
|
||||
Agent Settings
|
||||
</h3>
|
||||
</div>
|
||||
<AgentDialog organization={organization} typeTrigger="create"/>
|
||||
</div>
|
||||
{hasAgent ? (
|
||||
<CardsWithPagination data={agents} organizationView={true} cardItem={AgentCard} cardsPerPage={4} numberOfColumns={1}/>
|
||||
) : (
|
||||
<AgentDialog organization={organization} typeTrigger="empty"/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
-5
@@ -29,11 +29,6 @@ export const OrganizationNotifiersTab = ({
|
||||
Notification Settings
|
||||
</h3>
|
||||
</div>
|
||||
{/*<NotifierAddEditModal*/}
|
||||
{/* organization={organization}*/}
|
||||
{/* open={isAddModalOpen}*/}
|
||||
{/* onOpenChangeAction={setIsAddModalOpen}*/}
|
||||
{/*/>*/}
|
||||
<ChannelAddEditModal
|
||||
kind={kind}
|
||||
organization={organization}
|
||||
|
||||
@@ -16,22 +16,32 @@ import {
|
||||
import {
|
||||
OrganizationStoragesTab
|
||||
} from "@/components/wrappers/dashboard/organization/tabs/organization-channels-tab/organization-storages-tab";
|
||||
import {
|
||||
OrganizationAgentsTab
|
||||
} from "@/components/wrappers/dashboard/organization/tabs/organization-channels-tab/organization-agents-tab";
|
||||
import {Agent} from "@/db/schema/08_agent";
|
||||
|
||||
export type OrganizationTabsProps = {
|
||||
organization: OrganizationWithMembers;
|
||||
notificationChannels: NotificationChannel[];
|
||||
storageChannels: StorageChannel[];
|
||||
activeMember: MemberWithUser
|
||||
activeMember: MemberWithUser;
|
||||
agents: Agent[]
|
||||
};
|
||||
|
||||
export const OrganizationTabs = ({activeMember, organization, notificationChannels, storageChannels}: OrganizationTabsProps) => {
|
||||
export const OrganizationTabs = ({
|
||||
activeMember,
|
||||
organization,
|
||||
notificationChannels,
|
||||
storageChannels,
|
||||
agents
|
||||
}: OrganizationTabsProps) => {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const [tab, setTab] = useState<string>(() => searchParams.get("tab") ?? "users");
|
||||
|
||||
const {
|
||||
canManageUsers,
|
||||
canManageNotifications,
|
||||
canManageStorages
|
||||
} = useOrganizationPermissions(activeMember);
|
||||
@@ -71,6 +81,12 @@ export const OrganizationTabs = ({activeMember, organization, notificationChanne
|
||||
>
|
||||
Storages
|
||||
</TabsTrigger>
|
||||
<TabsTrigger
|
||||
className="w-full"
|
||||
value="agents"
|
||||
>
|
||||
Agents
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent className="h-full" value="users">
|
||||
<SettingsOrganizationMembersTable organization={organization}/>
|
||||
@@ -87,6 +103,12 @@ export const OrganizationTabs = ({activeMember, organization, notificationChanne
|
||||
storageChannels={storageChannels}
|
||||
/>
|
||||
</TabsContent>
|
||||
<TabsContent className="h-full" value="agents">
|
||||
<OrganizationAgentsTab
|
||||
organization={organization}
|
||||
agents={agents}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
:
|
||||
<SettingsOrganizationMembersTable organization={organization}/>
|
||||
|
||||
@@ -72,7 +72,7 @@ export const AvatarWithUpload = (props: AvatarWithUploadProps) => {
|
||||
|
||||
<Avatar className="w-24 h-24 lg:w-32 lg:h-32 border-4 border-muted/20">
|
||||
<AvatarImage className="object-cover" src={user.image || undefined}/>
|
||||
<AvatarFallback className="text-3xl">{user.name.charAt(0)}</AvatarFallback>
|
||||
<AvatarFallback className="text-3xl">{user.name.charAt(0).toUpperCase()}</AvatarFallback>
|
||||
</Avatar>
|
||||
|
||||
<div
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user