22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5+ import * as i18n from '../../../../core/i18n/i18n.js' ;
56import { assertNotNullOrUndefined } from '../../../../core/platform/platform.js' ;
67import * as SDK from '../../../../core/sdk/sdk.js' ;
78import type * as Protocol from '../../../../generated/protocol.js' ;
@@ -11,6 +12,8 @@ import * as CodeHighlighter from '../../../../ui/components/code_highlighter/cod
1112import * as LegacyWrapper from '../../../../ui/components/legacy_wrapper/legacy_wrapper.js' ;
1213import * as RenderCoordinator from '../../../../ui/components/render_coordinator/render_coordinator.js' ;
1314import * as TextEditor from '../../../../ui/components/text_editor/text_editor.js' ;
15+ // eslint-disable-next-line rulesdir/es-modules-import
16+ import inspectorCommonStylesRaw from '../../../../ui/legacy/inspectorCommon.css.js' ;
1417import type * as UI from '../../../../ui/legacy/legacy.js' ;
1518import * as Lit from '../../../../ui/lit/lit.js' ;
1619
@@ -20,8 +23,29 @@ import ruleSetDetailsViewStylesRaw from './RuleSetDetailsView.css.js';
2023const ruleSetDetailsViewStyles = new CSSStyleSheet ( ) ;
2124ruleSetDetailsViewStyles . replaceSync ( ruleSetDetailsViewStylesRaw . cssContent ) ;
2225
26+ // TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
27+ const inspectorCommonStyles = new CSSStyleSheet ( ) ;
28+ inspectorCommonStyles . replaceSync ( inspectorCommonStylesRaw . cssContent ) ;
29+
2330const { html} = Lit ;
2431
32+ const UIStrings = {
33+ /**
34+ *@description Text in RuleSetDetailsView of the Application panel if no element is selected. An element here is an item in a
35+ * table of speculation rules. Speculation rules define the rules when and which urls should be prefetched.
36+ * https://developer.chrome.com/docs/devtools/application/debugging-speculation-rules
37+ */
38+ noElementSelected : 'No element selected' ,
39+ /**
40+ *@description Text in RuleSetDetailsView of the Application panel if no element is selected. An element here is an item in a
41+ * table of speculation rules. Speculation rules define the rules when and which urls should be prefetched.
42+ * https://developer.chrome.com/docs/devtools/application/debugging-speculation-rules
43+ */
44+ selectAnElementForMoreDetails : 'Select an element for more details' ,
45+ } ;
46+ const str_ = i18n . i18n . registerUIStrings ( 'panels/application/preloading/components/RuleSetDetailsView.ts' , UIStrings ) ;
47+ const i18nString = i18n . i18n . getLocalizedString . bind ( undefined , str_ ) ;
48+
2549type RuleSet = Protocol . Preload . RuleSet ;
2650
2751const codeMirrorJsonType = await CodeHighlighter . CodeHighlighter . languageFromMIME ( 'application/json' ) ;
@@ -35,7 +59,7 @@ export class RuleSetDetailsView extends LegacyWrapper.LegacyWrapper.WrappableCom
3559 #editorState?: CodeMirror . EditorState ;
3660
3761 connectedCallback ( ) : void {
38- this . #shadow. adoptedStyleSheets = [ ruleSetDetailsViewStyles ] ;
62+ this . #shadow. adoptedStyleSheets = [ ruleSetDetailsViewStyles , inspectorCommonStyles ] ;
3963 }
4064
4165 set data ( data : RuleSetDetailsViewData ) {
@@ -50,7 +74,17 @@ export class RuleSetDetailsView extends LegacyWrapper.LegacyWrapper.WrappableCom
5074 async #render( ) : Promise < void > {
5175 await RenderCoordinator . write ( 'RuleSetDetailsView render' , async ( ) => {
5276 if ( this . #data === null ) {
53- Lit . render ( Lit . nothing , this . #shadow, { host : this } ) ;
77+ Lit . render (
78+ html `
79+ < div class ="placeholder ">
80+ < div class ="empty-state ">
81+ < span class ="empty-state-header "> ${ i18nString ( UIStrings . noElementSelected ) } </ span >
82+ < span class ="empty-state-description "> ${ i18nString ( UIStrings . selectAnElementForMoreDetails ) } </ span >
83+ </ div >
84+ </ div >
85+ ` ,
86+ this . #shadow, { host : this } ) ;
87+ // clang-format on
5488 return ;
5589 }
5690
0 commit comments