-
Notifications
You must be signed in to change notification settings - Fork 552
dbeaver/pro#9981 adds export button for admin users page #4531
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
Open
sergeyteleshev
wants to merge
9
commits into
devel
Choose a base branch
from
9981-export-csv-button
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f811528
dbeaver/pro#9981 adds export button for admin users page
sergeyteleshev 55e124b
Merge branch 'devel' into 9981-export-csv-button
sergeyteleshev c005cc3
dbeaver/pro#9981 uses fetch to download csv instead of submitForm app…
sergeyteleshev 13d174a
dbeaver/pro#9981 makes users export to be available only for PRO prod…
sergeyteleshev 8aab190
Merge branch 'devel' into 9981-export-csv-button
sergeyteleshev fea6c02
Merge branch 'devel' into 9981-export-csv-button
sergeyteleshev a3fb333
dbeaver/pro#9981 reverts export logic
sergeyteleshev da7a3b0
dbeaver/pro#9981 add actionButtonsPlaceholder
sergeyteleshev d7cc6f7
dbeaver/pro#9981 cleanup
sergeyteleshev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,81 @@ | ||
| /* | ||
| * 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 { observable } from 'mobx'; | ||
| import { observer } from 'mobx-react-lite'; | ||
|
|
||
| import { useService } from '@cloudbeaver/core-di'; | ||
| import { CommonDialogService, DialogueStateResult } from '@cloudbeaver/core-dialogs'; | ||
| import type { TLocalizationToken } from '@cloudbeaver/core-localization'; | ||
|
|
||
| import { Icon } from '../Icon.js'; | ||
| import { useTranslate } from '../localization/useTranslate.js'; | ||
| import { useObservableRef } from '../useObservableRef.js'; | ||
| import { ExportConfirmationDialog, type IExportConfirmationDialogState } from './ExportConfirmationDialog.js'; | ||
| import { GridAction } from './GridAction.js'; | ||
| import type { IExportFilterEntry } from './IExportFilterEntry.js'; | ||
|
|
||
| export interface IExportButtonProps { | ||
| filters?: IExportFilterEntry[]; | ||
| title?: TLocalizationToken; | ||
| confirmTitle?: TLocalizationToken; | ||
| descriptionWithFilters?: TLocalizationToken; | ||
| descriptionDefault?: TLocalizationToken; | ||
| /** Hint shown in the info box when `showHint` is enabled */ | ||
| hint?: TLocalizationToken; | ||
| openOptionsLabel?: TLocalizationToken; | ||
| showHint?: boolean; | ||
| exportHandler: () => void; | ||
| onOpenOptions?: () => void; | ||
| } | ||
|
|
||
| export const ExportButton = observer<IExportButtonProps>(function ExportButton({ | ||
| filters, | ||
| title = 'core_blocks_export_title', | ||
| confirmTitle = 'core_blocks_export_confirm_title', | ||
| descriptionWithFilters = 'core_blocks_export_confirm_with_filters', | ||
| descriptionDefault = 'core_blocks_export_confirm_default', | ||
| hint = 'core_blocks_export_confirm_default', | ||
| openOptionsLabel = 'core_blocks_export_change_filters', | ||
| showHint, | ||
| exportHandler, | ||
| onOpenOptions, | ||
| }) { | ||
| const translate = useTranslate(); | ||
| const commonDialogService = useService(CommonDialogService); | ||
|
|
||
| const dialogState = useObservableRef<IExportConfirmationDialogState>( | ||
| () => ({ filters: filters ?? [] }), | ||
| { filters: observable.ref }, | ||
| { filters: filters ?? [] }, | ||
| ); | ||
|
|
||
| async function handleExport() { | ||
| const { status } = await commonDialogService.open(ExportConfirmationDialog, { | ||
| state: dialogState, | ||
| confirmTitle, | ||
| descriptionWithFilters, | ||
| descriptionDefault, | ||
| hint, | ||
| openOptionsLabel, | ||
| showHint, | ||
| onOpenOptions, | ||
| }); | ||
|
|
||
| if (status !== DialogueStateResult.Resolved) { | ||
| return; | ||
| } | ||
|
|
||
| exportHandler(); | ||
| } | ||
|
|
||
| return ( | ||
| <GridAction title={translate(title)} onClick={handleExport}> | ||
| <Icon className="tw:w-full tw:h-full tw:fill-(--theme-primary)" name="table-export" viewBox="0 0 24 24" /> | ||
| </GridAction> | ||
| ); | ||
| }); | ||
12 changes: 12 additions & 0 deletions
12
webapp/packages/core-blocks/src/Export/ExportButtonLazy.ts
This file contains hidden or 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-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 { importLazyComponent } from '../importLazyComponent.js'; | ||
|
|
||
| export const ExportButton = importLazyComponent(() => import('./ExportButton.js').then(m => m.ExportButton)); | ||
|
|
||
| export type { IExportButtonProps } from './ExportButton.js'; |
104 changes: 104 additions & 0 deletions
104
webapp/packages/core-blocks/src/Export/ExportConfirmationDialog.tsx
This file contains hidden or 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,104 @@ | ||
| /* | ||
| * 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 { observer } from 'mobx-react-lite'; | ||
|
|
||
| import type { DialogComponentProps } from '@cloudbeaver/core-dialogs'; | ||
| import type { TLocalizationToken } from '@cloudbeaver/core-localization'; | ||
|
|
||
| import { Button } from '../Button.js'; | ||
| import { CommonDialogBody } from '../CommonDialog/CommonDialog/CommonDialogBody.js'; | ||
| import { CommonDialogFooter } from '../CommonDialog/CommonDialog/CommonDialogFooter.js'; | ||
| import { CommonDialogHeader } from '../CommonDialog/CommonDialog/CommonDialogHeader.js'; | ||
| import { CommonDialogWrapper } from '../CommonDialog/CommonDialog/CommonDialogWrapper.js'; | ||
| import { Container } from '../Containers/Container.js'; | ||
| import { Fill } from '../Fill.js'; | ||
| import { IconOrImage } from '../IconOrImage.js'; | ||
| import { Translate } from '../localization/Translate.js'; | ||
| import { useTranslate } from '../localization/useTranslate.js'; | ||
| import { Tag } from '../Tags/Tag.js'; | ||
| import { Tags } from '../Tags/Tags.js'; | ||
| import type { IExportFilterEntry } from './IExportFilterEntry.js'; | ||
|
|
||
| export interface IExportConfirmationDialogState { | ||
| filters: IExportFilterEntry[]; | ||
| } | ||
|
|
||
| export interface IExportConfirmationDialogPayload { | ||
| state: IExportConfirmationDialogState; | ||
| confirmTitle: TLocalizationToken; | ||
| descriptionWithFilters: TLocalizationToken; | ||
| descriptionDefault: TLocalizationToken; | ||
| hint: TLocalizationToken; | ||
| openOptionsLabel: TLocalizationToken; | ||
| showHint?: boolean; | ||
| onOpenOptions?: () => void; | ||
| } | ||
|
|
||
| export const ExportConfirmationDialog = observer<DialogComponentProps<IExportConfirmationDialogPayload>>(function ExportConfirmationDialog({ | ||
| payload, | ||
| resolveDialog, | ||
| rejectDialog, | ||
| className, | ||
| }) { | ||
| const translate = useTranslate(); | ||
| const { state, confirmTitle, descriptionWithFilters, descriptionDefault, hint, openOptionsLabel, showHint, onOpenOptions } = payload; | ||
| const hasFilters = state.filters.length > 0; | ||
|
|
||
| return ( | ||
| <CommonDialogWrapper size="medium" className={className} fixedWidth> | ||
| <CommonDialogHeader title={confirmTitle} onReject={() => rejectDialog()} /> | ||
| <CommonDialogBody> | ||
| <> | ||
| <div className="tw:mb-3"> | ||
| <Translate token={hasFilters ? descriptionWithFilters : descriptionDefault} /> | ||
| </div> | ||
| {hasFilters && ( | ||
| <ul className="tw:flex tw:flex-col tw:gap-1 tw:mb-3"> | ||
| {state.filters.map(f => ( | ||
| <li key={f.key} className="tw:flex tw:items-start tw:gap-1"> | ||
| <strong className="tw:shrink-0">{translate(f.label)}:</strong>{' '} | ||
| {f.items ? ( | ||
| <Tags className="tw:inline-flex tw:align-middle"> | ||
| {f.items.map(item => ( | ||
| <Tag key={String(item.id)} id={item.id} label={item.label} icon={item.icon} /> | ||
| ))} | ||
| </Tags> | ||
| ) : ( | ||
| f.value | ||
| )} | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| )} | ||
| {hasFilters && showHint && ( | ||
| <div className="tw:flex tw:items-start tw:gap-2 tw:bg-(--theme-secondary) tw:p-3 tw:rounded tw:mt-auto"> | ||
| <IconOrImage className="tw:py-1 tw:px-0.5" icon="/icons/preload/info_icon_sm.svg" /> | ||
| <span className="tw:text-pretty">{translate(hint)}</span> | ||
| </div> | ||
| )} | ||
| </> | ||
| </CommonDialogBody> | ||
| <CommonDialogFooter> | ||
| {onOpenOptions && ( | ||
| <Container keepSize> | ||
| <Button variant="secondary" onClick={onOpenOptions}> | ||
| {translate(openOptionsLabel)} | ||
| </Button> | ||
| </Container> | ||
| )} | ||
| <Fill /> | ||
| <Container keepSize noWrap gap> | ||
| <Button variant="secondary" onClick={() => rejectDialog()}> | ||
| {translate('ui_processing_cancel')} | ||
| </Button> | ||
| <Button onClick={() => resolveDialog()}>{translate('ui_export')}</Button> | ||
| </Container> | ||
| </CommonDialogFooter> | ||
| </CommonDialogWrapper> | ||
| ); | ||
| }); |
18 changes: 18 additions & 0 deletions
18
webapp/packages/core-blocks/src/Export/GridAction.module.css
This file contains hidden or 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,18 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| .gridAction { | ||
| composes: theme-ripple from global; | ||
| position: relative; | ||
| box-sizing: border-box; | ||
| background: inherit; | ||
| cursor: pointer; | ||
| width: 28px; | ||
| height: 100%; | ||
| padding: 4px; | ||
| } |
This file contains hidden or 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,23 @@ | ||
| /* | ||
| * 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 { observer } from 'mobx-react-lite'; | ||
|
|
||
| import { s } from '../s.js'; | ||
| import { useS } from '../useS.js'; | ||
| import styles from './GridAction.module.css'; | ||
|
|
||
| type Props = React.PropsWithChildren & React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>; | ||
|
|
||
| export const GridAction = observer(function GridAction({ children, className, ...rest }: Props) { | ||
| const style = useS(styles); | ||
| return ( | ||
| <button className={s(style, { gridAction: true }, className)} {...rest}> | ||
| {children} | ||
| </button> | ||
| ); | ||
| }); |
17 changes: 17 additions & 0 deletions
17
webapp/packages/core-blocks/src/Export/IExportFilterEntry.ts
This file contains hidden or 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,17 @@ | ||
| /* | ||
| * 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 type { TLocalizationToken } from '@cloudbeaver/core-localization'; | ||
|
|
||
| import type { ITag } from '../Tags/Tag.js'; | ||
|
|
||
| export interface IExportFilterEntry<T = string> { | ||
| key: T; | ||
| label: TLocalizationToken; | ||
| value?: string; | ||
| items?: ITag[]; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this component to
core-blockscause previously it was inplugin-query-managerand I don't wanna import this plugin intoplugin-user-export- this is incorrect deps handling