Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cb 1084 transactions #2449

Merged
merged 38 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b0f921a
CB-4806 transactions api
yagudin10 Mar 4, 2024
c2e081d
CB-1084 add commit mode plugin
devnaumov Mar 5, 2024
0ebf7e9
CB-1084 rename plugin
devnaumov Mar 5, 2024
a045360
Merge branch 'devel' into CB-1084-transactions
devnaumov Mar 5, 2024
cb42abf
CB-4806 add is auto commit property to web context
yagudin10 Mar 5, 2024
b210c75
CB-1084 add gql queries
devnaumov Mar 6, 2024
a1ed2ad
Merge remote-tracking branch 'origin/devel' into CB-1084-transactions
yagudin10 Mar 6, 2024
fa09481
CB-1084 add loaders
devnaumov Mar 6, 2024
a052b1a
Merge branch 'CB-1084-transactions' of https://github.com/dbeaver/clo…
devnaumov Mar 6, 2024
9ef63b0
CB-4806 transactions for update results
yagudin10 Mar 6, 2024
85c072e
Merge remote-tracking branch 'origin/CB-1084-transactions' into CB-10…
yagudin10 Mar 6, 2024
a8e6696
CB-4806 fix text
yagudin10 Mar 6, 2024
2e32dd6
CB-1084 pass execution context via extensions
devnaumov Mar 7, 2024
86ea375
CB-1084 handle errors
devnaumov Mar 7, 2024
d21fbfd
CB-1084 get connection before the task execution
devnaumov Mar 7, 2024
0069a3d
CB-1084 grab connection from transaction context
devnaumov Mar 7, 2024
ad9dc5c
Merge branch 'devel' into CB-1084-transactions
devnaumov Mar 8, 2024
03ed2f0
CB-1084 support execution context provider for the object viewer
devnaumov Mar 11, 2024
a71c8e5
CB-1084 refresh context manually
devnaumov Mar 11, 2024
6430617
CB-1084 check options panel status
devnaumov Mar 11, 2024
2404c46
CB-1084 move transaction logic to the ConnectionExecutionContext
devnaumov Mar 11, 2024
08c308e
CB-4806 make project id required
yagudin10 Mar 12, 2024
46d3fb0
Merge branch 'devel' into CB-1084-transactions
devnaumov Mar 12, 2024
2f2e35f
CB-1084 make actions naming more unique
devnaumov Mar 12, 2024
d5708f1
CB-1084 remove success flag
devnaumov Mar 12, 2024
c2fc994
CB-1084 add plugin to default product
devnaumov Mar 12, 2024
cbdd9f4
Merge branch 'devel' into CB-1084-transactions
EvgeniaBzzz Mar 13, 2024
97d194c
Merge branch 'devel' into CB-1084-transactions
EvgeniaBzzz Mar 14, 2024
9e1d384
CB-1084 show confirm dialog
devnaumov Mar 14, 2024
687c67a
Merge branch 'devel' into CB-1084-transactions
EvgeniaBzzz Mar 14, 2024
e4ab4f5
CB-1084 always fire disconnect through executor
devnaumov Mar 14, 2024
80423e7
Merge branch 'CB-1084-transactions' of https://github.com/dbeaver/clo…
devnaumov Mar 14, 2024
1c6beab
CB-1084 adjust behaviour
devnaumov Mar 14, 2024
ecfffce
Merge branch 'devel' into CB-1084-transactions
EvgeniaBzzz Mar 15, 2024
0dd614c
CB-1084 add more explicit check
devnaumov Mar 15, 2024
52281f5
Merge branch 'CB-1084-transactions' of https://github.com/dbeaver/clo…
devnaumov Mar 15, 2024
be12770
CB-1084 interrupt disconnect if commit fails
devnaumov Mar 15, 2024
e440e32
Merge branch 'devel' into CB-1084-transactions
EvgeniaBzzz Mar 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
*/
import { ConfirmationDialog } from '@cloudbeaver/core-blocks';
import {
ConnectionExecutionContext,
ConnectionExecutionContextResource,
ConnectionExecutionContextService,
ConnectionInfoResource,
ConnectionsManagerService,
createConnectionParam,
IConnectionExecutionContextUpdateTaskInfo,
IConnectionExecutorData,
} from '@cloudbeaver/core-connections';
import { Bootstrap, injectable } from '@cloudbeaver/core-di';
import { CommonDialogService, DialogueStateResult } from '@cloudbeaver/core-dialogs';
import { NotificationService } from '@cloudbeaver/core-events';
import { ExecutorInterrupter, type IExecutionContextProvider } from '@cloudbeaver/core-executor';
import { LocalizationService } from '@cloudbeaver/core-localization';
import { OptionsPanelService } from '@cloudbeaver/core-ui';
import { ActionService, MenuService } from '@cloudbeaver/core-view';
import { ConnectionSchemaManagerService } from '@cloudbeaver/plugin-datasource-context-switch';
Expand All @@ -33,13 +39,18 @@ export class TransactionManagerBootstrap extends Bootstrap {
private readonly connectionExecutionContextService: ConnectionExecutionContextService,
private readonly connectionExecutionContextResource: ConnectionExecutionContextResource,
private readonly connectionInfoResource: ConnectionInfoResource,
private readonly connectionsManagerService: ConnectionsManagerService,
private readonly optionsPanelService: OptionsPanelService,
private readonly notificationService: NotificationService,
private readonly commonDialogService: CommonDialogService,
private readonly localizationService: LocalizationService,
) {
super();
}

