@@ -6,14 +6,26 @@ import '../../../ui/legacy/components/data_grid/data_grid.js';
66
77import * as i18n from '../../../core/i18n/i18n.js' ;
88import type * as Protocol from '../../../generated/protocol.js' ;
9+ // inspectorCommonStyles is imported for the empty state styling that is used for the start view
10+ // eslint-disable-next-line rulesdir/es-modules-import
11+ import inspectorCommonStylesRaw from '../../../ui/legacy/inspectorCommon.css.js' ;
12+ import * as UI from '../../../ui/legacy/legacy.js' ;
913import * as Lit from '../../../ui/lit/lit.js' ;
14+ import * as VisualLogging from '../../../ui/visual_logging/visual_logging.js' ;
1015
1116import sharedStorageAccessGridStylesRaw from './sharedStorageAccessGrid.css.js' ;
1217
1318// TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
1419const sharedStorageAccessGridStyles = new CSSStyleSheet ( ) ;
1520sharedStorageAccessGridStyles . replaceSync ( sharedStorageAccessGridStylesRaw . cssContent ) ;
1621
22+ // TODO(crbug.com/391381439): Fully migrate off of constructed style sheets.
23+ const inspectorCommonStyles = new CSSStyleSheet ( ) ;
24+ inspectorCommonStyles . replaceSync ( inspectorCommonStylesRaw . cssContent ) ;
25+
26+ const SHARED_STORAGE_EXPLANATION_URL =
27+ 'https://developers.google.com/privacy-sandbox/private-advertising/shared-storage' ;
28+
1729const { render, html} = Lit ;
1830
1931const UIStrings = {
@@ -48,9 +60,23 @@ const UIStrings = {
4860 */
4961 eventParams : 'Optional Event Params' ,
5062 /**
51- *@description Text shown instead of a table when the table would be empty.
63+ *@description Text shown when no shared storage event is shown.
64+ * Shared storage allows to store and access data that can be shared across different sites.
65+ * A shared storage event is for example an access from a site to that storage.
5266 */
53- noEvents : 'No shared storage events recorded.' ,
67+ noEvents : 'No shared storage events detected' ,
68+ /**
69+ *@description Text shown when no shared storage event is shown. It explains the shared storage event page.
70+ * Shared storage allows to store and access data that can be shared across different sites.
71+ * A shared storage event is for example an access from a site to that storage.
72+ */
73+ sharedStorageDescription :
74+ 'On this page you can view, add, edit and delete shared storage key-value pairs and view shared storage events.' ,
75+ /**
76+ * @description Text used in a link to learn more about the topic.
77+ */
78+ learnMore : 'Learn more' ,
79+
5480} ;
5581
5682const str_ = i18n . i18n . registerUIStrings ( 'panels/application/components/SharedStorageAccessGrid.ts' , UIStrings ) ;
@@ -61,7 +87,7 @@ export class SharedStorageAccessGrid extends HTMLElement {
6187 #datastores: Array < Protocol . Storage . SharedStorageAccessedEvent > = [ ] ;
6288
6389 connectedCallback ( ) : void {
64- this . #shadow. adoptedStyleSheets = [ sharedStorageAccessGridStyles ] ;
90+ this . #shadow. adoptedStyleSheets = [ sharedStorageAccessGridStyles , inspectorCommonStyles ] ;
6591 this . #render( ) ;
6692 }
6793
@@ -71,55 +97,65 @@ export class SharedStorageAccessGrid extends HTMLElement {
7197 }
7298
7399 #render( ) : void {
74- // clang-format off
75- render ( html `
76- < div >
77- < span class ="heading "> ${ i18nString ( UIStrings . sharedStorage ) } </ span >
78- < devtools-icon class ="info-icon "
79- title =${ i18nString ( UIStrings . allSharedStorageEvents ) }
80- .data =${ { iconName : 'info' , color : 'var(--icon-default)' , width : '16px' } } >
81- </ devtools-icon >
82- ${ this . #renderGridOrNoDataMessage( ) }
83- </ div >
84- ` , this . #shadow, { host : this } ) ;
85- // clang-format on
100+ render ( html `${ this . #renderGridOrNoDataMessage( ) } ` , this . #shadow, { host : this } ) ;
86101 }
87102
88103 #renderGridOrNoDataMessage( ) : Lit . TemplateResult {
89104 if ( this . #datastores. length === 0 ) {
90- return html `< div
91- class ="no-events-message "> ${ i18nString ( UIStrings . noEvents ) } </ div > ` ;
105+ return html `
106+ < div class ="empty-state " jslog =${ VisualLogging . section ( ) . context ( 'empty-view' ) } >
107+ < div class ="empty-state-header "> ${ i18nString ( UIStrings . noEvents ) } </ div >
108+ < div class ="empty-state-description ">
109+ < span > ${ i18nString ( UIStrings . sharedStorageDescription ) } </ span >
110+ ${
111+ UI . XLink . XLink . create (
112+ SHARED_STORAGE_EXPLANATION_URL , i18nString ( UIStrings . learnMore ) , 'x-link' , undefined , 'learn-more' ) }
113+ </ div >
114+ </ div >
115+ ` ;
92116 }
117+ // clang-format off
93118 return html `
94- < devtools-data-grid striped inline @select =${ this . #onSelect} >
95- < table >
96- < tr >
97- < th id ="event-time " weight ="10 " sortable >
98- ${ i18nString ( UIStrings . eventTime ) }
99- </ th >
100- < th id ="event-type " weight ="10 " sortable >
101- ${ i18nString ( UIStrings . eventType ) }
102- </ th >
103- < th id ="event-owner-origin " weight ="10 " sortable >
104- ${ i18nString ( UIStrings . ownerOrigin ) }
105- </ th >
106- < th id ="event-params " weight ="10 " sortable >
107- ${ i18nString ( UIStrings . eventParams ) }
108- </ th >
109- </ tr >
110- ${ this . #datastores. map ( ( event , index ) => html `
111- < tr data-index =${ index } >
112- < td data-value =${ event . accessTime } >
113- ${ new Date ( 1e3 * event . accessTime ) . toLocaleString ( ) }
114- </ td >
115- < td > ${ event . type } </ td >
116- < td > ${ event . ownerOrigin } </ td >
117- < td > ${ JSON . stringify ( event . params ) } </ td >
119+ < div >
120+ < span class ="heading "> ${ i18nString ( UIStrings . sharedStorage ) } </ span >
121+ < devtools-icon class ="info-icon "
122+ title =${ i18nString ( UIStrings . allSharedStorageEvents ) }
123+ .data =${ { iconName : 'info' , color : 'var(--icon-default)' , width : '16px' } } >
124+ </ devtools-icon >
125+ < devtools-data-grid striped inline @select =${ this . #onSelect} >
126+ < table >
127+ < tr >
128+ < th id ="event-time " weight ="10 " sortable >
129+ ${ i18nString ( UIStrings . eventTime ) }
130+ </ th >
131+ < th id ="event-type " weight ="10 " sortable >
132+ ${ i18nString ( UIStrings . eventType ) }
133+ </ th >
134+ < th id ="event-owner-origin " weight ="10 " sortable >
135+ ${ i18nString ( UIStrings . ownerOrigin ) }
136+ </ th >
137+ < th id ="event-params " weight ="10 " sortable >
138+ ${ i18nString ( UIStrings . eventParams ) }
139+ </ th >
118140 </ tr >
119- ` ) }
120- </ table >
121- </ devtools-data-grid >
141+ ${
142+ this . #datastores. map ( ( event , index ) => html `
143+ < tr data-index =${ index } >
144+ < td data-value =${ event . accessTime } >
145+ ${
146+ new Date ( 1e3 * event . accessTime )
147+ . toLocaleString ( ) }
148+ </ td >
149+ < td > ${ event . type } </ td >
150+ < td > ${ event . ownerOrigin } </ td >
151+ < td > ${ JSON . stringify ( event . params ) } </ td >
152+ </ tr >
153+ ` ) }
154+ </ table >
155+ </ devtools-data-grid >
156+ </ div >
122157 ` ;
158+ // clang-format on
123159 }
124160
125161 #onSelect( event : CustomEvent < HTMLElement > ) : void {
0 commit comments