@@ -8,6 +8,7 @@ import * as Common from '../../core/common/common.js';
88import * as Host from '../../core/host/host.js' ;
99import * as i18n from '../../core/i18n/i18n.js' ;
1010import type * as Platform from '../../core/platform/platform.js' ;
11+ import * as Root from '../../core/root/root.js' ;
1112import type * as Formatter from '../../models/formatter/formatter.js' ;
1213import type * as Workspace from '../../models/workspace/workspace.js' ;
1314import * as WorkspaceDiff from '../../models/workspace_diff/workspace_diff.js' ;
@@ -19,6 +20,7 @@ import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
1920
2021import { ChangesSidebar , Events } from './ChangesSidebar.js' ;
2122import changesViewStyles from './changesView.css.js' ;
23+ import * as CombinedDiffView from './CombinedDiffView.js' ;
2224
2325const CHANGES_VIEW_URL = 'https://developer.chrome.com/docs/devtools/changes' as Platform . DevToolsPath . UrlString ;
2426
@@ -79,8 +81,9 @@ export class ChangesView extends UI.Widget.VBox {
7981 #learnMoreLinkElement?: HTMLElement ;
8082 private readonly diffContainer : HTMLElement ;
8183 private readonly toolbar : UI . Toolbar . Toolbar ;
82- private readonly diffStats : UI . Toolbar . ToolbarText ;
83- private readonly diffView : DiffView . DiffView . DiffView ;
84+ private readonly diffStats ?: UI . Toolbar . ToolbarText ;
85+ private readonly diffView ?: DiffView . DiffView . DiffView ;
86+ private readonly combinedDiffView ?: CombinedDiffView . CombinedDiffView ;
8487
8588 constructor ( ) {
8689 super ( true ) ;
@@ -98,6 +101,7 @@ export class ChangesView extends UI.Widget.VBox {
98101
99102 this . workspaceDiff = WorkspaceDiff . WorkspaceDiff . workspaceDiff ( ) ;
100103 this . changesSidebar = new ChangesSidebar ( this . workspaceDiff ) ;
104+ // TODO(ergunsh): Add scroll to singular diffs when they are clicked on sidebar.
101105 this . changesSidebar . addEventListener (
102106 Events . SELECTED_UI_SOURCE_CODE_CHANGED , this . selectedUISourceCodeChanged , this ) ;
103107 splitWidget . setSidebarWidget ( this . changesSidebar ) ;
@@ -106,20 +110,29 @@ export class ChangesView extends UI.Widget.VBox {
106110
107111 this . diffContainer = mainWidget . element . createChild ( 'div' , 'diff-container' ) ;
108112 UI . ARIAUtils . markAsTabpanel ( this . diffContainer ) ;
109- this . diffContainer . addEventListener ( 'click' , event => this . click ( event ) ) ;
110-
111- this . diffView = this . diffContainer . appendChild ( new DiffView . DiffView . DiffView ( ) ) ;
113+ if ( shouldRenderCombinedDiffView ( ) ) {
114+ // TODO(ergunsh): Handle clicks from CombinedDiffView too.
115+ this . combinedDiffView = new CombinedDiffView . CombinedDiffView ( ) ;
116+ this . combinedDiffView . workspaceDiff = this . workspaceDiff ;
117+ this . combinedDiffView . show ( this . diffContainer ) ;
118+ } else {
119+ this . diffView = this . diffContainer . appendChild ( new DiffView . DiffView . DiffView ( ) ) ;
120+ this . diffContainer . addEventListener ( 'click' , event => this . click ( event ) ) ;
121+ }
112122
113123 this . toolbar = mainWidget . element . createChild ( 'devtools-toolbar' , 'changes-toolbar' ) ;
114124 this . toolbar . setAttribute ( 'jslog' , `${ VisualLogging . toolbar ( ) } ` ) ;
115125 this . toolbar . appendToolbarItem ( UI . Toolbar . Toolbar . createActionButton ( 'changes.revert' ) ) ;
116- this . diffStats = new UI . Toolbar . ToolbarText ( '' ) ;
117- this . toolbar . appendToolbarItem ( this . diffStats ) ;
118-
119- this . toolbar . appendToolbarItem ( new UI . Toolbar . ToolbarSeparator ( ) ) ;
120- this . toolbar . appendToolbarItem ( UI . Toolbar . Toolbar . createActionButton ( 'changes.copy' , {
121- label : i18nLazyString ( UIStrings . copy ) ,
122- } ) ) ;
126+ if ( ! shouldRenderCombinedDiffView ( ) ) {
127+ // TODO(ergunsh): We do not show the diff stats & the copy button for the combined view.
128+ this . diffStats = new UI . Toolbar . ToolbarText ( '' ) ;
129+ this . toolbar . appendToolbarItem ( this . diffStats ) ;
130+
131+ this . toolbar . appendToolbarItem ( new UI . Toolbar . ToolbarSeparator ( ) ) ;
132+ this . toolbar . appendToolbarItem ( UI . Toolbar . Toolbar . createActionButton ( 'changes.copy' , {
133+ label : i18nLazyString ( UIStrings . copy ) ,
134+ } ) ) ;
135+ }
123136
124137 this . hideDiff ( i18nString ( UIStrings . noChanges ) , i18nString ( UIStrings . changesViewDescription ) , CHANGES_VIEW_URL ) ;
125138 this . selectedUISourceCodeChanged ( ) ;
@@ -235,7 +248,7 @@ export class ChangesView extends UI.Widget.VBox {
235248 }
236249
237250 private hideDiff ( header : string , text : string , link ?: Platform . DevToolsPath . UrlString ) : void {
238- this . diffStats . setText ( '' ) ;
251+ this . diffStats ? .setText ( '' ) ;
239252 this . toolbar . setEnabled ( false ) ;
240253 this . diffContainer . style . display = 'none' ;
241254 this . emptyWidget . header = header ;
@@ -257,12 +270,14 @@ export class ChangesView extends UI.Widget.VBox {
257270 if ( ! diff || ( diff . length === 1 && diff [ 0 ] [ 0 ] === Diff . Diff . Operation . Equal ) ) {
258271 this . hideDiff ( i18nString ( UIStrings . noChanges ) , i18nString ( UIStrings . changesViewDescription ) , CHANGES_VIEW_URL ) ;
259272 } else {
260- this . diffStats . setText ( diffStats ( diff ) ) ;
273+ this . diffStats ? .setText ( diffStats ( diff ) ) ;
261274 this . toolbar . setEnabled ( true ) ;
262275 this . emptyWidget . hideWidget ( ) ;
263276 const mimeType = ( this . selectedUISourceCode as Workspace . UISourceCode . UISourceCode ) . mimeType ( ) ;
264277 this . diffContainer . style . display = 'block' ;
265- this . diffView . data = { diff, mimeType} ;
278+ if ( this . diffView ) {
279+ this . diffView . data = { diff, mimeType} ;
280+ }
266281 }
267282 }
268283}
@@ -284,3 +299,8 @@ export class ActionDelegate implements UI.ActionRegistration.ActionDelegate {
284299 return false ;
285300 }
286301}
302+
303+ function shouldRenderCombinedDiffView ( ) : boolean {
304+ const { hostConfig} = Root . Runtime ;
305+ return Boolean ( hostConfig . devToolsFreestyler ?. patching ) ;
306+ }
0 commit comments