register() {
this.connectionsManagerService.onDisconnect.addHandler(this.disconnectHandler.bind(this));

this.menuService.addCreator({
menus: [MENU_APP_ACTIONS],
isApplicable: () => {
Expand Down Expand Up @@ -110,13 +121,7 @@ export class TransactionManagerBootstrap extends Bootstrap {

switch (action) {
case ACTION_DATASOURCE_TRANSACTION_COMMIT: {
try {
const result = await transaction.commit();
this.showTransactionResult(transaction, result);
} catch (exception: any) {
this.notificationService.logException(exception, 'plugin_datasource_transaction_manager_commit_fail');
}

await this.commit(transaction);
break;
}
case ACTION_DATASOURCE_TRANSACTION_ROLLBACK: {
Expand Down Expand Up @@ -164,4 +169,41 @@ export class TransactionManagerBootstrap extends Bootstrap {

return this.connectionExecutionContextService.get(context.id);
}

private async disconnectHandler(data: IConnectionExecutorData, contexts: IExecutionContextProvider<IConnectionExecutorData>) {
Wroud marked this conversation as resolved.
Show resolved Hide resolved
for (const connection of data.connections) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connection -> connectionKey (or connectionId)

const context = this.connectionExecutionContextResource.values.find(
c => c.connectionId === connection.connectionId && c.projectId === connection.projectId,
);
Wroud marked this conversation as resolved.
Show resolved Hide resolved

if (context) {
const transaction = this.connectionExecutionContextService.get(context.id);

if (transaction?.autoCommit === false) {
const connectionData = this.connectionInfoResource.get(connection);
const state = await this.commonDialogService.open(ConfirmationDialog, {
title: `${this.localizationService.translate('plugin_datasource_transaction_manager_commit')} (${connectionData?.name ?? context.id})`,
message: 'plugin_datasource_transaction_manager_commit_confirmation_message',
confirmActionText: 'plugin_datasource_transaction_manager_commit',
extraStatus: 'no',
});

if (state === DialogueStateResult.Resolved) {
await this.commit(transaction);
Wroud marked this conversation as resolved.
Show resolved Hide resolved
} else if (state === DialogueStateResult.Rejected) {
ExecutorInterrupter.interrupt(contexts);
}
}
}
}
}

private async commit(transaction: ConnectionExecutionContext) {
try {
const result = await transaction.commit();
this.showTransactionResult(transaction, result);
} catch (exception: any) {
this.notificationService.logException(exception, 'plugin_datasource_transaction_manager_commit_fail');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export default [
['plugin_datasource_transaction_manager_commit_fail', 'Failed to commit transaction'],
['plugin_datasource_transaction_manager_rollback_fail', 'Failed to rollback transaction'],
['plugin_datasource_transaction_manager_commit_mode_fail', 'Failed to change commit mode'],
['plugin_datasource_transaction_manager_commit_confirmation_message', 'Do you want to commit changes?'],
];
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export default [
['plugin_datasource_transaction_manager_commit_fail', 'Failed to commit transaction'],
['plugin_datasource_transaction_manager_rollback_fail', 'Failed to rollback transaction'],
['plugin_datasource_transaction_manager_commit_mode_fail', 'Failed to change commit mode'],
['plugin_datasource_transaction_manager_commit_confirmation_message', 'Do you want to commit changes?'],
];
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export default [
['plugin_datasource_transaction_manager_commit_fail', 'Не удалось выполнить коммит'],
['plugin_datasource_transaction_manager_rollback_fail', 'Не удалось выполнить откат'],
['plugin_datasource_transaction_manager_commit_mode_fail', 'Не удалось переключить режим коммита'],
['plugin_datasource_transaction_manager_commit_confirmation_message', 'Вы хотите зафиксировать изменения?'],
];
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export default [
['plugin_datasource_transaction_manager_commit_fail', 'Failed to commit transaction'],
['plugin_datasource_transaction_manager_rollback_fail', 'Failed to rollback transaction'],
['plugin_datasource_transaction_manager_commit_mode_fail', 'Failed to change commit mode'],
['plugin_datasource_transaction_manager_commit_confirmation_message', 'Do you want to commit changes?'],
];
Loading