Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions webapp/packages/core-blocks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@

export * from './AuthenticationProviderLoader.js';
export * from './useAuthenticationAction.js';
export * from './CommonDialog/CommonDialog/CommonDialogBody.js';

Check failure on line 13 in webapp/packages/core-blocks/src/index.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Don't import/export .tsx files from .ts files directly, use React.lazy()
export * from './CommonDialog/CommonDialog/CommonDialogFooter.js';

Check failure on line 14 in webapp/packages/core-blocks/src/index.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Don't import/export .tsx files from .ts files directly, use React.lazy()
export * from './CommonDialog/CommonDialog/CommonDialogHeader.js';

Check failure on line 15 in webapp/packages/core-blocks/src/index.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Don't import/export .tsx files from .ts files directly, use React.lazy()
export * from './CommonDialog/CommonDialog/CommonDialogWrapper.js';

Check failure on line 16 in webapp/packages/core-blocks/src/index.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Don't import/export .tsx files from .ts files directly, use React.lazy()
export * from './CommonDialog/ConfirmationDialog.js';

Check failure on line 17 in webapp/packages/core-blocks/src/index.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Don't import/export .tsx files from .ts files directly, use React.lazy()
export { default as ConfirmationDialogStyles } from './CommonDialog/ConfirmationDialog.module.css';
export * from './CommonDialog/ConfirmationDialogDelete.js';

Check failure on line 19 in webapp/packages/core-blocks/src/index.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Don't import/export .tsx files from .ts files directly, use React.lazy()
export * from './CommonDialog/RenameDialog.js';

Check failure on line 20 in webapp/packages/core-blocks/src/index.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Don't import/export .tsx files from .ts files directly, use React.lazy()
export * from './CommonDialog/DialogsPortal.js';

Check failure on line 21 in webapp/packages/core-blocks/src/index.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Don't import/export .tsx files from .ts files directly, use React.lazy()
export * from './ExportImageDialog/ExportImageDialogLazy.js';
export * from './ExportImageDialog/ExportImageFormats.js';

export * from './ErrorDetailsDialog/ErrorDetailsDialog.js';

Check failure on line 25 in webapp/packages/core-blocks/src/index.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Don't import/export .tsx files from .ts files directly, use React.lazy()

export * from './ComponentsRegistry/CRegistryLoader.js';
export * from './ComponentsRegistry/registry.js';

Check failure on line 28 in webapp/packages/core-blocks/src/index.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

Don't import/export .tsx files from .ts files directly, use React.lazy()
export * from './ComponentsRegistry/CRegistryList.js';
export * from './ComponentsRegistry/IComponentsTreeNodeValidator.js';
export * from './ComponentsRegistry/useParentProps.js';
Expand Down Expand Up @@ -262,3 +262,4 @@
export * from './ObjectPropertyInfo/getObjectPropertyDefaults.js';
export * from './useVisible.js';
export * from './SAVED_VALUE_INDICATOR.js';
export * from './useQuery.js';
52 changes: 52 additions & 0 deletions webapp/packages/core-blocks/src/useQuery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/

import { useState, useEffect, useRef, useLayoutEffect } from 'react';

interface QueryState<T> {
data: T | null;
loading: boolean;
error: Error | null;
}

/** We can use this if we don’t have ILoadableState and we fetch data that is not supposed to be kept in the resource */
export function useQuery<T>(queryFn: () => Promise<T>, deps: any[] = []): QueryState<T> {
const [state, setState] = useState<QueryState<T>>({
data: null,
loading: true,
Comment thread
devnaumov marked this conversation as resolved.
Outdated
error: null,
});

const abortRef = useRef<AbortController | null>(null);
const queryFnRef = useRef(queryFn);

useLayoutEffect(() => {
queryFnRef.current = queryFn;
}, [queryFn]);

useEffect(() => {
abortRef.current?.abort();
abortRef.current = new AbortController();
Comment thread
Wroud marked this conversation as resolved.
Outdated

queryFnRef
.current()
.then(data => setState({ data, loading: false, error: null }))
.catch(error => {
if (error.name === 'AbortError') {
Comment thread
devnaumov marked this conversation as resolved.
Outdated
setState(prev => ({ ...prev, loading: false }));
return;
}

setState({ data: null, loading: false, error });
});

return () => abortRef.current?.abort();
}, deps);

Check warning on line 49 in webapp/packages/core-blocks/src/useQuery.ts

View workflow job for this annotation

GitHub Actions / Frontend / Lint

React Hook useEffect was passed a dependency list that is not an array literal. This means we can't statically verify whether you've passed the correct dependencies

return state;
}
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export default [
['ui_not_selected', 'Not selected'],
['ui_reset', 'Reset'],
['ui_documentaion', 'Documentation'],
['ui_deny', 'Deny'],
['ui_allow', 'Allow'],

['root_permission_denied', "You don't have permissions"],
['root_permission_no_permission', "You don't have permission for this action"],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export default [
['ui_not_selected', 'Not selected'],
['ui_reset', 'Reset'],
['ui_documentaion', 'Documentation'],
['ui_deny', 'Refuser'],
['ui_allow', 'Autoriser'],

['root_permission_denied', "Vous n'avez pas les permissions"],
['root_permission_no_permission', "Vous n'avez pas la permission pour cette action"],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ export default [
['ui_not_selected', 'Not selected'],
['ui_reset', 'Reset'],
['ui_documentaion', 'Documentation'],
['ui_deny', 'Nega'],
['ui_allow', 'Consenti'],

['root_permission_denied', 'Non hai i permessi'],
['app_root_session_expire_warning_title', 'La sessione sta per scadere'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export default [
['ui_not_selected', 'Не выбрано'],
['ui_reset', 'Сбросить'],
['ui_documentaion', 'Документация'],
['ui_deny', 'Отклонить'],
['ui_allow', 'Разрешить'],

['root_permission_denied', 'Отказано в доступе'],
['root_permission_no_permission', 'У вас нет разрешения на это действие'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/vi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export default [
['ui_not_selected', 'Not selected'],
['ui_reset', 'Reset'],
['ui_documentaion', 'Tài liệu'],
['ui_deny', 'Từ chối'],
['ui_allow', 'Cho phép'],

['root_permission_denied', 'Bạn không có quyền'],
['root_permission_no_permission', 'Bạn không có quyền thực hiện hành động này'],
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-localization/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export default [
['ui_not_selected', 'Not selected'],
['ui_reset', 'Reset'],
['ui_documentaion', '文档'],
['ui_deny', '拒绝'],
['ui_allow', '允许'],

['root_permission_denied', '您没有权限'],
['root_permission_no_permission', '您没有权限执行此操作'],
Expand Down
Loading