diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 13e6372..96b5f73 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,13 @@ repos: files: ^frontend/.*\.(ts|tsx|js|jsx)$ pass_filenames: false + - id: frontend-build + name: Frontend Build + entry: bash -c "cd frontend && npm run build" + language: system + files: ^frontend/.*\.(ts|tsx|js|jsx|json|css)$ + pass_filenames: false + # Backend checks - repo: local hooks: diff --git a/frontend/src/features/databases/ui/DatabaseComponent.tsx b/frontend/src/features/databases/ui/DatabaseComponent.tsx index 2d54d2e..823cbd9 100644 --- a/frontend/src/features/databases/ui/DatabaseComponent.tsx +++ b/frontend/src/features/databases/ui/DatabaseComponent.tsx @@ -3,6 +3,7 @@ import { useRef, useState } from 'react'; import { useEffect } from 'react'; import { type Database, databaseApi } from '../../../entity/databases'; +import type { UserProfile } from '../../../entity/users'; import { BackupsComponent } from '../../backups'; import { HealthckeckAttemptsComponent } from '../../healthcheck'; import { DatabaseConfigComponent } from './DatabaseConfigComponent'; @@ -10,6 +11,7 @@ import { DatabaseConfigComponent } from './DatabaseConfigComponent'; interface Props { contentHeight: number; databaseId: string; + user: UserProfile; onDatabaseChanged: (database: Database) => void; onDatabaseDeleted: () => void; isCanManageDBs: boolean; @@ -18,6 +20,7 @@ interface Props { export const DatabaseComponent = ({ contentHeight, databaseId, + user, onDatabaseChanged, onDatabaseDeleted, isCanManageDBs, @@ -68,6 +71,7 @@ export const DatabaseComponent = ({ {currentTab === 'config' && ( void; onDatabaseChanged: (database: Database) => void; onDatabaseDeleted: () => void; @@ -33,6 +35,7 @@ interface Props { export const DatabaseConfigComponent = ({ database, + user, setDatabase, onDatabaseChanged, onDatabaseDeleted, @@ -311,6 +314,7 @@ export const DatabaseConfigComponent = ({ {isEditBackupConfig ? ( { setIsEditBackupConfig(false); @@ -464,6 +468,7 @@ export const DatabaseConfigComponent = ({ {isShowTransferDialog && ( setIsShowTransferDialog(false)} onTransferred={() => { diff --git a/frontend/src/features/databases/ui/DatabaseTransferDialogComponent.tsx b/frontend/src/features/databases/ui/DatabaseTransferDialogComponent.tsx index 521d967..711dbc6 100644 --- a/frontend/src/features/databases/ui/DatabaseTransferDialogComponent.tsx +++ b/frontend/src/features/databases/ui/DatabaseTransferDialogComponent.tsx @@ -8,6 +8,7 @@ import { type Database, databaseApi } from '../../../entity/databases'; import type { Notifier } from '../../../entity/notifiers'; import { notifierApi } from '../../../entity/notifiers'; import { type Storage, getStorageLogoFromType, storageApi } from '../../../entity/storages'; +import type { UserProfile } from '../../../entity/users'; import { type WorkspaceResponse, workspaceApi } from '../../../entity/workspaces'; import { ToastHelper } from '../../../shared/toast'; import { EditNotifierComponent } from '../../notifiers/ui/edit/EditNotifierComponent'; @@ -15,6 +16,7 @@ import { EditStorageComponent } from '../../storages/ui/edit/EditStorageComponen interface Props { database: Database; + user: UserProfile; currentStorageId?: string; onClose: () => void; onTransferred: () => void; @@ -28,6 +30,7 @@ interface NotifierUsageInfo { export const DatabaseTransferDialogComponent = ({ database, + user, currentStorageId, onClose, onTransferred, @@ -419,6 +422,7 @@ export const DatabaseTransferDialogComponent = ({ setIsShowCreateStorage(false)} diff --git a/frontend/src/features/databases/ui/DatabasesComponent.tsx b/frontend/src/features/databases/ui/DatabasesComponent.tsx index 0b3c351..1e9e2c3 100644 --- a/frontend/src/features/databases/ui/DatabasesComponent.tsx +++ b/frontend/src/features/databases/ui/DatabasesComponent.tsx @@ -3,6 +3,7 @@ import { useEffect, useState } from 'react'; import { databaseApi } from '../../../entity/databases'; import type { Database } from '../../../entity/databases'; +import type { UserProfile } from '../../../entity/users'; import type { WorkspaceResponse } from '../../../entity/workspaces'; import { useIsMobile } from '../../../shared/hooks'; import { CreateDatabaseComponent } from './CreateDatabaseComponent'; @@ -12,12 +13,13 @@ import { DatabaseComponent } from './DatabaseComponent'; interface Props { contentHeight: number; workspace: WorkspaceResponse; + user: UserProfile; isCanManageDBs: boolean; } const SELECTED_DATABASE_STORAGE_KEY = 'selectedDatabaseId'; -export const DatabasesComponent = ({ contentHeight, workspace, isCanManageDBs }: Props) => { +export const DatabasesComponent = ({ contentHeight, workspace, user, isCanManageDBs }: Props) => { const isMobile = useIsMobile(); const [isLoading, setIsLoading] = useState(true); const [databases, setDatabases] = useState([]); @@ -157,6 +159,7 @@ export const DatabasesComponent = ({ contentHeight, workspace, isCanManageDBs }: { loadDatabases(); }} @@ -185,6 +188,7 @@ export const DatabasesComponent = ({ contentHeight, workspace, isCanManageDBs }:
{ loadDatabases(false, databaseId); diff --git a/frontend/src/pages/OauthStorageComponent.tsx b/frontend/src/pages/OauthStorageComponent.tsx index 2dbefde..29b279d 100644 --- a/frontend/src/pages/OauthStorageComponent.tsx +++ b/frontend/src/pages/OauthStorageComponent.tsx @@ -4,10 +4,13 @@ import { useEffect, useState } from 'react'; import { GOOGLE_DRIVE_OAUTH_REDIRECT_URL } from '../constants'; import { type Storage, StorageType } from '../entity/storages'; import type { StorageOauthDto } from '../entity/storages/models/StorageOauthDto'; +import type { UserProfile } from '../entity/users'; +import { userApi } from '../entity/users'; import { EditStorageComponent } from '../features/storages/ui/edit/EditStorageComponent'; export function OauthStorageComponent() { const [storage, setStorage] = useState(); + const [user, setUser] = useState(); const exchangeGoogleOauthCode = async (oauthDto: StorageOauthDto) => { if (!oauthDto.storage.googleDriveStorage) { @@ -73,6 +76,13 @@ export function OauthStorageComponent() { }; useEffect(() => { + userApi + .getCurrentUser() + .then(setUser) + .catch(() => { + window.location.href = '/'; + }); + const urlParams = new URLSearchParams(window.location.search); // Attempt 1: Check for the 'oauthDto' param (Third-party/Legacy way) @@ -116,7 +126,7 @@ export function OauthStorageComponent() { alert('OAuth param not found. Ensure the redirect URL is configured correctly.'); }, []); - if (!storage) { + if (!storage || !user) { return (
@@ -140,6 +150,7 @@ export function OauthStorageComponent() { {}} isShowName={false} diff --git a/frontend/src/widgets/main/MainScreenComponent.tsx b/frontend/src/widgets/main/MainScreenComponent.tsx index f95ccad..2580c4c 100644 --- a/frontend/src/widgets/main/MainScreenComponent.tsx +++ b/frontend/src/widgets/main/MainScreenComponent.tsx @@ -341,6 +341,7 @@ export const MainScreenComponent = () => {