#12248 closed enhancement (fixed)
Hide repository admin panel if no connectors enabled
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.2 |
Component: | admin/web | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
|
||
API Changes: | |||
Internal Changes: |
Description
The proposed change is to have the Manage Repositories admin panel visible only when at least one repository connector is enabled (comment:2:ticket:11713).
Attachments (0)
Change History (11)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Committed to trunk in [14684].
comment:3 by , 9 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Functional tests are failing.
comment:4 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Failing functional tests fixed in [14687].
comment:5 by , 8 years ago
Since [14684], repository admin page wouldn't be shown if no repository connectors.
If a repository with sync_per_request
is defined, I get warning Can't synchronize with repository ...
. However, it is unable to disable sync_per_request
caused by invisible repository admin page and no repository connectors.
I consider we should show repository admin page if Trac environment has repositories and no repository connectors. Thoughts?
-
trac/versioncontrol/admin.py
diff --git a/trac/versioncontrol/admin.py b/trac/versioncontrol/admin.py index 57e119e53..829b86b44 100644
a b class RepositoryAdminPanel(Component): 179 179 # IAdminPanelProvider methods 180 180 181 181 def get_admin_panels(self, req): 182 types = RepositoryManager(self.env).get_supported_types() 183 if types and 'VERSIONCONTROL_ADMIN' \ 184 in req.perm('admin', 'versioncontrol/repository'): 182 rm = RepositoryManager(self.env) 183 if 'VERSIONCONTROL_ADMIN' in \ 184 req.perm('admin', 'versioncontrol/repository') and \ 185 (rm.get_supported_types() or rm.get_all_repositories()): 185 186 yield ('versioncontrol', _('Version Control'), 'repository', 186 187 _('Repositories')) 187 188
comment:6 by , 8 years ago
Good find. I think we should definitely deal with this corner-case. What about skipping repository synchronization in RepositoryManager.pre_process_request
?
-
trac/versioncontrol/api.py
diff --git a/trac/versioncontrol/api.py b/trac/versioncontrol/api.py index a6fd337..3aadbf6 100644
a b class RepositoryManager(Component): 356 356 357 357 def pre_process_request(self, req, handler): 358 358 from trac.web.chrome import Chrome, add_warning 359 if handler is not Chrome(self.env) :359 if handler is not Chrome(self.env) and self.get_supported_types(): 360 360 for repo_info in self.get_all_repositories().values(): 361 361 if not as_bool(repo_info.get('sync_per_request')): 362 362 continue
comment:7 by , 8 years ago
I think it would be better to skip sync if the repository type isn't supported for each repository with sync_per_request
.
-
trac/versioncontrol/api.py
diff --git a/trac/versioncontrol/api.py b/trac/versioncontrol/api.py index a6fd3377a..94e7385d5 100644
a b class RepositoryManager(Component): 357 357 def pre_process_request(self, req, handler): 358 358 from trac.web.chrome import Chrome, add_warning 359 359 if handler is not Chrome(self.env): 360 supported_types = set(self.get_supported_types()) 360 361 for repo_info in self.get_all_repositories().values(): 361 362 if not as_bool(repo_info.get('sync_per_request')): 362 363 continue 364 rtype = repo_info.get('type') or self.default_repository_type 365 if rtype not in supported_types: 366 continue 363 367 start = time_now() 364 368 repo_name = repo_info['name'] or '(default)' 365 369 try:
comment:8 by , 8 years ago
Checking supported type for each repository sounds good. I'd also be okay with equivalent functionality that uses exception handling.
-
trac/versioncontrol/api.py
diff --git a/trac/versioncontrol/api.py b/trac/versioncontrol/api.py index a6fd337..5400eeb 100644
a b class InvalidRepository(TracError): 40 40 """Exception raised when a repository is invalid.""" 41 41 42 42 43 class InvalidConnector(TracError): 44 """Exception raised when a repository connector is invalid.""" 45 46 43 47 class IRepositoryConnector(Interface): 44 48 """Provide support for a specific version control system.""" 45 49 … … class RepositoryManager(Component): 365 369 try: 366 370 repo = self.get_repository(repo_info['name']) 367 371 repo.sync() 372 except InvalidConnector: 373 continue 368 374 except TracError as e: 369 375 add_warning(req, 370 376 _("Can't synchronize with repository \"%(name)s\" " … … class RepositoryManager(Component): 565 571 :return: if no corresponding repository was defined, 566 572 simply return `None`. 567 573 574 :raises InvalidConnector: if the repository connector cannot be 575 opened. 568 576 :raises InvalidRepository: if the repository cannot be opened. 569 577 """ 570 578 reponame = reponame or '' … … class RepositoryManager(Component): 768 776 if prio >= 0: # no error condition 769 777 return connector 770 778 else: 771 raise TracError(779 raise InvalidConnector( 772 780 _('Unsupported version control system "%(name)s"' 773 781 ': %(error)s', name=rtype, 774 782 error=to_unicode(connector.error))) 775 783 else: 776 raise TracError(784 raise InvalidConnector( 777 785 _('Unsupported version control system "%(name)s": ' 778 786 'Can\'t find an appropriate component, maybe the ' 779 787 'corresponding plugin was not enabled? ', name=rtype))
comment:11 by , 8 years ago
Release Notes: | modified (diff) |
---|
Proposed changes in log:rjollos.git:t12248_hide_repository_admin_panels.