Skip to content

Commit

Permalink
feat(SiteDomains): show certbot error in a banner (#1920)
Browse files Browse the repository at this point in the history
  • Loading branch information
BreadGenie authored Jul 4, 2024
1 parent 2ae1696 commit d221892
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
9 changes: 3 additions & 6 deletions dashboard/src2/components/ObjectList.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<template>
<div>
<AlertBanner
v-if="banner"
:title="banner.title"
:type="banner.type"
class="mb-4"
/>
<AlertBanner v-if="banner" v-bind="banner" class="mb-4">
<Button v-if="banner.button" v-bind="banner.button" class="ml-auto" />
</AlertBanner>
<div class="flex items-center justify-between">
<slot name="header-left" v-bind="context">
<div v-if="showControls" class="flex items-center space-x-2">
Expand Down
37 changes: 37 additions & 0 deletions dashboard/src2/objects/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,43 @@ export default {
type: 'Badge'
}
],
banner({ documentResource: site }) {
if (site.doc.broken_domain_error) {
return {
title:
'There was an error fetching an https certificate for your domain.',
type: 'error',
button: {
label: 'View Error',
variant: 'outline',
onClick() {
renderDialog(
h(
GenericDialog,
{
options: {
title: 'Error fetching certificate',
size: 'xl'
}
},
{
default: () => {
return h('pre', {
class:
'whitespace-pre-wrap text-sm rounded border-2 p-3 border-gray-200 bg-gray-100',
innerHTML: site.doc.broken_domain_error
});
}
}
)
);
}
}
};
} else {
return null;
}
},
primaryAction({ listResource: domains, documentResource: site }) {
return {
label: 'Add Domain',
Expand Down
8 changes: 8 additions & 0 deletions press/press/doctype/site/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ def get_doc(self, doc):
doc.server_title = server.title
doc.inbound_ip = self.inbound_ip
doc.is_dedicated_server = is_dedicated_server(self.server)

if broken_domain_tls_certificate := frappe.db.get_value(
"Site Domain", {"site": self.name, "status": "Broken"}, "tls_certificate"
):
doc.broken_domain_error = frappe.db.get_value(
"TLS Certificate", broken_domain_tls_certificate, "error"
)

return doc

def site_action(allowed_status: List[str]):
Expand Down

0 comments on commit d221892

Please sign in to comment.