feat(UX): Disable write actions in read-only Desk

I won't be covering each and every aspect of desk that shouldn't work in
read only mode. This just handles major interactions and assumes that
user will get a hint about why other things aren't working.

Changes:
- Add read only badge on navbar.
- Disable forms
- Disable new doc creation
This commit is contained in:
Ankush Menat 2022-09-07 23:25:11 +05:30
parent e1253e8299
commit 1ec03dacff
4 changed files with 11 additions and 1 deletions

View file

@ -450,6 +450,10 @@ frappe.ui.form.Form = class FrappeForm {
.toggleClass("cancelled-form", this.doc.docstatus === 2);
this.show_conflict_message();
if (frappe.boot.read_only) {
this.disable_form();
}
}
}

View file

@ -215,7 +215,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
}
set_primary_action() {
if (this.can_create) {
if (this.can_create && !frappe.boot.read_only) {
const doctype_name = __(frappe.router.doctype_layout) || __(this.doctype);
// Better style would be __("Add {0}", [doctype_name], "Primary action in list view")

View file

@ -6,6 +6,11 @@
<ul class="nav navbar-nav d-none d-sm-flex" id="navbar-breadcrumbs"></ul>
<div class="collapse navbar-collapse justify-content-end">
<form class="form-inline fill-width justify-content-end" role="search" onsubmit="return false;">
{% if (frappe.boot.read_only) { %}
<span class="indicator-pill yellow" title="{%= __("Your site is getting upgraded.") %}">
{%= __("Read Only Mode") %}
</span>
{% } %}
<div class="input-group search-bar text-muted hidden">
<input
id="navbar-search"

View file

@ -179,6 +179,7 @@ def get():
bootinfo.notes = get_unseen_notes()
bootinfo.assets_json = get_assets_json()
bootinfo.read_only = bool(frappe.flags.read_only)
for hook in frappe.get_hooks("extend_bootinfo"):
frappe.get_attr(hook)(bootinfo=bootinfo)