99 updateSourceFilesToShare ,
1010 fetchSourceFilesToShare ,
1111 cancelSourceCodeFetch ,
12+ setSourceSharingDownloadedOnly ,
1213 turnOnSourceCodeSharing ,
1314 encodeSanitizedProfile ,
1415} from 'firefox-profiler/actions/publish' ;
@@ -18,6 +19,7 @@ import {
1819 getSourceCodeSharingStats ,
1920 getSourceFilesToFetch ,
2021 getSourceCodeFetchState ,
22+ getSourceSharingDownloadedOnly ,
2123 getSourceCodeSharingSummary ,
2224 getSourceFileTree ,
2325 getSourceFilesForOfferedPresets ,
@@ -100,6 +102,7 @@ type StateProps = {
100102 readonly sourceCodeSharingStats : SourceCodeSharingStats ;
101103 readonly sourceFilesToFetch : ReadonlySet < IndexIntoSourceTable > ;
102104 readonly sourceCodeFetchState : SourceCodeFetchState ;
105+ readonly sourceSharingDownloadedOnly : boolean ;
103106 readonly sourceFileTree : SourceFileTreeNode [ ] ;
104107 readonly sourceFilesToShare : ReadonlySet < IndexIntoSourceTable > ;
105108 readonly sourceFilesForPresets : Map <
@@ -114,6 +117,7 @@ type DispatchProps = {
114117 readonly updateSourceFilesToShare : typeof updateSourceFilesToShare ;
115118 readonly fetchSourceFilesToShare : typeof fetchSourceFilesToShare ;
116119 readonly cancelSourceCodeFetch : typeof cancelSourceCodeFetch ;
120+ readonly setSourceSharingDownloadedOnly : typeof setSourceSharingDownloadedOnly ;
117121 readonly turnOnSourceCodeSharing : typeof turnOnSourceCodeSharing ;
118122 readonly encodeSanitizedProfile : typeof encodeSanitizedProfile ;
119123} ;
@@ -159,6 +163,13 @@ class PublishSourceCodeSectionImpl extends React.PureComponent<Props> {
159163 this . props . encodeSanitizedProfile ( mode ) ;
160164 } ;
161165
166+ _onToggleDownloadedOnly = ( e : React . ChangeEvent < HTMLInputElement > ) => {
167+ this . props . setSourceSharingDownloadedOnly (
168+ this . props . mode ,
169+ e . target . checked
170+ ) ;
171+ } ;
172+
162173 _onFetchSourceFiles = ( ) => {
163174 this . props . fetchSourceFilesToShare ( this . props . mode ) ;
164175 } ;
@@ -262,43 +273,70 @@ class PublishSourceCodeSectionImpl extends React.PureComponent<Props> {
262273 }
263274
264275 _renderPresets ( ) {
265- const { mode, activeSourceSharingPreset, sourceFilesForPresets } =
266- this . props ;
267- if ( sourceFilesForPresets . size < 2 ) {
268- return null ;
269- }
276+ const {
277+ mode,
278+ activeSourceSharingPreset,
279+ sourceFilesForPresets,
280+ sourceCodeSharingStats,
281+ sourceSharingDownloadedOnly,
282+ } = this . props ;
283+
284+ const showPresets = sourceFilesForPresets . size >= 2 ;
285+ // The downloaded-only option only matters while some pickable file would
286+ // have to be fetched.
287+ const showDownloadedOnly =
288+ sourceCodeSharingStats . pickableFileCount >
289+ sourceCodeSharingStats . downloadedFileCount ;
270290
271291 const presets : SourceSharingPreset [ ] = [ ...sourceFilesForPresets . keys ( ) ] ;
272292 if ( activeSourceSharingPreset === 'custom' ) {
273293 presets . push ( 'custom' ) ;
274294 }
275295
276296 return (
277- < fieldset className = "publishPanelSourceCodePresets" >
278- < Localized id = "MenuButtons--publish--source-code-preset-legend" >
279- < legend className = "publishPanelSourceCodePresetsLegend" >
280- Include:
281- </ legend >
282- </ Localized >
283- { presets . map ( ( preset ) => (
284- < label
285- key = { preset }
286- className = "photon-label publishPanelSourceCodePresetLabel"
287- >
297+ < >
298+ { showPresets ? (
299+ < fieldset className = "publishPanelSourceCodePresets" >
300+ < Localized id = "MenuButtons--publish--source-code-preset-legend" >
301+ < legend className = "publishPanelSourceCodePresetsLegend" >
302+ Include:
303+ </ legend >
304+ </ Localized >
305+ { presets . map ( ( preset ) => (
306+ < label
307+ key = { preset }
308+ className = "photon-label publishPanelSourceCodePresetLabel"
309+ >
310+ < input
311+ type = "radio"
312+ className = "photon-radio photon-radio-micro"
313+ name = { `sourceCodePreset-${ mode } ` }
314+ value = { preset }
315+ checked = { activeSourceSharingPreset === preset }
316+ // "Custom" only reports the state of the tree.
317+ disabled = { this . _isUploading ( ) || preset === 'custom' }
318+ onChange = { this . _onPresetChange }
319+ />
320+ < Localized id = { PRESET_L10N_IDS [ preset ] } />
321+ </ label >
322+ ) ) }
323+ </ fieldset >
324+ ) : null }
325+ { showDownloadedOnly ? (
326+ < label className = "photon-label publishPanelSourceCodeDownloadedOnly" >
288327 < input
289- type = "radio"
290- className = "photon-radio photon-radio-micro"
291- name = { `sourceCodePreset-${ mode } ` }
292- value = { preset }
293- checked = { activeSourceSharingPreset === preset }
294- // "Custom" only reports the state of the tree.
295- disabled = { this . _isUploading ( ) || preset === 'custom' }
296- onChange = { this . _onPresetChange }
328+ type = "checkbox"
329+ className = "photon-checkbox photon-checkbox-micro"
330+ checked = { sourceSharingDownloadedOnly }
331+ disabled = { this . _isUploading ( ) }
332+ onChange = { this . _onToggleDownloadedOnly }
297333 />
298- < Localized id = { PRESET_L10N_IDS [ preset ] } />
334+ < Localized id = "MenuButtons--publish--source-code-downloaded-only" >
335+ Only already downloaded files
336+ </ Localized >
299337 </ label >
300- ) ) }
301- </ fieldset >
338+ ) : null }
339+ </ >
302340 ) ;
303341 }
304342
@@ -394,16 +432,18 @@ export const PublishSourceCodeSection = explicitConnect<
394432 sourceCodeSharingStats : getSourceCodeSharingStats ( state ) ,
395433 sourceFilesToFetch : getSourceFilesToFetch ( state , mode ) ,
396434 sourceCodeFetchState : getSourceCodeFetchState ( state ) ,
435+ sourceSharingDownloadedOnly : getSourceSharingDownloadedOnly ( state , mode ) ,
397436 sourceFileTree : getSourceFileTree ( state ) ,
398437 sourceFilesToShare : getSourceFilesToShare ( state , mode ) ,
399- sourceFilesForPresets : getSourceFilesForOfferedPresets ( state ) ,
438+ sourceFilesForPresets : getSourceFilesForOfferedPresets ( state , mode ) ,
400439 activeSourceSharingPreset : getActiveSourceSharingPreset ( state , mode ) ,
401440 sourceCodeSharingSummary : getSourceCodeSharingSummary ( state , mode ) ,
402441 } ) ,
403442 mapDispatchToProps : {
404443 updateSourceFilesToShare,
405444 fetchSourceFilesToShare,
406445 cancelSourceCodeFetch,
446+ setSourceSharingDownloadedOnly,
407447 turnOnSourceCodeSharing,
408448 encodeSanitizedProfile,
409449 } ,
0 commit comments