Merge pull request #73 from dbeaver/feat-data-refresh

chore: code cleanup
This commit is contained in:
Serge Rider
2020-06-06 20:28:21 +03:00
committed by GitHub
21 changed files with 376 additions and 398 deletions
@@ -14,7 +14,7 @@ import {
SubmittingForm, ErrorMessage, InputField, Checkbox
} from '@dbeaver/core/blocks';
import { useController } from '@dbeaver/core/di';
import { DialogComponent, CommonDialogWrapper } from '@dbeaver/core/dialogs';
import { CommonDialogWrapper, DialogComponentProps } from '@dbeaver/core/dialogs';
import { useTranslate } from '@dbeaver/core/localization';
import { composes, useStyles } from '@dbeaver/core/theming';
@@ -57,103 +57,103 @@ const styles = composes(
`
);
export const CreateUserDialog: DialogComponent<null, null> = observer(
function CreateUserDialog(props) {
const controller = useController(CreateUserDialogController, props.rejectDialog);
const translate = useTranslate();
const handleLoginChange = useCallback(
(value: string) => controller.credentials.login = value,
[]
);
const handlePasswordChange = useCallback(
(value: string) => controller.credentials.password = value,
[]
);
const handlePasswordRepeatChange = useCallback(
(value: string) => controller.credentials.passwordRepeat = value,
[]
);
const handleRoleChange = useCallback(
(roleId: string, value: boolean) => controller.credentials.roles.set(roleId, value),
[]
);
export const CreateUserDialog = observer(function CreateUserDialog({
rejectDialog,
}: DialogComponentProps<null, null>) {
const controller = useController(CreateUserDialogController, rejectDialog);
const translate = useTranslate();
const handleLoginChange = useCallback(
(value: string) => controller.credentials.login = value,
[]
);
const handlePasswordChange = useCallback(
(value: string) => controller.credentials.password = value,
[]
);
const handlePasswordRepeatChange = useCallback(
(value: string) => controller.credentials.passwordRepeat = value,
[]
);
const handleRoleChange = useCallback(
(roleId: string, value: boolean) => controller.credentials.roles.set(roleId, value),
[]
);
return styled(useStyles(styles))(
<CommonDialogWrapper
title={translate('authentication_create_user_dialog_title')}
noBodyPadding
footer={(
<CreateUserDialogFooter
isCreating={controller.isCreating}
onCancel={props.rejectDialog}
onCreate={controller.create}
/>
)}
onReject={props.rejectDialog}
>
<SubmittingForm onSubmit={controller.create} autoComplete="disabled">
<create-form as='div'>
<group as="div">
<InputField
type='text'
name='login'
value={controller.credentials.login}
onChange={handleLoginChange}
return styled(useStyles(styles))(
<CommonDialogWrapper
title={translate('authentication_create_user_dialog_title')}
noBodyPadding
footer={(
<CreateUserDialogFooter
isCreating={controller.isCreating}
onCancel={rejectDialog}
onCreate={controller.create}
/>
)}
onReject={rejectDialog}
>
<SubmittingForm onSubmit={controller.create} autoComplete="disabled">
<create-form as='div'>
<group as="div">
<InputField
type='text'
name='login'
value={controller.credentials.login}
onChange={handleLoginChange}
disabled={controller.isCreating}
mod='surface'
>
{translate('authentication_user_name')}
</InputField>
</group>
<group as="div">
<InputField
type='password'
name='password'
value={controller.credentials.password}
onChange={handlePasswordChange}
disabled={controller.isCreating}
mod='surface'
>
{translate('authentication_user_password')}
</InputField>
</group>
<group as="div">
<InputField
type='password'
name='password_repeat'
value={controller.credentials.passwordRepeat}
onChange={handlePasswordRepeatChange}
disabled={controller.isCreating}
mod='surface'
>
{translate('authentication_user_password_repeat')}
</InputField>
</group>
{controller.roles.map((role, i) => (
<group as="div" key={role.roleId}>
<Checkbox
type='checkbox'
name='role'
checkboxLabel={role.roleName || role.roleId}
onChange={checked => handleRoleChange(role.roleId, checked)}
checked={controller.credentials.roles.get(role.roleId)}
disabled={controller.isCreating}
mod='surface'
>
{translate('authentication_user_name')}
</InputField>
{i === 0 && translate('authentication_user_role')}
</Checkbox>
</group>
<group as="div">
<InputField
type='password'
name='password'
value={controller.credentials.password}
onChange={handlePasswordChange}
disabled={controller.isCreating}
mod='surface'
>
{translate('authentication_user_password')}
</InputField>
</group>
<group as="div">
<InputField
type='password'
name='password_repeat'
value={controller.credentials.passwordRepeat}
onChange={handlePasswordRepeatChange}
disabled={controller.isCreating}
mod='surface'
>
{translate('authentication_user_password_repeat')}
</InputField>
</group>
{controller.roles.map((role, i) => (
<group as="div" key={role.roleId}>
<Checkbox
type='checkbox'
name='role'
checkboxLabel={role.roleName || role.roleId}
onChange={checked => handleRoleChange(role.roleId, checked)}
checked={controller.credentials.roles.get(role.roleId)}
disabled={controller.isCreating}
mod='surface'
>
{i === 0 && translate('authentication_user_role')}
</Checkbox>
</group>
))}
</create-form>
</SubmittingForm>
{controller.error.responseMessage && (
<ErrorMessage
text={controller.error.responseMessage}
hasDetails={controller.error.hasDetails}
onShowDetails={controller.showDetails}
/>
)}
</CommonDialogWrapper>
);
}
);
))}
</create-form>
</SubmittingForm>
{controller.error.responseMessage && (
<ErrorMessage
text={controller.error.responseMessage}
hasDetails={controller.error.hasDetails}
onShowDetails={controller.showDetails}
/>
)}
</CommonDialogWrapper>
);
});
@@ -13,7 +13,7 @@ import {
SubmittingForm, ErrorMessage, TabsState, TabList, Tab, TabTitle
} from '@dbeaver/core/blocks';
import { useController } from '@dbeaver/core/di';
import { DialogComponent, CommonDialogWrapper } from '@dbeaver/core/dialogs';
import { CommonDialogWrapper, DialogComponentProps } from '@dbeaver/core/dialogs';
import { useTranslate } from '@dbeaver/core/localization';
import { composes, useStyles } from '@dbeaver/core/theming';
@@ -79,56 +79,57 @@ const styles = composes(
`
);
export const AuthDialog: DialogComponent<null, null> = observer(
function AuthDialog(props) {
const controller = useController(AuthDialogController, props.rejectDialog);
const translate = useTranslate();
export const AuthDialog = observer(function AuthDialog({
options,
rejectDialog,
}: DialogComponentProps<null, null>) {
const controller = useController(AuthDialogController, rejectDialog);
const translate = useTranslate();
return styled(useStyles(styles))(
<TabsState currentTabId={controller.provider?.id || null}>
<CommonDialogWrapper
title={translate('authentication_login_dialog_title')}
noBodyPadding
header={(
<TabList aria-label='Auth providers'>
{controller.providers.map(provider => (
<Tab
key={provider.id}
tabId={provider.id}
onOpen={() => controller.selectProvider(provider.id)}
>
<TabTitle>{provider.label}</TabTitle>
</Tab>
))}
</TabList>
)}
footer={(
<AuthDialogFooter
isAuthenticating={controller.isAuthenticating}
onLogin={controller.login}
return styled(useStyles(styles))(
<TabsState currentTabId={controller.provider?.id || null}>
<CommonDialogWrapper
title={translate('authentication_login_dialog_title')}
noBodyPadding
header={(
<TabList aria-label='Auth providers'>
{controller.providers.map(provider => (
<Tab
key={provider.id}
tabId={provider.id}
onOpen={() => controller.selectProvider(provider.id)}
>
<TabTitle>{provider.label}</TabTitle>
</Tab>
))}
</TabList>
)}
footer={(
<AuthDialogFooter
isAuthenticating={controller.isAuthenticating}
onLogin={controller.login}
/>
)}
onReject={options?.persistent ? undefined : rejectDialog}
>
<SubmittingForm onSubmit={controller.login}>
{controller.provider && (
<AuthProviderForm
provider={controller.provider}
credentials={controller.credentials}
authenticate={controller.isAuthenticating}
/>
)}
onReject={props.options?.persistent ? undefined : props.rejectDialog}
>
<SubmittingForm onSubmit={controller.login}>
{controller.provider && (
<AuthProviderForm
provider={controller.provider}
credentials={controller.credentials}
authenticate={controller.isAuthenticating}
/>
)}
{!controller.provider && <>Select available provider</>}
</SubmittingForm>
{controller.error.responseMessage && (
<ErrorMessage
text={controller.error.responseMessage}
hasDetails={controller.error.hasDetails}
onShowDetails={controller.showDetails}
/>
)}
</CommonDialogWrapper>
</TabsState>
);
}
);
{!controller.provider && <>Select available provider</>}
</SubmittingForm>
{controller.error.responseMessage && (
<ErrorMessage
text={controller.error.responseMessage}
hasDetails={controller.error.hasDetails}
onShowDetails={controller.showDetails}
/>
)}
</CommonDialogWrapper>
</TabsState>
);
});
@@ -11,7 +11,7 @@ import styled, { css } from 'reshadow';
import { ErrorMessage, SubmittingForm, Loader } from '@dbeaver/core/blocks';
import { useController } from '@dbeaver/core/di';
import { CommonDialogWrapper, DialogComponent, DialogComponentProps } from '@dbeaver/core/dialogs';
import { CommonDialogWrapper, DialogComponentProps } from '@dbeaver/core/dialogs';
import { useTranslate } from '@dbeaver/core/localization';
import { useStyles } from '@dbeaver/core/theming';
@@ -37,59 +37,59 @@ const styles = css`
}
`;
export const ConnectionDialog: DialogComponent<null, null> = observer(
function ConnectionDialog(props: DialogComponentProps<null, null>) {
const controller = useController(ConnectionController, props.rejectDialog);
const translate = useTranslate();
let title = translate('basicConnection_connectionDialog_newConnection');
export const ConnectionDialog = observer(function ConnectionDialog({
rejectDialog,
}: DialogComponentProps<null, null>) {
const controller = useController(ConnectionController, rejectDialog);
const translate = useTranslate();
let title = translate('basicConnection_connectionDialog_newConnection');
if (controller.step === ConnectionStep.Connection && controller.dbSource?.name) {
title = controller.dbSource.name;
}
return styled(useStyles(styles))(
<CommonDialogWrapper
title={title}
noBodyPadding={controller.step === ConnectionStep.DBSource}
footer={controller.step === ConnectionStep.Connection && (
<ConnectionDialogFooter
isConnecting={controller.isConnecting}
onBack={() => controller.onStep(ConnectionStep.DBSource)}
onConnect={controller.onConnect}
/>
)}
onReject={props.rejectDialog}
>
{controller.isLoading && <Loader />}
{!controller.isLoading && controller.step === ConnectionStep.DBSource && (
<DBSourceSelector
dbSources={controller.dbSources}
dbDrivers={controller.dbDrivers}
onSelect={controller.onDBSourceSelect}
/>
)}
{controller.step === ConnectionStep.Connection && (controller.dbDriver?.anonymousAccess ? (
<center as="div">
{controller.isConnecting && translate('basicConnection_connectionDialog_connecting_message')}
</center>
) : (
<SubmittingForm onSubmit={controller.onConnect}>
<Connection
userName={controller.config.userName}
userPassword={controller.config.userPassword}
isConnecting={controller.isConnecting}
onChange={controller.onChange}
/>
</SubmittingForm>
))}
{controller.responseMessage && (
<ErrorMessage
text={controller.responseMessage}
hasDetails={controller.hasDetails}
onShowDetails={controller.onShowDetails}
/>
)}
</CommonDialogWrapper>
);
if (controller.step === ConnectionStep.Connection && controller.dbSource?.name) {
title = controller.dbSource.name;
}
);
return styled(useStyles(styles))(
<CommonDialogWrapper
title={title}
noBodyPadding={controller.step === ConnectionStep.DBSource}
footer={controller.step === ConnectionStep.Connection && (
<ConnectionDialogFooter
isConnecting={controller.isConnecting}
onBack={() => controller.onStep(ConnectionStep.DBSource)}
onConnect={controller.onConnect}
/>
)}
onReject={rejectDialog}
>
{controller.isLoading && <Loader />}
{!controller.isLoading && controller.step === ConnectionStep.DBSource && (
<DBSourceSelector
dbSources={controller.dbSources}
dbDrivers={controller.dbDrivers}
onSelect={controller.onDBSourceSelect}
/>
)}
{controller.step === ConnectionStep.Connection && (controller.dbDriver?.anonymousAccess ? (
<center as="div">
{controller.isConnecting && translate('basicConnection_connectionDialog_connecting_message')}
</center>
) : (
<SubmittingForm onSubmit={controller.onConnect}>
<Connection
userName={controller.config.userName}
userPassword={controller.config.userPassword}
isConnecting={controller.isConnecting}
onChange={controller.onChange}
/>
</SubmittingForm>
))}
{controller.responseMessage && (
<ErrorMessage
text={controller.responseMessage}
hasDetails={controller.hasDetails}
onShowDetails={controller.onShowDetails}
/>
)}
</CommonDialogWrapper>
);
});
@@ -1,19 +0,0 @@
/*
* cloudbeaver - Cloud Database Manager
* Copyright (C) 2020 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 styled from 'reshadow';
import { placeholderStyles } from './placeholderStyles';
export function Placeholder({ className }: { className?: string }) {
return styled(placeholderStyles)(
<box as="div" className={className}>
<div></div>
</box>
);
}
@@ -1,41 +0,0 @@
/*
* cloudbeaver - Cloud Database Manager
* Copyright (C) 2020 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 { css } from 'reshadow';
export const placeholderStyles = css`
box {
position: relative;
overflow: hidden;
padding: 0 6px;
max-width: 200px;
}
div {
box-sizing: border-box;
overflow: hidden;
position: relative;
height: 18px;
background: #dedede;
border-radius: 3px;
margin: 2px 0px;
animation: wave 1.5s linear infinite;
}
@keyframes wave {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
`;
@@ -9,7 +9,7 @@
import { observer } from 'mobx-react';
import React, { PropsWithChildren } from 'react';
import { useChildren } from '../../../shared/useChildren';
import { useChildren } from '../../shared/useChildren';
type NavigationNodeChildrenProps = PropsWithChildren<{
parentId: string;
@@ -29,7 +29,7 @@ export const NavigationNodeChildren = observer(function NavigationNodeChildren({
const NavigationNodeChild = component;
return (
<>
{nodeChildren.children.map(id => (
{nodeChildren.children!.map(id => (
<NavigationNodeChild id={id} key={id} />
))}
</>
@@ -9,7 +9,7 @@
import { observer } from 'mobx-react';
import { NavigationNode } from './NavigationNode/NavigationNode';
import { NavigationNodeChildren } from './NavigationNodeChildren/NavigationNodeChildren';
import { NavigationNodeChildren } from './NavigationNodeChildren';
import { TreeNodeMenu } from './TreeNodeMenu/TreeNodeMenu';
import { useNavigationTree } from './useNavigationTree';
@@ -13,7 +13,7 @@ import { ComputedMenuItemModel, ComputedMenuPanelModel, IMenuItem } from '@dbeav
import { ConnectionsManagerService, Connection } from '../../../shared/ConnectionsManager/ConnectionsManagerService';
import { EObjectFeature } from '../../../shared/NodesManager/EObjectFeature';
import { concatSchemaAndCatalog } from '../../../shared/NodesManager/NodesManagerService';
import { NodeManagerUtils } from '../../../shared/NodesManager/NodeManagerUtils';
import { ConnectionSchemaManagerService } from '../ConnectionSchemaManagerService';
@injectable()
@@ -54,7 +54,7 @@ export class ConnectionSelectorController {
}
private get currentObjectContainerTitle(): string | undefined {
return concatSchemaAndCatalog(
return NodeManagerUtils.concatSchemaAndCatalog(
this.connectionSelectorService.currentObjectCatalogId,
this.connectionSelectorService.currentObjectSchemaId
);
@@ -116,7 +116,10 @@ export class ConnectionSelectorController {
.filter(item => !!item.name)
.map((item) => {
if (item.features?.includes(EObjectFeature.catalog)) {
const title = concatSchemaAndCatalog(item.name, this.connectionSelectorService.currentObjectSchemaId);
const title = NodeManagerUtils.concatSchemaAndCatalog(
item.name,
this.connectionSelectorService.currentObjectSchemaId
);
const handler = item.features?.includes(EObjectFeature.catalog)
? () => this.connectionSelectorService.selectCatalog(item.name!)
: () => this.connectionSelectorService.selectSchema(item.name!);
@@ -129,7 +132,10 @@ export class ConnectionSelectorController {
return menuItem;
}
const title = concatSchemaAndCatalog(this.connectionSelectorService.currentObjectCatalogId, item.name);
const title = NodeManagerUtils.concatSchemaAndCatalog(
this.connectionSelectorService.currentObjectCatalogId,
item.name
);
const handler = item.features?.includes(EObjectFeature.catalog)
? () => this.connectionSelectorService.selectCatalog(item.name!)
: () => this.connectionSelectorService.selectSchema(item.name!);
+1
View File
@@ -15,6 +15,7 @@ export * from './shared/NodesManager/extensions/IObjectCatalogProvider';
export * from './shared/NodesManager/extensions/IObjectCatalogSetter';
export * from './shared/NodesManager/extensions/IObjectSchemaProvider';
export * from './shared/NodesManager/extensions/IObjectSchemaSetter';
export * from './shared/NodesManager/NodeManagerUtils';
export * from './shared/Navigation/NavigationService';
export * from './shared/NavigationTabs/NavigationTabsService';
export * from './shared/NavigationTabs/TabNavigationContext';
@@ -25,5 +25,11 @@ export class NodeManagerUtils {
return matches[1];
}
static isDatabaseObject(objectId: string) {
return /^database:\/\//.test(objectId);
}
static concatSchemaAndCatalog(catalogId?: string, schemaId?: string) {
return `${schemaId || ''}${schemaId && catalogId ? '@' : ''}${catalogId || ''}`;
}
}
@@ -312,11 +312,3 @@ export class NodesManagerService {
|| info.features.includes(ENodeFeature.container);
}
}
export function isDatabaseObject(objectId: string) {
return /^database:\/\//.test(objectId);
}
export function concatSchemaAndCatalog(catalogId?: string, schemaId?: string) {
return `${schemaId || ''}${schemaId && catalogId ? '@' : ''}${catalogId || ''}`;
}
@@ -15,7 +15,7 @@ import { useTranslate } from '@dbeaver/core/localization';
import { useStyles } from '@dbeaver/core/theming';
import { CommonDialogWrapper } from '../CommonDialog/CommonDialog/CommonDialogWrapper';
import { DialogComponent } from '../CommonDialog/CommonDialogService';
import { DialogComponentProps } from '../CommonDialog/CommonDialogService';
const styles = css`
dialog-content {
@@ -34,9 +34,9 @@ const styles = css`
}
`;
export const SessionExpiredDialog: DialogComponent<null, null> = observer(function SessionExpiredDialog({
export const SessionExpiredDialog = observer(function SessionExpiredDialog({
rejectDialog,
}) {
}: DialogComponentProps<null, null>) {
const translate = useTranslate();
const title = translate('app_root_session_expired_title');
const reload = useCallback(() => window.location.reload(), []);
+1 -1
View File
@@ -73,7 +73,7 @@ export const coreManifest: PluginManifest = {
ServerService,
],
async initialize(services) {
async initialize() {
// Note that the initialization of the core occurs in AppBootstrap
// and it is called before the initialization phase of all manifests
},
@@ -0,0 +1,32 @@
/*
* cloudbeaver - Cloud Database Manager
* Copyright (C) 2020 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 { observable } from 'mobx';
export type DefaultValueGetter<TKey, TValue> = (key: TKey, metadata: MetadataMap<TKey, TValue>) => TValue
export class MetadataMap<TKey, TValue> {
private data: Map<TKey, TValue>;
constructor(private defaultValueGetter: DefaultValueGetter<TKey, TValue>) {
this.data = observable(new Map());
}
get(key: TKey): TValue {
if (this.data.has(key)) {
return this.data.get(key)!;
}
const value = this.defaultValueGetter(key, this);
this.data.set(key, value);
return value;
}
delete(key: TKey) {
this.data.delete(key);
}
}
+1
View File
@@ -1,4 +1,5 @@
export * from './flat';
export * from './MetadataMap';
export * from './OrderedMap';
export * from './parseJSONFlat';
export * from './uuid_';
@@ -82,63 +82,61 @@ type ConnectionFormDialogProps = React.PropsWithChildren<{
onBack(): void;
}>
export const ConnectionFormDialog = observer(
function ConnectionFormDialog({
title,
driver,
onClose,
onBack,
}: ConnectionFormDialogProps) {
const translate = useTranslate();
const controller = useController(ConnectionFormDialogController, driver, onClose);
const [loadProperties, setLoadProperties] = useState(false);
export const ConnectionFormDialog = observer(function ConnectionFormDialog({
title,
driver,
onClose,
onBack,
}: ConnectionFormDialogProps) {
const translate = useTranslate();
const controller = useController(ConnectionFormDialogController, driver, onClose);
const [loadProperties, setLoadProperties] = useState(false);
return styled(useStyles(styles))(
<TabsState selectedId='options'>
<CommonDialogWrapper
title={title}
noBodyPadding
header={(
<TabList>
<Tab tabId='options' >
<TabTitle>{translate('customConnection_options')}</TabTitle>
</Tab>
<Tab tabId='driver_properties' onOpen={() => setLoadProperties(true)} >
<TabTitle>{translate('customConnection_properties')}</TabTitle>
</Tab>
</TabList>
)}
footer={(
<ConnectionFormDialogFooter
isConnecting={controller.isConnecting}
onConnectionTest={controller.onTestConnection}
onCreateConnection={controller.onCreateConnection}
onBack={onBack}
return styled(useStyles(styles))(
<TabsState selectedId='options'>
<CommonDialogWrapper
title={title}
noBodyPadding
header={(
<TabList>
<Tab tabId='options' >
<TabTitle>{translate('customConnection_options')}</TabTitle>
</Tab>
<Tab tabId='driver_properties' onOpen={() => setLoadProperties(true)} >
<TabTitle>{translate('customConnection_properties')}</TabTitle>
</Tab>
</TabList>
)}
footer={(
<ConnectionFormDialogFooter
isConnecting={controller.isConnecting}
onConnectionTest={controller.onTestConnection}
onCreateConnection={controller.onCreateConnection}
onBack={onBack}
/>
)}
onReject={onClose}
>
<SubmittingForm onSubmit={controller.onCreateConnection}>
<TabPanel tabId='options'>
<ConnectionForm driver={driver} controller={controller} />
</TabPanel>
<TabPanel tabId='driver_properties'>
<DriverProperties
driver={driver}
state={controller.config.properties!}
loadProperties={loadProperties}
/>
)}
onReject={onClose}
>
<SubmittingForm onSubmit={controller.onCreateConnection}>
<TabPanel tabId='options'>
<ConnectionForm driver={driver} controller={controller} />
</TabPanel>
<TabPanel tabId='driver_properties'>
<DriverProperties
driver={driver}
state={controller.config.properties!}
loadProperties={loadProperties}
/>
</TabPanel>
</SubmittingForm>
{controller.error.responseMessage && (
<ErrorMessage
text={controller.error.responseMessage}
hasDetails={controller.error.hasDetails}
onShowDetails={controller.onShowDetails}
/>
)}
</CommonDialogWrapper>
</TabsState>
);
}
);
</TabPanel>
</SubmittingForm>
{controller.error.responseMessage && (
<ErrorMessage
text={controller.error.responseMessage}
hasDetails={controller.error.hasDetails}
onShowDetails={controller.onShowDetails}
/>
)}
</CommonDialogWrapper>
</TabsState>
);
});
@@ -9,41 +9,41 @@
import { observer } from 'mobx-react';
import { useController } from '@dbeaver/core/di';
import { DialogComponent } from '@dbeaver/core/dialogs';
import { DialogComponentProps } from '@dbeaver/core/dialogs';
import { useTranslate } from '@dbeaver/core/localization';
import { ConnectionFormDialog } from './ConnectionFormDialog/ConnectionFormDialog';
import { CustomConnectionController, ConnectionStep } from './CustomConnectionController';
import { DriverSelectorDialog } from './DriverSelectorDialog/DriverSelectorDialog';
export const CustomConnectionDialog: DialogComponent<null, null> = observer(
function CustomConnectionDialog(props) {
const controller = useController(CustomConnectionController);
let title = useTranslate('basicConnection_connectionDialog_newConnection');
export const CustomConnectionDialog = observer(function CustomConnectionDialog({
rejectDialog,
}: DialogComponentProps<null, null>) {
const controller = useController(CustomConnectionController);
let title = useTranslate('basicConnection_connectionDialog_newConnection');
if (controller.step === ConnectionStep.Connection && controller.driver?.name) {
title = controller.driver.name;
}
if (controller.step === ConnectionStep.Connection && controller.driver) {
return (
<ConnectionFormDialog
title={title}
driver={controller.driver}
onBack={() => controller.onStep(ConnectionStep.Driver)}
onClose={props.rejectDialog}
/>
);
}
if (controller.step === ConnectionStep.Connection && controller.driver?.name) {
title = controller.driver.name;
}
if (controller.step === ConnectionStep.Connection && controller.driver) {
return (
<DriverSelectorDialog
<ConnectionFormDialog
title={title}
drivers={controller.drivers}
onSelect={controller.onDriverSelect}
isLoading={controller.isLoading}
onClose={props.rejectDialog}
driver={controller.driver}
onBack={() => controller.onStep(ConnectionStep.Driver)}
onClose={rejectDialog}
/>
);
}
);
return (
<DriverSelectorDialog
title={title}
drivers={controller.drivers}
onSelect={controller.onDriverSelect}
isLoading={controller.isLoading}
onClose={rejectDialog}
/>
);
});
@@ -9,41 +9,42 @@
import { observer } from 'mobx-react';
import { useController } from '@dbeaver/core/di';
import { DialogComponent } from '@dbeaver/core/dialogs';
import { DialogComponentProps } from '@dbeaver/core/dialogs';
import { IExportContext } from '../IExportContext';
import { DataExportController, DataExportStep } from './DataExportController';
import { ProcessorConfigureDialog } from './ProcessorConfigureDialog';
import { ProcessorSelectDialog } from './ProcessorSelectDialog';
export const DataExportDialog: DialogComponent<IExportContext, null> = observer(
function DataExportDialog(props) {
const controller = useController(DataExportController, props.payload, props.rejectDialog);
if (controller.step === DataExportStep.Configure && controller.processor) {
return (
<ProcessorConfigureDialog
processor={controller.processor}
properties={controller.properties}
processorProperties={controller.processorProperties}
error={controller.error}
isExporting={controller.isExporting}
onShowDetails={controller.showDetails}
onBack={() => controller.setStep(DataExportStep.DataTransferProcessor)}
onClose={props.rejectDialog}
onExport={controller.prepareExport}
/>
);
}
export const DataExportDialog = observer(function DataExportDialog({
payload,
rejectDialog,
}: DialogComponentProps<IExportContext, null>) {
const controller = useController(DataExportController, payload, rejectDialog);
if (controller.step === DataExportStep.Configure && controller.processor) {
return (
<ProcessorSelectDialog
context={props.payload}
processors={controller.processors}
onSelect={controller.selectProcessor}
isLoading={controller.isLoading}
onClose={props.rejectDialog}
<ProcessorConfigureDialog
processor={controller.processor}
properties={controller.properties}
processorProperties={controller.processorProperties}
error={controller.error}
isExporting={controller.isExporting}
onShowDetails={controller.showDetails}
onBack={() => controller.setStep(DataExportStep.DataTransferProcessor)}
onClose={rejectDialog}
onExport={controller.prepareExport}
/>
);
}
);
return (
<ProcessorSelectDialog
context={payload}
processors={controller.processors}
onSelect={controller.selectProcessor}
isLoading={controller.isLoading}
onClose={rejectDialog}
/>
);
});
@@ -7,13 +7,13 @@
*/
import { injectable } from '@dbeaver/core/di';
import { GraphQLService, SqlDataFilterConstraint } from '@dbeaver/core/sdk';
import { GraphQLService } from '@dbeaver/core/sdk';
import { RequestDataOptionsToConstrains } from './DataViewerUtils';
import { IExecutionContext } from './IExecutionContext';
import { RowDiff } from './TableViewer/TableDataModel/EditedRow';
import { IRequestDataResult, IRequestDataResultOptions, TableViewerModel } from './TableViewer/TableViewerModel';
import { TableViewerStorageService } from './TableViewer/TableViewerStorageService';
import { RequestDataOptionsToConstrains } from './DataViewerUtils';
@injectable()
@@ -11,7 +11,7 @@ import { useCallback } from 'react';
import styled, { css } from 'reshadow';
import { Button, SanitizedHTML } from '@dbeaver/core/blocks';
import { CommonDialogWrapper, DialogComponent } from '@dbeaver/core/dialogs';
import { CommonDialogWrapper, DialogComponentProps } from '@dbeaver/core/dialogs';
import { useTranslate } from '@dbeaver/core/localization';
import { useStyles } from '@dbeaver/core/theming';
@@ -44,9 +44,9 @@ export type ErrorDialogPayload = {
onShowDetails?: () => void;
}
export const ErrorDialog: DialogComponent<ErrorDialogPayload, boolean> = observer(function ErrorDialog({
export const ErrorDialog = observer(function ErrorDialog({
rejectDialog, resolveDialog, payload,
}) {
}: DialogComponentProps<ErrorDialogPayload, boolean>) {
const handleRetry = useCallback(() => resolveDialog(true), [resolveDialog]);
const translate = useTranslate();
@@ -15,12 +15,12 @@ import {
IContextProvider,
ITab,
TabHandler,
isDatabaseObject,
NavigationType,
NodeManagerUtils,
connectionProvider,
objectCatalogProvider,
objectSchemaProvider,
NavNodeManagerService,
} from '@dbeaver/core/app';
import { injectable } from '@dbeaver/core/di';
import { NotificationService } from '@dbeaver/core/eventsLog';
@@ -115,7 +115,7 @@ export class ObjectViewerTabService {
const propertiesTabLoadingKey = `${tab.handlerState.objectId}_${folderId}`;
try {
if (children.length === 0 || !isDatabaseObject(folderId)) {
if (children.length === 0 || !NodeManagerUtils.isDatabaseObject(folderId)) {
return;
}