Show More
@@ -0,0 +1,51 b'' | |||||
|
1 | ## -*- coding: utf-8 -*- | |||
|
2 | <%inherit file="/base/base.mako"/> | |||
|
3 | ||||
|
4 | <%def name="title()"> | |||
|
5 | ${_('Settings administration')} | |||
|
6 | %if c.rhodecode_name: | |||
|
7 | · ${h.branding(c.rhodecode_name)} | |||
|
8 | %endif | |||
|
9 | </%def> | |||
|
10 | ||||
|
11 | <%def name="breadcrumbs_links()"> | |||
|
12 | ${h.link_to(_('Admin'),h.route_path('admin_home'))} | |||
|
13 | » | |||
|
14 | ${_('Integrations')} | |||
|
15 | </%def> | |||
|
16 | ||||
|
17 | <%def name="menu_bar_nav()"> | |||
|
18 | ${self.menu_items(active='admin')} | |||
|
19 | </%def> | |||
|
20 | ||||
|
21 | <%def name="side_bar_nav()"> | |||
|
22 | <li class="active"> | |||
|
23 | <a href="${h.route_path('global_integrations_home')}">Global</a> | |||
|
24 | </li> | |||
|
25 | </%def> | |||
|
26 | ||||
|
27 | <%def name="main_content()"> | |||
|
28 | <%include file="/admin/settings/settings_${c.active}.mako"/> | |||
|
29 | </%def> | |||
|
30 | ||||
|
31 | <%def name="main()"> | |||
|
32 | <div class="box"> | |||
|
33 | <div class="title"> | |||
|
34 | ${self.admin_menu()} | |||
|
35 | </div> | |||
|
36 | ||||
|
37 | ##main | |||
|
38 | <div class='sidebar-col-wrapper'> | |||
|
39 | <div class="sidebar"> | |||
|
40 | <ul class="nav nav-pills nav-stacked"> | |||
|
41 | ${self.side_bar_nav()} | |||
|
42 | </ul> | |||
|
43 | </div> | |||
|
44 | ||||
|
45 | <div class="main-content-auto-width"> | |||
|
46 | ${self.main_content()} | |||
|
47 | </div> | |||
|
48 | </div> | |||
|
49 | </div> | |||
|
50 | ||||
|
51 | </%def> |
@@ -1,148 +1,146 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2016-2019 RhodeCode GmbH |
|
3 | # Copyright (C) 2016-2019 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 |
|
21 | |||
22 | import logging |
|
22 | import logging | |
23 | import collections |
|
23 | import collections | |
24 |
|
24 | |||
25 | from zope.interface import implementer |
|
25 | from zope.interface import implementer | |
26 |
|
26 | |||
27 | from rhodecode.apps._base.interfaces import IAdminNavigationRegistry |
|
27 | from rhodecode.apps._base.interfaces import IAdminNavigationRegistry | |
28 | from rhodecode.lib.utils2 import str2bool |
|
28 | from rhodecode.lib.utils2 import str2bool | |
29 | from rhodecode.translation import _ |
|
29 | from rhodecode.translation import _ | |
30 |
|
30 | |||
31 |
|
31 | |||
32 | log = logging.getLogger(__name__) |
|
32 | log = logging.getLogger(__name__) | |
33 |
|
33 | |||
34 | NavListEntry = collections.namedtuple( |
|
34 | NavListEntry = collections.namedtuple( | |
35 | 'NavListEntry', ['key', 'name', 'url', 'active_list']) |
|
35 | 'NavListEntry', ['key', 'name', 'url', 'active_list']) | |
36 |
|
36 | |||
37 |
|
37 | |||
38 | class NavEntry(object): |
|
38 | class NavEntry(object): | |
39 | """ |
|
39 | """ | |
40 | Represents an entry in the admin navigation. |
|
40 | Represents an entry in the admin navigation. | |
41 |
|
41 | |||
42 | :param key: Unique identifier used to store reference in an OrderedDict. |
|
42 | :param key: Unique identifier used to store reference in an OrderedDict. | |
43 | :param name: Display name, usually a translation string. |
|
43 | :param name: Display name, usually a translation string. | |
44 | :param view_name: Name of the view, used generate the URL. |
|
44 | :param view_name: Name of the view, used generate the URL. | |
45 | :param active_list: list of urls that we select active for this element |
|
45 | :param active_list: list of urls that we select active for this element | |
46 | """ |
|
46 | """ | |
47 |
|
47 | |||
48 | def __init__(self, key, name, view_name, active_list=None): |
|
48 | def __init__(self, key, name, view_name, active_list=None): | |
49 | self.key = key |
|
49 | self.key = key | |
50 | self.name = name |
|
50 | self.name = name | |
51 | self.view_name = view_name |
|
51 | self.view_name = view_name | |
52 | self._active_list = active_list or [] |
|
52 | self._active_list = active_list or [] | |
53 |
|
53 | |||
54 | def generate_url(self, request): |
|
54 | def generate_url(self, request): | |
55 | return request.route_path(self.view_name) |
|
55 | return request.route_path(self.view_name) | |
56 |
|
56 | |||
57 | def get_localized_name(self, request): |
|
57 | def get_localized_name(self, request): | |
58 | return request.translate(self.name) |
|
58 | return request.translate(self.name) | |
59 |
|
59 | |||
60 | @property |
|
60 | @property | |
61 | def active_list(self): |
|
61 | def active_list(self): | |
62 | active_list = [self.key] |
|
62 | active_list = [self.key] | |
63 | if self._active_list: |
|
63 | if self._active_list: | |
64 | active_list = self._active_list |
|
64 | active_list = self._active_list | |
65 | return active_list |
|
65 | return active_list | |
66 |
|
66 | |||
67 |
|
67 | |||
68 | @implementer(IAdminNavigationRegistry) |
|
68 | @implementer(IAdminNavigationRegistry) | |
69 | class NavigationRegistry(object): |
|
69 | class NavigationRegistry(object): | |
70 |
|
70 | |||
71 | _base_entries = [ |
|
71 | _base_entries = [ | |
72 | NavEntry('global', _('Global'), |
|
72 | NavEntry('global', _('Global'), | |
73 | 'admin_settings_global'), |
|
73 | 'admin_settings_global'), | |
74 | NavEntry('vcs', _('VCS'), |
|
74 | NavEntry('vcs', _('VCS'), | |
75 | 'admin_settings_vcs'), |
|
75 | 'admin_settings_vcs'), | |
76 | NavEntry('visual', _('Visual'), |
|
76 | NavEntry('visual', _('Visual'), | |
77 | 'admin_settings_visual'), |
|
77 | 'admin_settings_visual'), | |
78 | NavEntry('mapping', _('Remap and Rescan'), |
|
78 | NavEntry('mapping', _('Remap and Rescan'), | |
79 | 'admin_settings_mapping'), |
|
79 | 'admin_settings_mapping'), | |
80 | NavEntry('issuetracker', _('Issue Tracker'), |
|
80 | NavEntry('issuetracker', _('Issue Tracker'), | |
81 | 'admin_settings_issuetracker'), |
|
81 | 'admin_settings_issuetracker'), | |
82 | NavEntry('email', _('Email'), |
|
82 | NavEntry('email', _('Email'), | |
83 | 'admin_settings_email'), |
|
83 | 'admin_settings_email'), | |
84 | NavEntry('hooks', _('Hooks'), |
|
84 | NavEntry('hooks', _('Hooks'), | |
85 | 'admin_settings_hooks'), |
|
85 | 'admin_settings_hooks'), | |
86 | NavEntry('search', _('Full Text Search'), |
|
86 | NavEntry('search', _('Full Text Search'), | |
87 | 'admin_settings_search'), |
|
87 | 'admin_settings_search'), | |
88 | NavEntry('integrations', _('Integrations'), |
|
|||
89 | 'global_integrations_home'), |
|
|||
90 | NavEntry('system', _('System Info'), |
|
88 | NavEntry('system', _('System Info'), | |
91 | 'admin_settings_system'), |
|
89 | 'admin_settings_system'), | |
92 | NavEntry('exceptions', _('Exceptions Tracker'), |
|
90 | NavEntry('exceptions', _('Exceptions Tracker'), | |
93 | 'admin_settings_exception_tracker', |
|
91 | 'admin_settings_exception_tracker', | |
94 | active_list=['exceptions', 'exceptions_browse']), |
|
92 | active_list=['exceptions', 'exceptions_browse']), | |
95 | NavEntry('process_management', _('Processes'), |
|
93 | NavEntry('process_management', _('Processes'), | |
96 | 'admin_settings_process_management'), |
|
94 | 'admin_settings_process_management'), | |
97 | NavEntry('sessions', _('User Sessions'), |
|
95 | NavEntry('sessions', _('User Sessions'), | |
98 | 'admin_settings_sessions'), |
|
96 | 'admin_settings_sessions'), | |
99 | NavEntry('open_source', _('Open Source Licenses'), |
|
97 | NavEntry('open_source', _('Open Source Licenses'), | |
100 | 'admin_settings_open_source'), |
|
98 | 'admin_settings_open_source'), | |
101 | NavEntry('automation', _('Automation'), |
|
99 | NavEntry('automation', _('Automation'), | |
102 | 'admin_settings_automation') |
|
100 | 'admin_settings_automation') | |
103 | ] |
|
101 | ] | |
104 |
|
102 | |||
105 | _labs_entry = NavEntry('labs', _('Labs'), |
|
103 | _labs_entry = NavEntry('labs', _('Labs'), | |
106 | 'admin_settings_labs') |
|
104 | 'admin_settings_labs') | |
107 |
|
105 | |||
108 | def __init__(self, labs_active=False): |
|
106 | def __init__(self, labs_active=False): | |
109 | self._registered_entries = collections.OrderedDict() |
|
107 | self._registered_entries = collections.OrderedDict() | |
110 | for item in self.__class__._base_entries: |
|
108 | for item in self.__class__._base_entries: | |
111 | self._registered_entries[item.key] = item |
|
109 | self._registered_entries[item.key] = item | |
112 |
|
110 | |||
113 | if labs_active: |
|
111 | if labs_active: | |
114 | self.add_entry(self._labs_entry) |
|
112 | self.add_entry(self._labs_entry) | |
115 |
|
113 | |||
116 | def add_entry(self, entry): |
|
114 | def add_entry(self, entry): | |
117 | self._registered_entries[entry.key] = entry |
|
115 | self._registered_entries[entry.key] = entry | |
118 |
|
116 | |||
119 | def get_navlist(self, request): |
|
117 | def get_navlist(self, request): | |
120 | nav_list = [ |
|
118 | nav_list = [ | |
121 | NavListEntry(i.key, i.get_localized_name(request), |
|
119 | NavListEntry(i.key, i.get_localized_name(request), | |
122 | i.generate_url(request), i.active_list) |
|
120 | i.generate_url(request), i.active_list) | |
123 | for i in self._registered_entries.values()] |
|
121 | for i in self._registered_entries.values()] | |
124 | return nav_list |
|
122 | return nav_list | |
125 |
|
123 | |||
126 |
|
124 | |||
127 | def navigation_registry(request, registry=None): |
|
125 | def navigation_registry(request, registry=None): | |
128 | """ |
|
126 | """ | |
129 | Helper that returns the admin navigation registry. |
|
127 | Helper that returns the admin navigation registry. | |
130 | """ |
|
128 | """ | |
131 | pyramid_registry = registry or request.registry |
|
129 | pyramid_registry = registry or request.registry | |
132 | nav_registry = pyramid_registry.queryUtility(IAdminNavigationRegistry) |
|
130 | nav_registry = pyramid_registry.queryUtility(IAdminNavigationRegistry) | |
133 | return nav_registry |
|
131 | return nav_registry | |
134 |
|
132 | |||
135 |
|
133 | |||
136 | def navigation_list(request): |
|
134 | def navigation_list(request): | |
137 | """ |
|
135 | """ | |
138 | Helper that returns the admin navigation as list of NavListEntry objects. |
|
136 | Helper that returns the admin navigation as list of NavListEntry objects. | |
139 | """ |
|
137 | """ | |
140 | return navigation_registry(request).get_navlist(request) |
|
138 | return navigation_registry(request).get_navlist(request) | |
141 |
|
139 | |||
142 |
|
140 | |||
143 | def includeme(config): |
|
141 | def includeme(config): | |
144 | # Create admin navigation registry and add it to the pyramid registry. |
|
142 | # Create admin navigation registry and add it to the pyramid registry. | |
145 | settings = config.get_settings() |
|
143 | settings = config.get_settings() | |
146 | labs_active = str2bool(settings.get('labs_settings_active', False)) |
|
144 | labs_active = str2bool(settings.get('labs_settings_active', False)) | |
147 | navigation_registry_instance = NavigationRegistry(labs_active=labs_active) |
|
145 | navigation_registry_instance = NavigationRegistry(labs_active=labs_active) | |
148 | config.registry.registerUtility(navigation_registry_instance) |
|
146 | config.registry.registerUtility(navigation_registry_instance) |
@@ -1,42 +1,42 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <%! |
|
2 | <%! | |
3 | def inherit(context): |
|
3 | def inherit(context): | |
4 | if context['c'].repo: |
|
4 | if context['c'].repo: | |
5 | return "/admin/repos/repo_edit.mako" |
|
5 | return "/admin/repos/repo_edit.mako" | |
6 | elif context['c'].repo_group: |
|
6 | elif context['c'].repo_group: | |
7 | return "/admin/repo_groups/repo_group_edit.mako" |
|
7 | return "/admin/repo_groups/repo_group_edit.mako" | |
8 | else: |
|
8 | else: | |
9 |
return "/admin/ |
|
9 | return "/admin/integrations/global.mako" | |
10 | %> |
|
10 | %> | |
11 | <%inherit file="${inherit(context)}" /> |
|
11 | <%inherit file="${inherit(context)}" /> | |
12 |
|
12 | |||
13 | <%def name="title()"> |
|
13 | <%def name="title()"> | |
14 | ${_('Integrations Settings')} |
|
14 | ${_('Integrations Settings')} | |
15 | %if c.rhodecode_name: |
|
15 | %if c.rhodecode_name: | |
16 | · ${h.branding(c.rhodecode_name)} |
|
16 | · ${h.branding(c.rhodecode_name)} | |
17 | %endif |
|
17 | %endif | |
18 | </%def> |
|
18 | </%def> | |
19 |
|
19 | |||
20 | <%def name="breadcrumbs_links()"> |
|
20 | <%def name="breadcrumbs_links()"> | |
21 | ${h.link_to(_('Admin'),h.route_path('admin_home'))} |
|
21 | ${h.link_to(_('Admin'),h.route_path('admin_home'))} | |
22 | » |
|
22 | » | |
23 | ${_('Integrations')} |
|
23 | ${_('Integrations')} | |
24 | </%def> |
|
24 | </%def> | |
25 |
|
25 | |||
26 | <%def name="menu_bar_nav()"> |
|
26 | <%def name="menu_bar_nav()"> | |
27 | %if c.repo: |
|
27 | %if c.repo: | |
28 | ${self.menu_items(active='repositories')} |
|
28 | ${self.menu_items(active='repositories')} | |
29 | %else: |
|
29 | %else: | |
30 | ${self.menu_items(active='admin')} |
|
30 | ${self.menu_items(active='admin')} | |
31 | %endif |
|
31 | %endif | |
32 | </%def> |
|
32 | </%def> | |
33 |
|
33 | |||
34 | <%def name="menu_bar_subnav()"> |
|
34 | <%def name="menu_bar_subnav()"> | |
35 | %if c.repo: |
|
35 | %if c.repo: | |
36 | ${self.repo_menu(active='options')} |
|
36 | ${self.repo_menu(active='options')} | |
37 | %endif |
|
37 | %endif | |
38 | </%def> |
|
38 | </%def> | |
39 |
|
39 | |||
40 | <%def name="main_content()"> |
|
40 | <%def name="main_content()"> | |
41 | ${next.body()} |
|
41 | ${next.body()} | |
42 | </%def> |
|
42 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now