diff --git a/scripts/apps/authoring-react/article-widgets/find-and-replace.tsx b/scripts/apps/authoring-react/article-widgets/find-and-replace.tsx index c8a7c0d0fb..8ac16ae25a 100644 --- a/scripts/apps/authoring-react/article-widgets/find-and-replace.tsx +++ b/scripts/apps/authoring-react/article-widgets/find-and-replace.tsx @@ -134,7 +134,7 @@ class FindAndReplaceWidget extends React.PureComponent diff --git a/scripts/apps/authoring-react/article-widgets/versions-and-item-history/versions-tab.tsx b/scripts/apps/authoring-react/article-widgets/versions-and-item-history/versions-tab.tsx index cf6df5f3e7..33e42a96ce 100644 --- a/scripts/apps/authoring-react/article-widgets/versions-and-item-history/versions-tab.tsx +++ b/scripts/apps/authoring-react/article-widgets/versions-and-item-history/versions-tab.tsx @@ -183,7 +183,9 @@ export class VersionsTab extends React.PureComponent { this.compareVersions(); }} diff --git a/scripts/apps/authoring-react/authoring-integration-wrapper-sidebar.tsx b/scripts/apps/authoring-react/authoring-integration-wrapper-sidebar.tsx index 42fffba7bb..cf5437eacb 100644 --- a/scripts/apps/authoring-react/authoring-integration-wrapper-sidebar.tsx +++ b/scripts/apps/authoring-react/authoring-integration-wrapper-sidebar.tsx @@ -3,7 +3,6 @@ import * as Nav from 'superdesk-ui-framework/react/components/Navigation'; import {IArticle, IExposedFromAuthoring} from 'superdesk-api'; import {ISideBarTab} from 'superdesk-ui-framework/react/components/Navigation/SideBarTabs'; import {getWidgetsFromExtensions, ISideWidget} from './authoring-integration-wrapper'; -import {closedIntentionally} from 'apps/authoring/widgets/widgets'; interface IProps { options: IExposedFromAuthoring; @@ -58,36 +57,27 @@ export class AuthoringIntegrationWrapperSidebar extends React.PureComponent { - if (nextWidgetId == null && closedIntentionally.value == true) { - closedIntentionally.value = false; + // active is closed, we set the pinned as active + if (nextWidgetId == null && sideWidget.pinnedId != null) { + setSideWidget({ + activeId: sideWidget?.pinnedId, + pinnedId: sideWidget?.pinnedId, + }); + } else { + setSideWidget({ + activeId: nextWidgetId, + pinnedId: sideWidget?.pinnedId, + }); } - - const isWidgetPinned = (() => { - if (sideWidget?.id != null && sideWidget.id === nextWidgetId) { - return sideWidget.pinned; - } - - return false; - })(); - - this.props.setSideWidget( - nextWidgetId == null - ? null - : { - id: nextWidgetId, - pinned: isWidgetPinned, - }, - ); }} items={this.state.sidebarTabs} /> ); } -} \ No newline at end of file +} diff --git a/scripts/apps/authoring-react/authoring-integration-wrapper.tsx b/scripts/apps/authoring-react/authoring-integration-wrapper.tsx index 157c7f9acf..f4a3f65017 100644 --- a/scripts/apps/authoring-react/authoring-integration-wrapper.tsx +++ b/scripts/apps/authoring-react/authoring-integration-wrapper.tsx @@ -62,10 +62,9 @@ const defaultToolbarItems: Array { @@ -256,10 +255,14 @@ export class AuthoringIntegrationWrapper extends React.PureComponent - {(panelState, panelActions) => { - return ( - { - this.authoringReactRef = component; - }} - itemId={this.props.itemId} - resourceNames={ARTICLE_RELATED_RESOURCE_NAMES} - onClose={() => this.props.onClose()} - authoringStorage={this.props.authoringStorage} - fieldsAdapter={getFieldsAdapter(this.props.authoringStorage)} - storageAdapter={{ - storeValue: (value, fieldId, article) => { - return { - ...article, - extra: { - ...(article.extra ?? {}), - [fieldId]: value, - }, - }; - }, - retrieveStoredValue: (item: IArticle, fieldId) => item.extra?.[fieldId] ?? null, - }} - getLanguage={(article) => article.language ?? 'en'} - onEditingStart={(article) => { - dispatchCustomEvent('articleEditStart', article); - }} - onEditingEnd={(article) => { - dispatchCustomEvent('articleEditEnd', article); - }} - getActions={({ + {(panelState, panelActions) => ( + { + this.authoringReactRef = component; + }} + itemId={this.props.itemId} + resourceNames={ARTICLE_RELATED_RESOURCE_NAMES} + onClose={() => this.props.onClose()} + authoringStorage={this.props.authoringStorage} + fieldsAdapter={getFieldsAdapter(this.props.authoringStorage)} + storageAdapter={{ + storeValue: (value, fieldId, article) => { + return { + ...article, + extra: { + ...(article.extra ?? {}), + [fieldId]: value, + }, + }; + }, + retrieveStoredValue: (item: IArticle, fieldId) => item.extra?.[fieldId] ?? null, + }} + getLanguage={(article) => article.language ?? 'en'} + onEditingStart={(article) => { + dispatchCustomEvent('articleEditStart', article); + }} + onEditingEnd={(article) => { + dispatchCustomEvent('articleEditEnd', article); + }} + getActions={({ + item, + contentProfile, + fieldsData, + getLatestItem, + handleUnsavedChanges, + hasUnsavedChanges, + authoringStorage, + fieldsAdapter, + storageAdapter, + }) => { + const authoringActionsFromExtensions = getAuthoringActionsFromExtensions( item, contentProfile, fieldsData, - getLatestItem, - handleUnsavedChanges, - hasUnsavedChanges, - authoringStorage, - fieldsAdapter, - storageAdapter, - }) => { - const authoringActionsFromExtensions = getAuthoringActionsFromExtensions( - item, - contentProfile, - fieldsData, + ); + + return [ + getSaveAsTemplate(getLatestItem), + getCompareVersionsModal( + getLatestItem, + authoringStorage, + fieldsAdapter, + storageAdapter, + ), + getMultiEditModal(getLatestItem), + getHighlightsAction(getLatestItem), + getMarkedForDesksModal(getLatestItem), + getExportModal(getLatestItem, handleUnsavedChanges, hasUnsavedChanges), + getTranslateModal(getLatestItem), + ...authoringActionsFromExtensions, + ]; + }} + getSidebarWidgetsCount={({item}) => getWidgetsFromExtensions(item).length} + sideWidget={this.state.sideWidget} + onSideWidgetChange={(sideWidget) => { + this.setState({sideWidget}); + closedIntentionally.value = false; + }} + getInlineToolbarActions={this.props.getInlineToolbarActions} + getAuthoringPrimaryToolbarWidgets={ + this.props.getAuthoringPrimaryToolbarWidgets != null + ? () => this.props.getAuthoringPrimaryToolbarWidgets(panelState, panelActions) + : undefined + } + getSidePanel={({ + item, + getLatestItem, + contentProfile, + fieldsData, + handleFieldsDataChange, + fieldsAdapter, + storageAdapter, + authoringStorage, + handleUnsavedChanges, + sideWidget, + onItemChange, + addValidationErrors, + }, readOnly) => { + if (panelState.active === true) { + return ( + handleUnsavedChanges().then((res) => [res]) + } + onClose={panelActions.closePanel} + onError={(error) => { + if (error.kind === 'publishing-error') { + addValidationErrors(error.fields); + } else { + assertNever(error.kind); + } + }} + markupV2 + /> ); + } - return [ - getSaveAsTemplate(getLatestItem), - getCompareVersionsModal( - getLatestItem, - authoringStorage, - fieldsAdapter, - storageAdapter, - ), - getMultiEditModal(getLatestItem), - getHighlightsAction(getLatestItem), - getMarkedForDesksModal(getLatestItem), - getExportModal(getLatestItem, handleUnsavedChanges, hasUnsavedChanges), - getTranslateModal(getLatestItem), - ...authoringActionsFromExtensions, - ]; - }} - getSidebarWidgetsCount={({item}) => getWidgetsFromExtensions(item).length} - sideWidget={this.state.sideWidget} - onSideWidgetChange={(sideWidget) => { - this.setState({sideWidget}); - }} - getInlineToolbarActions={this.props.getInlineToolbarActions} - getAuthoringPrimaryToolbarWidgets={ - this.props.getAuthoringPrimaryToolbarWidgets != null - ? () => this.props.getAuthoringPrimaryToolbarWidgets(panelState, panelActions) - : undefined + if (sideWidget == null) { + return null; } - getSidePanel={({ - item, - getLatestItem, - contentProfile, - fieldsData, - handleFieldsDataChange, - fieldsAdapter, - storageAdapter, - authoringStorage, - handleUnsavedChanges, - sideWidget, - onItemChange, - addValidationErrors, - }, readOnly) => { - if (panelState.active === true) { - return ( - handleUnsavedChanges().then((res) => [res]) - } - onClose={panelActions.closePanel} - onError={(error) => { - if (error.kind === 'publishing-error') { - addValidationErrors(error.fields); - } else { - assertNever(error.kind); - } - }} - markupV2 - /> - ); - } - if (sideWidget == null) { - return null; - } + const WidgetComponent = getWidgetsFromExtensions(item) + .find((widget) => sideWidget === widget._id)?.component; + + return ( + + {(widgetRef) => ( + { + const localStorageWidgetState = + JSON.parse(localStorage.getItem('SIDE_WIDGET') ?? 'null'); + + if (localStorageWidgetState?.id != null) { + const initialState = localStorageWidgetState?.initialState; + + sdApi.preferences.update( + PINNED_WIDGET_USER_PREFERENCE_SETTINGS, + {type: 'string', _id: localStorageWidgetState?.id}, + ); + + // Once a user switches the widget, authoring gets + // re-rendered 3-4 times, causing this logic to run more + // than once. To prevent wrong widget state its + // deleted after 5 seconds. + setTimeout(() => { + localStorage.removeItem('SIDE_WIDGET'); + }, 5000); + + closedIntentionally.value = false; + return initialState; + } - const WidgetComponent = getWidgetsFromExtensions(item) - .find((widget) => sideWidget === widget._id)?.component; + if ( + localStorageWidgetState == null + && closedIntentionally.value === true + && widgetState[this.state.sideWidget?.activeId] != null + ) { + return widgetState[this.state.sideWidget?.activeId]; + } - return ( - - {(widgetRef) => ( - { - const localStorageWidgetState = - JSON.parse(localStorage.getItem('SIDE_WIDGET') ?? 'null'); - - if (localStorageWidgetState?.id != null) { - const initialState = localStorageWidgetState?.initialState; - - sdApi.preferences.update( - PINNED_WIDGET_USER_PREFERENCE_SETTINGS, - {type: 'string', _id: localStorageWidgetState?.id}, - ); - - // Once a user switches the widget, authoring gets - // re-rendered 3-4 times, causing this logic to run more - // than once. To prevent wrong widget state its - // deleted after 5 seconds. - setTimeout(() => { - localStorage.removeItem('SIDE_WIDGET'); - }, 5000); - - closedIntentionally.value = false; - return initialState; - } - - if ( - localStorageWidgetState == null - && closedIntentionally.value === true - && widgetState[this.state.sideWidget.id] != null - ) { - return widgetState[this.state.sideWidget.id]; - } - - return undefined; - })()} - article={item} - getLatestArticle={getLatestItem} - contentProfile={contentProfile} - fieldsData={fieldsData} - authoringStorage={authoringStorage} - fieldsAdapter={fieldsAdapter} - storageAdapter={storageAdapter} - onFieldsDataChange={handleFieldsDataChange} - readOnly={readOnly} - handleUnsavedChanges={() => handleUnsavedChanges()} - onItemChange={onItemChange} - /> - )} - - ); - }} - getSidebar={ - this.state.sidebarMode !== true - ? null - : (options) => ( - { - this.setState({sideWidget}); - }} + return undefined; + })()} + article={item} + getLatestArticle={getLatestItem} + contentProfile={contentProfile} + fieldsData={fieldsData} + authoringStorage={authoringStorage} + fieldsAdapter={fieldsAdapter} + storageAdapter={storageAdapter} + onFieldsDataChange={handleFieldsDataChange} + readOnly={readOnly} + handleUnsavedChanges={() => handleUnsavedChanges()} + onItemChange={onItemChange} /> - ) - } - secondaryToolbarWidgets={secondaryToolbarWidgetsReady} - validateBeforeSaving={false} - getSideWidgetIdAtIndex={(article, index) => { - return getWidgetsFromExtensions(article)[index]._id; - }} - autoFocus={this.props.autoFocus} - /> - ); - }} + )} + + ); + }} + getSidebar={this.state.sidebarMode !== true ? null : (options) => ( + { + this.setState({sideWidget}); + closedIntentionally.value = false; + }} + /> + )} + secondaryToolbarWidgets={secondaryToolbarWidgetsReady} + validateBeforeSaving={false} + getSideWidgetIdAtIndex={(article, index) => { + return getWidgetsFromExtensions(article)[index]._id; + }} + autoFocus={this.props.autoFocus} + /> + )} ); } diff --git a/scripts/apps/authoring-react/authoring-react.tsx b/scripts/apps/authoring-react/authoring-react.tsx index 08264f2c62..c03676ad7f 100644 --- a/scripts/apps/authoring-react/authoring-react.tsx +++ b/scripts/apps/authoring-react/authoring-react.tsx @@ -334,37 +334,40 @@ export class AuthoringReact extends React.PureCo }; widgetReactIntegration.pinWidget = () => { - const widgetPinned = !(this.props.sideWidget?.pinned ?? false); + const nextPinnedWidget = this.props.sideWidget.pinnedId != null ? null : this.props.sideWidget.activeId; const update = { type: 'string', - _id: widgetPinned ? this.props.sideWidget.id : null, + _id: nextPinnedWidget, }; - closedIntentionally.value = true; + dispatchEvent(new CustomEvent('resize-monitoring', { + detail: {value: nextPinnedWidget ? -330 : 330}, + })); + sdApi.preferences.update(PINNED_WIDGET_USER_PREFERENCE_SETTINGS, update); + + // Pinned state can change, but the active widget shouldn't change + // from this function this.props.onSideWidgetChange({ - ...this.props.sideWidget, - pinned: widgetPinned, + activeId: this.props.sideWidget.activeId, + pinnedId: nextPinnedWidget, }); }; widgetReactIntegration.getActiveWidget = () => { - return this.props.sideWidget?.id ?? null; + return this.props.sideWidget?.activeId; }; widgetReactIntegration.getPinnedWidget = () => { - const pinned = this.props.sideWidget?.pinned === true; - - if (pinned) { - return this.props.sideWidget.id; - } - - return null; + return this.props.sideWidget?.pinnedId; }; widgetReactIntegration.closeActiveWidget = () => { closedIntentionally.value = false; - this.props.onSideWidgetChange(null); + this.props.onSideWidgetChange({ + activeId: this.props.sideWidget?.pinnedId, + pinnedId: this.props.sideWidget?.pinnedId, + }); }; widgetReactIntegration.WidgetHeaderComponent = WidgetHeaderComponent; @@ -1208,16 +1211,14 @@ export class AuthoringReact extends React.PureCo authoringStorage: authoringStorage, storageAdapter: storageAdapter, fieldsAdapter: fieldsAdapter, - sideWidget: this.props.sideWidget?.id ?? null, + sideWidget: this.props.sideWidget?.activeId, toggleSideWidget: (id) => { - if (id == null || this.props.sideWidget?.id === id) { - this.props.onSideWidgetChange(null); - } else { - this.props.onSideWidgetChange({ - id: id, - pinned: false, - }); - } + const activeWidgetId = this.props.sideWidget?.activeId; + + this.props.onSideWidgetChange({ + activeId: id, + pinnedId: id === activeWidgetId ? activeWidgetId : this.props.sideWidget?.pinnedId, + }); }, addValidationErrors: (moreValidationErrors) => { this.setState({ @@ -1333,11 +1334,11 @@ export class AuthoringReact extends React.PureCo for (let i = 0; i < widgetsCount; i++) { widgetKeybindings[`ctrl+alt+${i + 1}`] = () => { - const nextWidgetName: string = this.props.getSideWidgetIdAtIndex(exposed.item, i); + const nextWidgetId: string = this.props.getSideWidgetIdAtIndex(exposed.item, i); this.props.onSideWidgetChange({ - id: nextWidgetName, - pinned: this.props.sideWidget?.pinned ?? false, + activeId: nextWidgetId, + pinnedId: this.props.sideWidget?.pinnedId, }); }; } @@ -1356,8 +1357,6 @@ export class AuthoringReact extends React.PureCo }, ] : []; - const pinned = this.props.sideWidget?.pinned === true; - const printPreviewAction = (() => { const execute = () => { previewAuthoringEntity( @@ -1416,6 +1415,8 @@ export class AuthoringReact extends React.PureCo }, }; + const isPinned = this.props.sideWidget?.pinnedId != null; + const onChangeSideWidget = (item: T) => { authoringStorage.getContentProfile(item, this.props.fieldsAdapter) .then((res) => { @@ -1563,10 +1564,10 @@ export class AuthoringReact extends React.PureCo /> )} - sideOverlay={!pinned && OpenWidgetComponent != null && OpenWidgetComponent} - sideOverlayOpen={!pinned && OpenWidgetComponent != null} - sidePanel={pinned && OpenWidgetComponent != null && OpenWidgetComponent} - sidePanelOpen={pinned && OpenWidgetComponent != null} + sideOverlay={!isPinned && OpenWidgetComponent != null && OpenWidgetComponent} + sideOverlayOpen={!isPinned && OpenWidgetComponent != null} + sidePanel={isPinned && OpenWidgetComponent != null && OpenWidgetComponent} + sidePanelOpen={isPinned && OpenWidgetComponent != null} sideBar={this.props.getSidebar?.(exposed)} /> )} diff --git a/scripts/apps/authoring-react/generic-widgets/comments/CommentsWidget.tsx b/scripts/apps/authoring-react/generic-widgets/comments/CommentsWidget.tsx index 2405245ec3..839cb2cbb4 100644 --- a/scripts/apps/authoring-react/generic-widgets/comments/CommentsWidget.tsx +++ b/scripts/apps/authoring-react/generic-widgets/comments/CommentsWidget.tsx @@ -216,7 +216,7 @@ class CommentsWidget extends React.PureComponent, IState> { text="post" type="primary" onClick={this.save} - disabled={this.state.newCommentMessage.length < 1} + disabled={(this.state.newCommentMessage ?? '').length < 1} /> diff --git a/scripts/apps/authoring-react/macros/macros.tsx b/scripts/apps/authoring-react/macros/macros.tsx index c2f753f3ca..7087437536 100644 --- a/scripts/apps/authoring-react/macros/macros.tsx +++ b/scripts/apps/authoring-react/macros/macros.tsx @@ -18,7 +18,7 @@ import {Button} from 'superdesk-ui-framework/react/components/Button'; import {sdApi} from 'api'; import {dispatchInternalEvent} from 'core/internal-events'; import {generatePatch} from 'core/patch'; -import {ToggleBox} from 'superdesk-ui-framework/react'; +import {Label, ToggleBox} from 'superdesk-ui-framework/react'; import {Switch} from 'superdesk-ui-framework/react/components/Switch'; import {omitFields} from '../data-layer'; import {assertNever, nameof} from 'core/helpers/typescript-helpers'; @@ -304,7 +304,20 @@ class MacrosWidget extends React.PureComponent + )} + body={( + + )} + /> + ); } const RunMacroButton: React.ComponentType<{macro: IMacro}> = ({macro}) => { diff --git a/scripts/apps/authoring-react/widget-header-component.tsx b/scripts/apps/authoring-react/widget-header-component.tsx index 063c151a59..a0976aa22c 100644 --- a/scripts/apps/authoring-react/widget-header-component.tsx +++ b/scripts/apps/authoring-react/widget-header-component.tsx @@ -7,11 +7,11 @@ import {gettext} from 'core/utils'; export class WidgetHeaderComponent extends React.PureComponent { render() { const { - widget, pinned, pinWidget, customContent, } = this.props; + const sidebarPinnedId = widgetReactIntegration.getPinnedWidget(); return ( this.props.closeWidget()} iconButtons={widgetReactIntegration.disableWidgetPinning == null ? undefined - : [ + : sidebarPinnedId != null && (sidebarPinnedId !== widgetReactIntegration.getActiveWidget()) ? [] : [ { - pinWidget(widget); + pinWidget(); }} /> , diff --git a/scripts/apps/authoring/widgets/WidgetHeaderComponent.tsx b/scripts/apps/authoring/widgets/WidgetHeaderComponent.tsx index c53c9a19e4..ae44b3a09d 100644 --- a/scripts/apps/authoring/widgets/WidgetHeaderComponent.tsx +++ b/scripts/apps/authoring/widgets/WidgetHeaderComponent.tsx @@ -8,11 +8,7 @@ import {gettext} from 'core/utils'; */ export class WidgetHeaderComponent extends React.PureComponent { render() { - const { - widget, - pinWidget, - pinned, - } = this.props; + const {pinWidget, pinned} = this.props; return ( @@ -20,18 +16,10 @@ export class WidgetHeaderComponent extends React.PureComponent{this.props.widgetName} { - pinWidget(widget); + pinWidget(); }} aria-label={gettext('Pin/Unpin')} > diff --git a/scripts/apps/authoring/widgets/widgets.ts b/scripts/apps/authoring/widgets/widgets.ts index ad438a0bdc..93e632a9b2 100644 --- a/scripts/apps/authoring/widgets/widgets.ts +++ b/scripts/apps/authoring/widgets/widgets.ts @@ -101,9 +101,9 @@ function AuthoringWidgetsProvider() { export interface IWidgetIntegrationComponentProps { widgetName: string; pinned: boolean; - widget: any; + widget: string; editMode: boolean; - pinWidget(widget: any): void; + pinWidget(sideWidget?: IWidget): void; closeWidget(): void; /** @@ -121,7 +121,7 @@ export interface IWidgetIntegrationComponentProps { * and styles in the angular based authoring. */ interface IWidgetIntegration { - pinWidget(widget: any): void; + pinWidget(sideWidget?: IWidget): void; getActiveWidget(): any; closeActiveWidget(): any; getPinnedWidget(): any; diff --git a/scripts/core/superdesk-api.d.ts b/scripts/core/superdesk-api.d.ts index 3c02015920..b56609c30d 100644 --- a/scripts/core/superdesk-api.d.ts +++ b/scripts/core/superdesk-api.d.ts @@ -220,8 +220,8 @@ declare module 'superdesk-api' { getSidebarWidgetsCount(options: IExposedFromAuthoring): number; sideWidget: null | { - id: string; - pinned?: boolean; + pinnedId?: string; + activeId?: string; }; getSideWidgetIdAtIndex(item: T, index: number): string; diff --git a/scripts/core/ui/ui.ts b/scripts/core/ui/ui.ts index d4fddec702..0ac19a089a 100644 --- a/scripts/core/ui/ui.ts +++ b/scripts/core/ui/ui.ts @@ -926,23 +926,36 @@ function splitterWidget(superdesk, $timeout, $rootScope) { }, 0, false); } - /* - * Resize on request - */ - $rootScope.$on('resize:monitoring', (e, value) => { - if ((workspace.outerWidth() + value) < MONITORING_MIN_WIDTH) { + const resizeOnDemandHandler = (resizeWith: number) => { + if ((workspace.outerWidth() + resizeWith) < MONITORING_MIN_WIDTH) { return; } - workspace.width(workspace.outerWidth() + value); + workspace.width(workspace.outerWidth() + resizeWith); resize(); $timeout(() => { afterResize(); }, 500, false); + }; + + addEventListener('resize-monitoring', (e: CustomEvent) => { + resizeOnDemandHandler(e.detail.value); + }); + + /* + * Resize on request + */ + $rootScope.$on('resize:monitoring', (e, value) => { + resizeOnDemandHandler(value); }); + $rootScope.$on('$destroy', () => { + removeEventListener('resize-monitoring', (e: CustomEvent) => { + resizeOnDemandHandler(e.detail.value); + }); + }); /* * If authoring is not initialized, * wait, and initialize it again diff --git a/scripts/extensions/broadcasting/src/page.tsx b/scripts/extensions/broadcasting/src/page.tsx index 189202a49a..2eeda1fa9c 100644 --- a/scripts/extensions/broadcasting/src/page.tsx +++ b/scripts/extensions/broadcasting/src/page.tsx @@ -134,8 +134,8 @@ export class RundownsPage extends React.PureComponent { : { ...rundownItemActionNext, sideWidget: { - id: sidePanel, - pinned: false, + activeId: sidePanel, + pinnedId: undefined, }, }; diff --git a/scripts/extensions/broadcasting/src/rundown-templates/template-edit.tsx b/scripts/extensions/broadcasting/src/rundown-templates/template-edit.tsx index ca0b2e0321..377f9de1c9 100644 --- a/scripts/extensions/broadcasting/src/rundown-templates/template-edit.tsx +++ b/scripts/extensions/broadcasting/src/rundown-templates/template-edit.tsx @@ -99,8 +99,8 @@ type IProps = IPropsEditable | IPropsReadOnly; interface IState { sideWidget: null | { - id: string; - pinned?: boolean; + activeId?: string; + pinnedId?: string; }; } diff --git a/scripts/extensions/broadcasting/src/rundowns/prepare-create-edit-rundown-item.ts b/scripts/extensions/broadcasting/src/rundowns/prepare-create-edit-rundown-item.ts index 5c8cef15b3..a3a187a8cf 100644 --- a/scripts/extensions/broadcasting/src/rundowns/prepare-create-edit-rundown-item.ts +++ b/scripts/extensions/broadcasting/src/rundowns/prepare-create-edit-rundown-item.ts @@ -15,8 +15,8 @@ const {httpRequestJsonLocal} = superdesk; interface IRundownItemActionBase extends IWithAuthoringReactKey { sideWidget: null | { - id: string; - pinned?: boolean; + activeId?: string; + pinnedId?: string; }; } diff --git a/scripts/extensions/broadcasting/src/rundowns/rundown-view-edit.tsx b/scripts/extensions/broadcasting/src/rundowns/rundown-view-edit.tsx index 5b2d7c4541..8d8ebd4967 100644 --- a/scripts/extensions/broadcasting/src/rundowns/rundown-view-edit.tsx +++ b/scripts/extensions/broadcasting/src/rundowns/rundown-view-edit.tsx @@ -682,9 +682,13 @@ export class RundownViewEditComponent extends React.PureComponent { - toggleSideWidget(val); + activeTab={sideWidget?.activeId ?? null} + onActiveTabChange={(nextWidget) => { + if (sideWidget?.pinnedId && nextWidget == null) { + toggleSideWidget(sideWidget.pinnedId); + } else { + toggleSideWidget(nextWidget); + } }} items={sideWidgetsAllowed.map(({icon, _id}) => { const sidebarTab: ISideBarTab = { @@ -715,7 +719,7 @@ export class RundownViewEditComponent extends React.PureComponent { - const sideWidgetName = sideWidget?.id ?? null; + const sideWidgetName = sideWidget?.activeId ?? null; if ( sideWidgetName == null