File tree Expand file tree Collapse file tree 4 files changed +37
-12
lines changed 
templates/repo/settings/webhook Expand file tree Collapse file tree 4 files changed +37
-12
lines changed Original file line number Diff line number Diff line change @@ -627,7 +627,7 @@ type UpdateAllowEditsForm struct {
627627//  |       _// __ \|  | _/ __ \\__  \  /  ___// __ \ 
628628//  |    |   \  ___/|  |_\  ___/ / __ \_\___ \\  ___/ 
629629//  |____|_  /\___  >____/\___  >____  /____  >\___  > 
630- //         \/     \/             \/     \/     \/     \/ 
630+ //         \/     \/          \/     \/     \/     \/ 
631631
632632// NewReleaseForm form for creating release 
633633type  NewReleaseForm  struct  {
Original file line number Diff line number Diff line change 5454		<h5>{{ctx.Locale.Tr "repo.settings.payload_optimization_files"}}</h5>
5555		<div class="field">
5656			<div class="ui checkbox">
57- 				<input name="payload_optimization_files_enable" type="checkbox" {{if .Webhook.IsFilesOptimizationEnabled}}checked{{end}} onchange="toggleLimitField('payload_optimization_files_limit', this.checked)" >
57+ 				<input name="payload_optimization_files_enable" type="checkbox" {{if .Webhook.IsFilesOptimizationEnabled}}checked{{end}}>
5858				<label>{{ctx.Locale.Tr "repo.settings.payload_optimization_enable"}}</label>
5959				<span class="help">{{ctx.Locale.Tr "repo.settings.payload_optimization_enable_desc"}}</span>
6060			</div>
6969		<h5>{{ctx.Locale.Tr "repo.settings.payload_optimization_commits"}}</h5>
7070		<div class="field">
7171			<div class="ui checkbox">
72- 				<input name="payload_optimization_commits_enable" type="checkbox" {{if .Webhook.IsCommitsOptimizationEnabled}}checked{{end}} onchange="toggleLimitField('payload_optimization_commits_limit', this.checked)" >
72+ 				<input name="payload_optimization_commits_enable" type="checkbox" {{if .Webhook.IsCommitsOptimizationEnabled}}checked{{end}}>
7373				<label>{{ctx.Locale.Tr "repo.settings.payload_optimization_enable"}}</label>
7474				<span class="help">{{ctx.Locale.Tr "repo.settings.payload_optimization_enable_desc"}}</span>
7575			</div>
8282	</div>
8383</div>
8484
85- <script>
86- function toggleLimitField(fieldName, enabled) {
87- 	const field = document.querySelector('input[name="' + fieldName + '"]');
88- 	if (field) {
89- 		field.disabled = !enabled;
90- 	}
91- }
92- </script>
93- 
9485<div class="field">
9586	<h4>{{ctx.Locale.Tr "repo.settings.event_desc"}}</h4>
9687	<div class="grouped event type fields">
Original file line number Diff line number Diff line change 1+ /** 
2+  * Webhook settings functionality 
3+  */ 
4+ 
5+ function  toggleLimitField ( fieldName : string ,  enabled : boolean ) : void { 
6+   const  field  =  document . querySelector < HTMLInputElement > ( `input[name="${ fieldName }  ) ; 
7+   if  ( field )  { 
8+     field . disabled  =  ! enabled ; 
9+   } 
10+ } 
11+ 
12+ export  function  initRepoSettingsWebhook ( ) : void { 
13+   if  ( ! document . querySelector ( '.page-content.repository.settings.webhook' ) )  return ; 
14+ 
15+   // Add event listeners for payload optimization checkboxes 
16+   const  filesEnableCheckbox  =  document . querySelector < HTMLInputElement > ( 'input[name="payload_optimization_files_enable"]' ) ; 
17+   const  commitsEnableCheckbox  =  document . querySelector < HTMLInputElement > ( 'input[name="payload_optimization_commits_enable"]' ) ; 
18+ 
19+   if  ( filesEnableCheckbox )  { 
20+     filesEnableCheckbox . addEventListener ( 'change' ,  ( e )  =>  { 
21+       const  target  =  e . target  as  HTMLInputElement ; 
22+       toggleLimitField ( 'payload_optimization_files_limit' ,  target . checked ) ; 
23+     } ) ; 
24+   } 
25+ 
26+   if  ( commitsEnableCheckbox )  { 
27+     commitsEnableCheckbox . addEventListener ( 'change' ,  ( e )  =>  { 
28+       const  target  =  e . target  as  HTMLInputElement ; 
29+       toggleLimitField ( 'payload_optimization_commits_limit' ,  target . checked ) ; 
30+     } ) ; 
31+   } 
32+ } 
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import {createMonaco} from './codeeditor.ts';
33import  { onInputDebounce ,  queryElems ,  toggleElem }  from  '../utils/dom.ts' ; 
44import  { POST }  from  '../modules/fetch.ts' ; 
55import  { initRepoSettingsBranchesDrag }  from  './repo-settings-branches.ts' ; 
6+ import  { initRepoSettingsWebhook }  from  './repo-settings-webhook.ts' ; 
67import  { fomanticQuery }  from  '../modules/fomantic/base.ts' ; 
78
89const  { appSubUrl,  csrfToken}  =  window . config ; 
@@ -152,4 +153,5 @@ export function initRepoSettings() {
152153  initRepoSettingsSearchTeamBox ( ) ; 
153154  initRepoSettingsGitHook ( ) ; 
154155  initRepoSettingsBranchesDrag ( ) ; 
156+   initRepoSettingsWebhook ( ) ; 
155157} 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments