-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Toolbar additional parameters (#7168)
* ToolbarPanelConfig additionalParams (cherry picked from commit 893c34c) * allow additionalParams in RemoteComponent * add RemoteModuleDialog * deps * fixed missing params * fixed missing params * label translation * allow RemoteModuleDialog buttons customization * revert unnecessary changes * test update * test update * fixed theme & styles * review * formatting * Update NussknackerRemoteDebug.run.xml * Update NussknackerRemoteDebug.run.xml * Update NussknackerRemoteDebug.run.xml * formatting
- Loading branch information
1 parent
ec8c461
commit fcebd61
Showing
22 changed files
with
293 additions
and
110 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { ModuleUrl } from "@touk/federated-component"; | ||
import { WindowContentProps } from "@touk/window-manager"; | ||
import type { FooterButtonProps } from "@touk/window-manager/cjs/components/window/footer"; | ||
import React, { useCallback, useMemo, useRef } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { WindowContent, WindowKind } from "../windowManager"; | ||
import { LoadingButtonTypes } from "../windowManager/LoadingButton"; | ||
import { RemoteComponent } from "./RemoteComponent"; | ||
|
||
export type RemoteModuleDialogProps = NonNullable<unknown>; | ||
export type RemoteModuleDialogRef = NonNullable<{ | ||
closeAction?: () => Promise<void>; | ||
adjustButtons: (buttons: { closeButton: FooterButtonProps; confirmButton: FooterButtonProps }) => FooterButtonProps[]; | ||
}>; | ||
|
||
export function RemoteModuleDialog<P extends NonNullable<unknown>>({ | ||
close, | ||
...props | ||
}: WindowContentProps<WindowKind, { url: ModuleUrl } & P>): JSX.Element { | ||
const { | ||
data: { meta: passProps }, | ||
} = props; | ||
|
||
const ref = useRef<RemoteModuleDialogRef>(); | ||
|
||
const closeAction = useCallback(async () => { | ||
await Promise.all([ref.current?.closeAction?.()]); | ||
close(); | ||
}, [close]); | ||
|
||
const { t } = useTranslation(); | ||
|
||
const closeButton = useMemo<FooterButtonProps>( | ||
() => ({ | ||
title: t("dialog.button.cancel", "cancel"), | ||
action: closeAction, | ||
className: LoadingButtonTypes.secondaryButton, | ||
}), | ||
[closeAction, t], | ||
); | ||
|
||
const confirmButton = useMemo<FooterButtonProps>( | ||
() => ({ | ||
title: t("dialog.button.ok", "OK"), | ||
action: closeAction, | ||
}), | ||
[closeAction, t], | ||
); | ||
|
||
return ( | ||
<WindowContent | ||
{...props} | ||
close={close} | ||
buttons={ref.current?.adjustButtons({ closeButton, confirmButton }) || [closeButton, confirmButton]} | ||
> | ||
<RemoteComponent<RemoteModuleDialogProps, RemoteModuleDialogRef> ref={ref} {...passProps} /> | ||
</WindowContent> | ||
); | ||
} | ||
|
||
export default RemoteModuleDialog; |
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
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.