@@ -28,6 +28,7 @@ import { withFeatureConsumer, isFeatureEnabled } from '../common/feature-checkin
2828import { withLogger } from '../common/logger' ;
2929import { withRouterAndRef } from '../common/routing' ;
3030import ActivitySidebarFilter from './ActivitySidebarFilter' ;
31+ import { ViewType , FeedEntryType } from '../common/types/SidebarNavigation' ;
3132import {
3233 ACTIVITY_FILTER_OPTION_ALL ,
3334 ACTIVITY_FILTER_OPTION_RESOLVED ,
@@ -76,6 +77,7 @@ import type { WithAnnotatorContextProps } from '../common/annotator-context';
7677import './ActivitySidebar.scss' ;
7778
7879import type { OnAnnotationEdit , OnAnnotationStatusChange } from './activity-feed/comment/types' ;
80+ import type { InternalSidebarNavigation , InternalSidebarNavigationHandler } from '../common/types/SidebarNavigation' ;
7981
8082type ExternalProps = {
8183 activeFeedEntryId ?: string ,
@@ -86,6 +88,8 @@ type ExternalProps = {
8688 hasReplies ?: boolean ,
8789 hasTasks ?: boolean ,
8890 hasVersions ?: boolean ,
91+ internalSidebarNavigation ?: InternalSidebarNavigation ,
92+ internalSidebarNavigationHandler ?: InternalSidebarNavigationHandler ,
8993 onCommentCreate : Function ,
9094 onCommentDelete : ( comment : Comment ) => any ,
9195 onCommentUpdate : ( ) => any ,
@@ -94,6 +98,7 @@ type ExternalProps = {
9498 onTaskDelete : ( id : string ) => any ,
9599 onTaskUpdate : ( ) => any ,
96100 onTaskView : ( id : string , isCreator : boolean ) => any ,
101+ routerDisabled ?: boolean ,
97102} & ErrorContextProps &
98103 WithAnnotatorContextProps ;
99104
@@ -547,7 +552,7 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
547552 * @return {void }
548553 */
549554 updateReplies = ( id : string , replies : Array < Comment > ) => {
550- const { activeFeedEntryId, api, file, history } = this . props ;
555+ const { activeFeedEntryId, api, file, history, internalSidebarNavigationHandler , routerDisabled } = this . props ;
551556 const { feedItems } = this . state ;
552557
553558 if ( ! feedItems ) {
@@ -567,7 +572,16 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
567572 item . id === id && item === this . getCommentFeedItemByReplyId ( feedItems , activeFeedEntryId ) ,
568573 )
569574 ) {
570- history . replace ( this . getActiveCommentPath ( ) ) ;
575+ if ( routerDisabled && internalSidebarNavigationHandler ) {
576+ internalSidebarNavigationHandler (
577+ {
578+ sidebar : ViewType . ACTIVITY ,
579+ } ,
580+ true ,
581+ ) ;
582+ } else {
583+ history . replace ( this . getActiveCommentPath ( ) ) ;
584+ }
571585 }
572586
573587 feedAPI . updateFeedItem ( { replies } , id ) ;
@@ -1108,18 +1122,36 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
11081122 getAnnotationsMatchPath,
11091123 getAnnotationsPath,
11101124 history,
1125+ internalSidebarNavigation,
1126+ internalSidebarNavigationHandler,
11111127 location,
11121128 onAnnotationSelect,
1129+ routerDisabled,
11131130 } = this . props ;
11141131 const annotationFileVersionId = getProp ( file_version , 'id' ) ;
11151132 const currentFileVersionId = getProp ( file , 'file_version.id' ) ;
1116- const match = getAnnotationsMatchPath ( location ) ;
1117- const selectedFileVersionId = getProp ( match , 'params.fileVersionId' , currentFileVersionId ) ;
1133+
1134+ let selectedFileVersionId = currentFileVersionId ;
1135+ if ( routerDisabled && internalSidebarNavigation ) {
1136+ selectedFileVersionId = getProp ( internalSidebarNavigation , 'fileVersionId' , currentFileVersionId ) ;
1137+ } else {
1138+ const match = getAnnotationsMatchPath ( location ) ;
1139+ selectedFileVersionId = getProp ( match , 'params.fileVersionId' , currentFileVersionId ) ;
1140+ }
11181141
11191142 emitActiveAnnotationChangeEvent ( nextActiveAnnotationId ) ;
11201143
11211144 if ( annotationFileVersionId && annotationFileVersionId !== selectedFileVersionId ) {
1122- history . push ( getAnnotationsPath ( annotationFileVersionId , nextActiveAnnotationId ) ) ;
1145+ if ( routerDisabled && internalSidebarNavigationHandler ) {
1146+ internalSidebarNavigationHandler ( {
1147+ sidebar : ViewType . ACTIVITY ,
1148+ activeFeedEntryId : nextActiveAnnotationId ,
1149+ activeFeedEntryType : FeedEntryType . ANNOTATIONS ,
1150+ fileVersionId : annotationFileVersionId ,
1151+ } ) ;
1152+ } else {
1153+ history . push ( getAnnotationsPath ( annotationFileVersionId , nextActiveAnnotationId) ) ;
1154+ }
11231155 }
11241156
11251157 onAnnotationSelect(annotation);
@@ -1161,7 +1193,8 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
11611193 }
11621194
11631195 renderAddTaskButton = () => {
1164- const { isDisabled , hasTasks } = this.props;
1196+ const { isDisabled , hasTasks , internalSidebarNavigation , internalSidebarNavigationHandler , routerDisabled } =
1197+ this.props;
11651198 const { approverSelectorContacts } = this.state;
11661199 const { getApprover , getAvatarUrl , createTask , onTaskModalClose } = this;
11671200
@@ -1171,8 +1204,11 @@ class ActivitySidebar extends React.PureComponent<Props, State> {
11711204
11721205 return (
11731206 < AddTaskButton
1207+ internalSidebarNavigation = { internalSidebarNavigation }
1208+ internalSidebarNavigationHandler = { internalSidebarNavigationHandler }
11741209 isDisabled = { isDisabled }
11751210 onTaskModalClose = { onTaskModalClose }
1211+ routerDisabled = { routerDisabled }
11761212 taskFormProps = { {
11771213 approvers : [ ] ,
11781214 approverSelectorContacts,
0 commit comments