Move icons to old position and pass initial state to parent.

pull/4831/head
ioedeveloper 6 months ago committed by Aniket
parent bc9e9fd266
commit 9e50d3c1b8
  1. 36
      libs/remix-ui/panel/src/lib/plugins/panel-header.tsx
  2. 7
      libs/remix-ui/panel/src/lib/plugins/panel-plugin.tsx

@ -44,19 +44,6 @@ const RemixUIPanelHeader = (props: RemixPanelProps) => {
{plugin?.profile?.name && <FormattedMessage id={`${plugin.profile.name}.displayName`} defaultMessage={plugin?.profile?.displayName || plugin?.profile?.name} />}
</h6>
<div className="d-flex flex-row">
{
plugin && plugin.profile.name !== 'filePanel' && (
<RenderIfNot condition={plugin.profile.name === 'filePanel'}>
<RenderIf condition={plugin.pinned}>
<div className='d-flex' data-id="movePluginToLeft" onClick={unPinPlugin}>
<CustomTooltip placement="auto-end" tooltipId="unPinnedMsg" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="panel.unPinnedMsg" />}>
<i aria-hidden="true" className="mt-1 px-2 fas fa-solid fa-square-left"></i>
</CustomTooltip>
</div>
</RenderIf>
</RenderIfNot>
)
}
<div className="d-flex flex-row">
{plugin?.profile?.maintainedBy?.toLowerCase() === 'remix' ? (
<CustomTooltip placement="auto-end" tooltipId="maintainedByTooltip" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="panel.maintainedByRemix" />}>
@ -75,13 +62,22 @@ const RemixUIPanelHeader = (props: RemixPanelProps) => {
{
plugin && plugin.profile.name !== 'filePanel' && (
<RenderIfNot condition={plugin.profile.name === 'filePanel'}>
<RenderIfNot condition={plugin.pinned}>
<div className='d-flex' data-id="movePluginToRight" onClick={pinPlugin}>
<CustomTooltip placement="auto-end" tooltipId="pinnedMsg" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="panel.pinnedMsg" />}>
<i aria-hidden="true" className="mt-1 px-1 pl-2 fas fa-solid fa-square-right"></i>
</CustomTooltip>
</div>
</RenderIfNot>
<>
<RenderIf condition={plugin.pinned}>
<div className='d-flex' data-id="movePluginToLeft" onClick={unPinPlugin}>
<CustomTooltip placement="auto-end" tooltipId="unPinnedMsg" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="panel.unPinnedMsg" />}>
<i aria-hidden="true" className="mt-1 px-2 fas fa-solid fa-square-left"></i>
</CustomTooltip>
</div>
</RenderIf>
<RenderIfNot condition={plugin.pinned}>
<div className='d-flex' data-id="movePluginToRight" onClick={pinPlugin}>
<CustomTooltip placement="auto-end" tooltipId="pinnedMsg" tooltipClasses="text-nowrap" tooltipText={<FormattedMessage id="panel.pinnedMsg" />}>
<i aria-hidden="true" className="mt-1 px-1 pl-2 fas fa-solid fa-square-right"></i>
</CustomTooltip>
</div>
</RenderIfNot>
</>
</RenderIfNot>
)
}

@ -19,9 +19,12 @@ const RemixUIPanelPlugin = (props: panelPLuginProps, panelRef: any) => {
let view = props.pluginRecord.view
if (props.initialState) {
let hasInitialProps = false
view = React.Children.map((props.pluginRecord.view.props as any).children, child => {
if (React.isValidElement(child) && typeof child.type === 'function') {
// Safe to clone and pass `initialState`
if (React.isValidElement(child) && typeof child.type === 'function' && !hasInitialProps) {
hasInitialProps = true
// Safe to clone and pass `initialState`
return React.cloneElement(child, { ...props, initialState: props.initialState } as any)
}
return child

Loading…
Cancel
Save