Skip to content

Commit e6f61e2

Browse files
committed
Add button to add custom certificate in certificate list
1 parent 9687e9e commit e6f61e2

File tree

9 files changed

+58
-35
lines changed

9 files changed

+58
-35
lines changed

frontend/js/app/empty/main.ejs

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ if (subtitle) { %>
66
<p class="h4 text-muted font-weight-normal mb-7"><%- subtitle %></p>
77
<% }
88
9-
if (link) { %>
10-
<a class="btn btn-<%- btn_color %>" href="#"><%- link %></a>
9+
if (links && links.length) { %>
10+
<% links.forEach(function(link, index) { %>
11+
<div style="margin-bottom: 10px;">
12+
<a class="btn btn-<%- btn_color %>" href="#" data-index="<%- index %>"><%- link %></a>
13+
</div>
14+
<% }); %>
1115
<% } %>

frontend/js/app/empty/main.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ module.exports = Mn.View.extend({
66
template: template,
77

88
options: {
9-
btn_color: 'teal'
9+
btn_color: 'teal',
10+
links: [], // Added to accept multiple links
11+
actions: [] // Added to accept multiple actions
1012
},
1113

1214
ui: {
@@ -16,17 +18,19 @@ module.exports = Mn.View.extend({
1618
events: {
1719
'click @ui.action': function (e) {
1820
e.preventDefault();
19-
this.getOption('action')();
21+
const index = $(e.currentTarget).data('index');
22+
this.getOption('actions')[index]();
2023
}
2124
},
2225

2326
templateContext: function () {
2427
return {
25-
title: this.getOption('title'),
26-
subtitle: this.getOption('subtitle'),
27-
link: this.getOption('link'),
28-
action: typeof this.getOption('action') === 'function',
29-
btn_color: this.getOption('btn_color')
28+
title: this.getOption('title'),
29+
subtitle: this.getOption('subtitle'),
30+
links: this.getOption('links'), // Changed to array
31+
actions: this.getOption('actions'), // Changed to array
32+
hasActions: this.getOption('actions').length > 0,
33+
btn_color: this.getOption('btn_color')
3034
};
3135
}
3236

frontend/js/app/nginx/access/main.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ module.exports = Mn.View.extend({
4545
this.showChildView('list_region', new EmptyView({
4646
title: App.i18n('access-lists', 'empty'),
4747
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
48-
link: manage ? App.i18n('access-lists', 'add') : null,
48+
links: manage ? [App.i18n('access-lists', 'add')] : [],
4949
btn_color: 'teal',
5050
permission: 'access_lists',
51-
action: function () {
52-
App.Controller.showNginxAccessListForm();
53-
}
51+
actions: [
52+
function () {
53+
App.Controller.showNginxAccessListForm();
54+
}
55+
]
5456
}));
5557
},
5658

frontend/js/app/nginx/certificates/main.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ module.exports = Mn.View.extend({
4545
this.showChildView('list_region', new EmptyView({
4646
title: App.i18n('certificates', 'empty'),
4747
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
48-
link: manage ? App.i18n('certificates', 'add') : null,
48+
links: manage ? [App.i18n('certificates', 'add-letsencrypt'), App.i18n('certificates', 'add-custom')] : [],
49+
actions: [
50+
function () {
51+
App.Controller.showNginxCertificateForm();
52+
},
53+
function () {
54+
App.Controller.showNginxCertificateForm(new CertificateModel.Model({provider: 'custom'}));
55+
}],
4956
btn_color: 'pink',
50-
permission: 'certificates',
51-
action: function () {
52-
App.Controller.showNginxCertificateForm();
53-
}
57+
permission: 'certificates'
5458
}));
5559
},
5660

frontend/js/app/nginx/dead/main.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ module.exports = Mn.View.extend({
4545
this.showChildView('list_region', new EmptyView({
4646
title: App.i18n('dead-hosts', 'empty'),
4747
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
48-
link: manage ? App.i18n('dead-hosts', 'add') : null,
48+
links: manage ? [App.i18n('dead-hosts', 'add')] : [],
4949
btn_color: 'danger',
5050
permission: 'dead_hosts',
51-
action: function () {
52-
App.Controller.showNginxDeadForm();
53-
}
51+
actions: [
52+
function () {
53+
App.Controller.showNginxDeadForm();
54+
}
55+
]
5456
}));
5557
},
5658

frontend/js/app/nginx/proxy/main.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,17 @@ module.exports = Mn.View.extend({
4141

4242
showEmpty: function() {
4343
let manage = App.Cache.User.canManage('proxy_hosts');
44-
4544
this.showChildView('list_region', new EmptyView({
4645
title: App.i18n('proxy-hosts', 'empty'),
4746
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
48-
link: manage ? App.i18n('proxy-hosts', 'add') : null,
47+
links: manage ? [App.i18n('proxy-hosts', 'add')] : [],
48+
actions: [
49+
function () {
50+
App.Controller.showNginxProxyForm();
51+
}
52+
],
4953
btn_color: 'success',
5054
permission: 'proxy_hosts',
51-
action: function () {
52-
App.Controller.showNginxProxyForm();
53-
}
5455
}));
5556
},
5657

frontend/js/app/nginx/redirection/main.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ module.exports = Mn.View.extend({
4444
this.showChildView('list_region', new EmptyView({
4545
title: App.i18n('redirection-hosts', 'empty'),
4646
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
47-
link: manage ? App.i18n('redirection-hosts', 'add') : null,
47+
links: manage ? [App.i18n('redirection-hosts', 'add')] : [],
4848
btn_color: 'yellow',
4949
permission: 'redirection_hosts',
50-
action: function () {
51-
App.Controller.showNginxRedirectionForm();
52-
}
50+
actions: [
51+
function () {
52+
App.Controller.showNginxRedirectionForm();
53+
}
54+
]
5355
}));
5456
},
5557

frontend/js/app/nginx/stream/main.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ module.exports = Mn.View.extend({
4545
this.showChildView('list_region', new EmptyView({
4646
title: App.i18n('streams', 'empty'),
4747
subtitle: App.i18n('all-hosts', 'empty-subtitle', {manage: manage}),
48-
link: manage ? App.i18n('streams', 'add') : null,
48+
links: manage ? [App.i18n('streams', 'add')] : [],
4949
btn_color: 'blue',
5050
permission: 'streams',
51-
action: function () {
52-
App.Controller.showNginxStreamForm();
53-
}
51+
actions: [
52+
function () {
53+
App.Controller.showNginxStreamForm();
54+
}
55+
]
5456
}));
5557
},
5658

frontend/js/i18n/messages.json

+2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@
185185
"title": "SSL Certificates",
186186
"empty": "There are no SSL Certificates",
187187
"add": "Add SSL Certificate",
188+
"add-letsencrypt": "Add SSL Certificate with Let's Encrypt",
189+
"add-custom": "Add Custom SSL Certificate",
188190
"form-title": "Add {provider, select, letsencrypt{Let's Encrypt} other{Custom}} Certificate",
189191
"delete": "Delete SSL Certificate",
190192
"delete-confirm": "Are you sure you want to delete this SSL Certificate? Any hosts using it will need to be updated later.",

0 commit comments

Comments
 (0)