Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SiteDomains): show certbot error in a banner #1920

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading