-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CB-4018 fix: isolate contexts in data viewer
- Loading branch information
Showing
16 changed files
with
219 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 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 { observer } from 'mobx-react-lite'; | ||
import { type PropsWithChildren, useContext } from 'react'; | ||
|
||
import { useDataContext } from '@cloudbeaver/core-data-context'; | ||
|
||
import { CaptureViewContext } from './CaptureViewContext'; | ||
|
||
export const CaptureViewScope = observer<PropsWithChildren>(function CaptureViewScope({ children }) { | ||
const context = useContext(CaptureViewContext); | ||
const viewContext = useDataContext(context); | ||
|
||
return <CaptureViewContext.Provider value={viewContext}>{children}</CaptureViewContext.Provider>; | ||
}); |
10 changes: 10 additions & 0 deletions
10
webapp/packages/core-view/src/View/CaptureViewScopeLazy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 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 { importLazyComponent } from '@cloudbeaver/core-blocks'; | ||
|
||
export const CaptureViewScope = importLazyComponent(() => import('./CaptureViewScope').then(m => m.CaptureViewScope)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ges/plugin-data-viewer-result-set-grouping/src/DVResultSetGroupingPresentationContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 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 { observer } from 'mobx-react-lite'; | ||
|
||
import { useCaptureViewContext } from '@cloudbeaver/core-view'; | ||
|
||
import { DATA_CONTEXT_DV_DDM_RS_GROUPING } from './DataContext/DATA_CONTEXT_DV_DDM_RS_GROUPING'; | ||
import type { IDVResultSetGroupingPresentationState } from './IDVResultSetGroupingPresentationState'; | ||
import { useGroupingData } from './useGroupingData'; | ||
|
||
interface Props { | ||
state: IDVResultSetGroupingPresentationState; | ||
} | ||
|
||
export const DVResultSetGroupingPresentationContext = observer<Props>(function DVResultSetGroupingPresentationContext({ state }) { | ||
const grouping = useGroupingData(state); | ||
|
||
useCaptureViewContext((context, id) => { | ||
context.set(DATA_CONTEXT_DV_DDM_RS_GROUPING, grouping, id); | ||
}); | ||
|
||
return null; | ||
}); |
12 changes: 12 additions & 0 deletions
12
...kages/plugin-data-viewer-result-set-grouping/src/IDVResultSetGroupingPresentationState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 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 type { IGroupingQueryState } from './IGroupingQueryState'; | ||
|
||
export interface IDVResultSetGroupingPresentationState extends IGroupingQueryState { | ||
presentationId: string; | ||
} |
9 changes: 8 additions & 1 deletion
9
webapp/packages/plugin-data-viewer-result-set-grouping/src/useGroupingData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
webapp/packages/plugin-data-viewer/src/TableViewer/DataViewerViewService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 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 { injectable } from '@cloudbeaver/core-di'; | ||
import { ACTION_REDO, ACTION_SAVE, ACTION_UNDO, IActiveView, View } from '@cloudbeaver/core-view'; | ||
import { ITab, NavigationTabsService } from '@cloudbeaver/plugin-navigation-tabs'; | ||
|
||
@injectable() | ||
export class DataViewerViewService extends View<ITab> { | ||
constructor(private readonly navigationTabsService: NavigationTabsService) { | ||
super(); | ||
this.registerAction(ACTION_UNDO, ACTION_REDO, ACTION_SAVE); | ||
} | ||
|
||
getView(): IActiveView<ITab> | null { | ||
return this.navigationTabsService.getView(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.