mirror of
				https://github.com/scinote-eln/scinote-web.git
				synced 2025-10-31 16:49:40 +08:00 
			
		
		
		
	Merge pull request #8483 from artoscinote/ma_SCI_11896
Add option to skip repository templates feature [SCI-11896]
This commit is contained in:
		
						commit
						84e030b1e6
					
				
					 2 changed files with 9 additions and 3 deletions
				
			
		|  | @ -22,7 +22,7 @@ | ||||||
|                        :placeholder="i18n.t('repositories.index.modal_create.name_placeholder')" /> |                        :placeholder="i18n.t('repositories.index.modal_create.name_placeholder')" /> | ||||||
|               </div> |               </div> | ||||||
|             </div> |             </div> | ||||||
|             <div> |             <div v-if="repositoryTemplatesAvailable"> | ||||||
|               <label class="sci-label" data-e2e="e2e-LB-newInventoryModal-inventoryTemplate"> |               <label class="sci-label" data-e2e="e2e-LB-newInventoryModal-inventoryTemplate"> | ||||||
|                 {{ i18n.t("repositories.index.modal_create.repository_template_label") }} |                 {{ i18n.t("repositories.index.modal_create.repository_template_label") }} | ||||||
|               </label> |               </label> | ||||||
|  | @ -58,7 +58,7 @@ | ||||||
|           </div> |           </div> | ||||||
|           <div class="modal-footer"> |           <div class="modal-footer"> | ||||||
|             <button type="button" class="btn btn-secondary" data-dismiss="modal" data-e2e="e2e-BT-newInventoryModal-cancel">{{ i18n.t('general.cancel') }}</button> |             <button type="button" class="btn btn-secondary" data-dismiss="modal" data-e2e="e2e-BT-newInventoryModal-cancel">{{ i18n.t('general.cancel') }}</button> | ||||||
|             <button class="btn btn-primary" type="submit" :disabled="submitting || !validName || !repositoryTemplate" data-e2e="e2e-BT-newInventoryModal-create"> |             <button class="btn btn-primary" type="submit" :disabled="submitting || !validName || (repositoryTemplatesAvailable && !repositoryTemplate)" data-e2e="e2e-BT-newInventoryModal-create"> | ||||||
|               {{ i18n.t('repositories.index.modal_create.submit') }} |               {{ i18n.t('repositories.index.modal_create.submit') }} | ||||||
|             </button> |             </button> | ||||||
|           </div> |           </div> | ||||||
|  | @ -115,6 +115,9 @@ export default { | ||||||
|     repositoryTemplateUrl() { |     repositoryTemplateUrl() { | ||||||
|       return repository_templates_path(); |       return repository_templates_path(); | ||||||
|     }, |     }, | ||||||
|  |     repositoryTemplatesAvailable() { | ||||||
|  |       return this.repositoryTemplates && this.repositoryTemplates.length !== 0; | ||||||
|  |     }, | ||||||
|     validName() { |     validName() { | ||||||
|       return this.name.length >= GLOBAL_CONSTANTS.NAME_MIN_LENGTH; |       return this.name.length >= GLOBAL_CONSTANTS.NAME_MIN_LENGTH; | ||||||
|     } |     } | ||||||
|  | @ -154,7 +157,7 @@ export default { | ||||||
|       axios.get(this.repositoryTemplateUrl) |       axios.get(this.repositoryTemplateUrl) | ||||||
|         .then((response) => { |         .then((response) => { | ||||||
|           this.repositoryTemplates = response.data.data; |           this.repositoryTemplates = response.data.data; | ||||||
|           [this.repositoryTemplate] = this.repositoryTemplates[0]; |           if (this.repositoryTemplates.length !== 0) [this.repositoryTemplate] = this.repositoryTemplates[0]; | ||||||
|         }); |         }); | ||||||
|     }, |     }, | ||||||
|     loadColumnsInfo(e) { |     loadColumnsInfo(e) { | ||||||
|  |  | ||||||
|  | @ -2,6 +2,9 @@ | ||||||
| 
 | 
 | ||||||
| class AddRepositoryTemplatesToTeams < ActiveRecord::Migration[7.0] | class AddRepositoryTemplatesToTeams < ActiveRecord::Migration[7.0] | ||||||
|   def up |   def up | ||||||
|  |     # don't create templates if feature is disabled | ||||||
|  |     return unless ENV.fetch('SCINOTE_REPOSITORY_TEMPLATES_ENABLED', false) | ||||||
|  | 
 | ||||||
|     Team.find_each do |team| |     Team.find_each do |team| | ||||||
|       RepositoryTemplate.default.update!(team: team) |       RepositoryTemplate.default.update!(team: team) | ||||||
|       RepositoryTemplate.cell_lines.update!(team: team) |       RepositoryTemplate.cell_lines.update!(team: team) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue