@@ -35,10 +35,20 @@ export class SitePage extends Page<SitePageProps, SitePageState> {
35
35
36
36
async componentDidMount ( ) {
37
37
document . title = `${ this . state . siteId } – Fileset` ;
38
+ this . updateTable ( this . state . tab === undefined ? 'branch' : 'ref' ) ;
39
+ }
40
+
41
+ async componentWillReceiveProps ( props : SitePageProps ) {
42
+ this . setState ( { tab : props . tab } ) ;
43
+ this . updateTable ( props . tab === undefined ? 'branch' : 'ref' ) ;
44
+ }
45
+
46
+ async updateTable ( manifestType : string ) {
38
47
try {
39
48
this . setState ( { loading : true } ) ;
40
49
const resp : any = await rpc ( 'manifest.list' , {
41
50
site : this . state . siteId ,
51
+ manifestType : manifestType ,
42
52
} ) ;
43
53
this . setState ( {
44
54
loading : false ,
@@ -50,10 +60,6 @@ export class SitePage extends Page<SitePageProps, SitePageState> {
50
60
}
51
61
}
52
62
53
- async componentWillReceiveProps ( props : SitePageProps ) {
54
- this . setState ( { tab : props . tab } ) ;
55
- }
56
-
57
63
filterManifests ( manifests : Array < any > ) {
58
64
return manifests . sort (
59
65
( a , b ) => new Date ( b . modified ) . getTime ( ) - new Date ( a . modified ) . getTime ( )
@@ -92,24 +98,25 @@ export class SitePage extends Page<SitePageProps, SitePageState> {
92
98
</ Link >
93
99
</ div >
94
100
< div >
95
- { this . state . tab === undefined ? this . renderManifestTable ( ) : '' }
96
- { this . state . tab === 'history' ? this . renderManifestTable ( ) : '' }
101
+ { this . state . loading
102
+ ? this . renderLoading ( )
103
+ : this . renderManifestTable ( ) }
97
104
</ div >
98
105
</ div >
99
106
) ;
100
107
}
101
108
102
- renderManifestTable ( ) {
103
- return this . state . manifests && this . state . manifests . length ? (
109
+ renderStagingLinkTable ( ) {
110
+ return (
104
111
< div class = "SitePage__content__table" >
105
112
< table >
106
113
< thead >
107
114
< tr >
108
115
< th > Branch</ th >
109
- < th > Commit</ th >
116
+ < th data-extra-small > Commit</ th >
110
117
< th > Modified</ th >
111
- < th > Files</ th >
112
- < th > Staging link</ th >
118
+ < th data-extra-small > Files</ th >
119
+ < th data-extra-small > Staging link</ th >
113
120
</ tr >
114
121
</ thead >
115
122
< tbody >
@@ -148,6 +155,78 @@ export class SitePage extends Page<SitePageProps, SitePageState> {
148
155
</ tbody >
149
156
</ table >
150
157
</ div >
158
+ ) ;
159
+ }
160
+
161
+ renderHistoryTable ( ) {
162
+ return (
163
+ < div class = "SitePage__content__table" >
164
+ < table >
165
+ < thead >
166
+ < tr >
167
+ < th > Description</ th >
168
+ < th data-extra-small > Commit</ th >
169
+ < th > Modified</ th >
170
+ < th data-extra-small > Files</ th >
171
+ < th data-small > Links</ th >
172
+ </ tr >
173
+ </ thead >
174
+ < tbody >
175
+ { this . filterManifests ( this . state . manifests ) . map ( ( manifest , i ) => (
176
+ < tr >
177
+ < td >
178
+ { manifest . commit ? (
179
+ < div >
180
+ { manifest . commit . message } { ' ' }
181
+ < small > { manifest . commit . author . name } </ small >
182
+ </ div >
183
+ ) : (
184
+ < small > (unknown)</ small >
185
+ ) }
186
+ </ td >
187
+ < td >
188
+ < code > { manifest . ref . slice ( 0 , 7 ) } </ code >
189
+ </ td >
190
+ < td > { prettyDate ( manifest . modified ) } </ td >
191
+ < td > { Object . keys ( manifest . paths ) . length } </ td >
192
+ < td >
193
+ < a
194
+ class = "button button--tonal button--small"
195
+ href = { `/fileset/sites/${
196
+ this . state . siteId
197
+ } /${ encodeURIComponent ( manifest . ref . slice ( 0 , 7 ) ) } /`}
198
+ >
199
+ < span class = "material-icons-outlined" > view_list</ span >
200
+ Details
201
+ </ a >
202
+ < a
203
+ class = "button button--tonal button--small"
204
+ href = { createStagingLink (
205
+ window . location . href ,
206
+ manifest . site ,
207
+ '' ,
208
+ manifest . ref
209
+ ) }
210
+ >
211
+ < span class = "material-icons-outlined" > open_in_new</ span >
212
+ Staging
213
+ </ a >
214
+ </ td >
215
+ </ tr >
216
+ ) ) }
217
+ </ tbody >
218
+ </ table >
219
+ </ div >
220
+ ) ;
221
+ }
222
+
223
+ renderManifestTable ( ) {
224
+ return this . state . manifests && this . state . manifests . length ? (
225
+ this . state . tab === 'history' ? (
226
+ this . renderHistoryTable ( )
227
+ ) : (
228
+ this . renderStagingLinkTable ( )
229
+ )
151
230
) : (
152
231
< div class = "SitePage__content__empty" >
153
232
< div class = "SitePage__content__empty__headline" >
@@ -178,9 +257,7 @@ export class SitePage extends Page<SitePageProps, SitePageState> {
178
257
{ this . state . siteId }
179
258
</ Link >
180
259
</ div >
181
- < div class = "SitePage__content" >
182
- { this . state . loading ? this . renderLoading ( ) : this . renderTabSet ( ) }
183
- </ div >
260
+ < div class = "SitePage__content" > { this . renderTabSet ( ) } </ div >
184
261
</ div >
185
262
) ;
186
263
}
0 commit comments