From 544ce6b52418c5316f08e9ada267354c753e5bb4 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Tue, 16 Jul 2024 20:10:07 +0530 Subject: [PATCH 01/11] feat: provision to populate logos from website settings --- dashboard/src/views/partials/LoginBox.vue | 37 +++++++++++++++++++++-- press/api/utils.py | 10 ++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 press/api/utils.py diff --git a/dashboard/src/views/partials/LoginBox.vue b/dashboard/src/views/partials/LoginBox.vue index 364ca87697..13d6b32ed7 100644 --- a/dashboard/src/views/partials/LoginBox.vue +++ b/dashboard/src/views/partials/LoginBox.vue @@ -4,11 +4,15 @@
- + + - Frappe Cloud + {{ appName }}
@@ -27,7 +31,11 @@
- + +
@@ -44,6 +52,13 @@ export default { FCLogo, FrappeLogo }, + data() { + return { + appLogo: '', + appName: 'Frappe Cloud', + appFooterLogo: '' + }; + }, mounted() { const params = new URLSearchParams(window.location.search); @@ -59,6 +74,22 @@ export default { redirectForFrappeioAuth() { window.location = '/f-login'; } + }, + resources: { + brandDetails() { + return { + url: 'press.api.utils.get_app_details', + auto: true, + onSuccess(data) { + console.log(data); + } + }; + } + }, + computed: { + brandDetails() { + return this.$resources.brandDetails.data || ''; + } } }; diff --git a/press/api/utils.py b/press/api/utils.py new file mode 100644 index 0000000000..75d2ef8fd2 --- /dev/null +++ b/press/api/utils.py @@ -0,0 +1,10 @@ +import frappe + + +@frappe.whitelist(allow_guest=True) +def get_app_details(): + return { + "app_logo": frappe.get_website_settings("app_logo") or "default", + "app_name": frappe.get_website_settings("app_logo") or "default", + "app_footer_logo": frappe.get_website_settings("app_logo") or "default", + } From 6c82323434a3f896b776cd66941c35e0e22480dd Mon Sep 17 00:00:00 2001 From: Saurabh Date: Wed, 17 Jul 2024 19:55:14 +0530 Subject: [PATCH 02/11] feat: separate component to set branding info --- dashboard/src/views/general/BrandLogo.vue | 46 +++++++++++++++++++++++ dashboard/src/views/partials/LoginBox.vue | 38 +++++-------------- dashboard/src2/data/branding.js | 15 ++++++++ press/api/utils.py | 13 +++++-- 4 files changed, 79 insertions(+), 33 deletions(-) create mode 100644 dashboard/src/views/general/BrandLogo.vue create mode 100644 dashboard/src2/data/branding.js diff --git a/dashboard/src/views/general/BrandLogo.vue b/dashboard/src/views/general/BrandLogo.vue new file mode 100644 index 0000000000..5948eba785 --- /dev/null +++ b/dashboard/src/views/general/BrandLogo.vue @@ -0,0 +1,46 @@ + + diff --git a/dashboard/src/views/partials/LoginBox.vue b/dashboard/src/views/partials/LoginBox.vue index 13d6b32ed7..34f987a5b4 100644 --- a/dashboard/src/views/partials/LoginBox.vue +++ b/dashboard/src/views/partials/LoginBox.vue @@ -4,11 +4,7 @@
- - + @@ -31,33 +27,20 @@
- - +
diff --git a/dashboard/src2/components/AppSidebar.vue b/dashboard/src2/components/AppSidebar.vue index d40ac073e6..d993816c7b 100644 --- a/dashboard/src2/components/AppSidebar.vue +++ b/dashboard/src2/components/AppSidebar.vue @@ -32,10 +32,10 @@ class="flex w-[204px] items-center rounded-md px-2 py-2 text-left" :class="open ? 'bg-white shadow-sm' : 'hover:bg-gray-200'" > - +
- Frappe Cloud + {{ appName }}
diff --git a/dashboard/src/views/general/BrandLogo.vue b/dashboard/src2/components/BrandLogo.vue similarity index 81% rename from dashboard/src/views/general/BrandLogo.vue rename to dashboard/src2/components/BrandLogo.vue index 5948eba785..bae3194f39 100644 --- a/dashboard/src/views/general/BrandLogo.vue +++ b/dashboard/src2/components/BrandLogo.vue @@ -21,6 +21,7 @@ diff --git a/dashboard/src2/data/branding.js b/dashboard/src2/data/branding.js index 278ed6c22d..4935908d7b 100644 --- a/dashboard/src2/data/branding.js +++ b/dashboard/src2/data/branding.js @@ -11,5 +11,5 @@ export function fetchBrandInfo() { } export function getBrandInfo() { - return brand.data || []; + return BrandInfo.data || []; } diff --git a/dashboard/src2/main.js b/dashboard/src2/main.js index 405e798bda..397287e313 100644 --- a/dashboard/src2/main.js +++ b/dashboard/src2/main.js @@ -14,6 +14,7 @@ import * as Sentry from '@sentry/vue'; import { session } from './data/session.js'; import posthog from 'posthog-js'; import { toast } from 'vue-sonner'; +import { fetchBrandInfo } from './data/branding.js'; let request = options => { let _options = options || {}; @@ -50,6 +51,8 @@ getInitialData().then(() => { app.config.globalProperties.$socket = socket; window.$socket = socket; subscribeToJobUpdates(socket); + fetchBrandInfo(); + if (session.isLoggedIn) { fetchPlans(); session.roles.fetch(); From a1fefc12ef02a2faa8d450e201570ff362d76a7b Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 19 Jul 2024 17:28:39 +0530 Subject: [PATCH 04/11] feat: use typed props --- dashboard/src2/components/AppSidebar.vue | 4 ++-- dashboard/src2/components/BrandLogo.vue | 10 +++++++--- dashboard/src2/components/auth/LoginBox.vue | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dashboard/src2/components/AppSidebar.vue b/dashboard/src2/components/AppSidebar.vue index d993816c7b..49683d60fc 100644 --- a/dashboard/src2/components/AppSidebar.vue +++ b/dashboard/src2/components/AppSidebar.vue @@ -32,7 +32,7 @@ class="flex w-[204px] items-center rounded-md px-2 py-2 text-left" :class="open ? 'bg-white shadow-sm' : 'hover:bg-gray-200'" > - +
{{ appName }} @@ -122,7 +122,7 @@ export default { ); } }, - compute: { + computed: { appName() { let brandInfo = getBrandInfo(); return brandInfo.app_name; diff --git a/dashboard/src2/components/BrandLogo.vue b/dashboard/src2/components/BrandLogo.vue index bae3194f39..a52eb961a1 100644 --- a/dashboard/src2/components/BrandLogo.vue +++ b/dashboard/src2/components/BrandLogo.vue @@ -1,5 +1,5 @@ From 4c9d9784fedbd900a188d888ca71e1601d6e9989 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 22 Jul 2024 15:00:24 +0530 Subject: [PATCH 05/11] feat: provision to setup branding info --- .../press/doctype/brand_settings/__init__.py | 0 .../doctype/brand_settings/brand_settings.js | 8 ++ .../brand_settings/brand_settings.json | 92 +++++++++++++++++++ .../doctype/brand_settings/brand_settings.py | 41 +++++++++ .../brand_settings/test_brand_settings.py | 9 ++ 5 files changed, 150 insertions(+) create mode 100644 press/press/doctype/brand_settings/__init__.py create mode 100644 press/press/doctype/brand_settings/brand_settings.js create mode 100644 press/press/doctype/brand_settings/brand_settings.json create mode 100644 press/press/doctype/brand_settings/brand_settings.py create mode 100644 press/press/doctype/brand_settings/test_brand_settings.py diff --git a/press/press/doctype/brand_settings/__init__.py b/press/press/doctype/brand_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/press/press/doctype/brand_settings/brand_settings.js b/press/press/doctype/brand_settings/brand_settings.js new file mode 100644 index 0000000000..05f6f89a76 --- /dev/null +++ b/press/press/doctype/brand_settings/brand_settings.js @@ -0,0 +1,8 @@ +// Copyright (c) 2024, Frappe and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("Brand Settings", { +// refresh(frm) { + +// }, +// }); diff --git a/press/press/doctype/brand_settings/brand_settings.json b/press/press/doctype/brand_settings/brand_settings.json new file mode 100644 index 0000000000..366c0079db --- /dev/null +++ b/press/press/doctype/brand_settings/brand_settings.json @@ -0,0 +1,92 @@ +{ + "actions": [], + "allow_rename": 1, + "creation": "2024-07-22 14:06:23.709878", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "brand_section", + "brand_logo", + "footer_logo", + "column_break_oezy", + "brand_name", + "terms_section", + "terms_of_service", + "cookie_policy", + "column_break_gcuq", + "privacy_policy" + ], + "fields": [ + { + "fieldname": "brand_section", + "fieldtype": "Section Break", + "label": "Brand" + }, + { + "fieldname": "column_break_oezy", + "fieldtype": "Column Break" + }, + { + "fieldname": "brand_name", + "fieldtype": "Data", + "label": "Brand Name" + }, + { + "fieldname": "terms_section", + "fieldtype": "Section Break", + "label": "Terms" + }, + { + "fieldname": "terms_of_service", + "fieldtype": "Data", + "label": "Terms of Service" + }, + { + "fieldname": "cookie_policy", + "fieldtype": "Data", + "label": "Cookie Policy" + }, + { + "fieldname": "column_break_gcuq", + "fieldtype": "Column Break" + }, + { + "fieldname": "privacy_policy", + "fieldtype": "Data", + "label": "Privacy Policy" + }, + { + "fieldname": "brand_logo", + "fieldtype": "Attach Image", + "label": "Brand Logo" + }, + { + "fieldname": "footer_logo", + "fieldtype": "Attach Image", + "label": "Footer Logo" + } + ], + "index_web_pages_for_search": 1, + "issingle": 1, + "links": [], + "modified": "2024-07-22 14:31:18.289758", + "modified_by": "Administrator", + "module": "Press", + "name": "Brand Settings", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "print": 1, + "read": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "creation", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/press/press/doctype/brand_settings/brand_settings.py b/press/press/doctype/brand_settings/brand_settings.py new file mode 100644 index 0000000000..38aadd5c1e --- /dev/null +++ b/press/press/doctype/brand_settings/brand_settings.py @@ -0,0 +1,41 @@ +# Copyright (c) 2024, Frappe and contributors +# For license information, please see license.txt + +import frappe +from frappe.model.document import Document + + +class BrandSettings(Document): + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + brand_logo: DF.AttachImage | None + brand_name: DF.Data | None + cookie_policy: DF.Data | None + footer_logo: DF.AttachImage | None + privacy_policy: DF.Data | None + terms_of_service: DF.Data | None + # end: auto-generated types + + pass + + +def get_brand_details(): + brand_details = frappe.get_cached_doc("Brand Settings") + + return { + "brand_logo": brand_details.get("brand_logo"), + "brand_name": brand_details.get("brand_name") or "Frappe Cloud", + "footer_logo": brand_details.get("footer_logo"), + } + + +def get_brand_name(): + brand_details = frappe.get_cached_doc("Brand Settings") + print(brand_details.as_dict()) + return brand_details.get("brand_name") or "Frappe Cloud" diff --git a/press/press/doctype/brand_settings/test_brand_settings.py b/press/press/doctype/brand_settings/test_brand_settings.py new file mode 100644 index 0000000000..4715cf3e93 --- /dev/null +++ b/press/press/doctype/brand_settings/test_brand_settings.py @@ -0,0 +1,9 @@ +# Copyright (c) 2024, Frappe and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestBrandSettings(FrappeTestCase): + pass From 91ece140391058c6af8d9fad0f44d77661910a15 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 22 Jul 2024 15:01:18 +0530 Subject: [PATCH 06/11] fix: naming and api's --- dashboard/src2/components/AppSidebar.vue | 6 +++--- dashboard/src2/components/BrandLogo.vue | 9 +++++---- dashboard/src2/components/auth/LoginBox.vue | 6 +++--- press/api/utils.py | 17 ++++++++++------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/dashboard/src2/components/AppSidebar.vue b/dashboard/src2/components/AppSidebar.vue index 49683d60fc..f6e819dc05 100644 --- a/dashboard/src2/components/AppSidebar.vue +++ b/dashboard/src2/components/AppSidebar.vue @@ -35,7 +35,7 @@
- {{ appName }} + {{ brandName }}
@@ -10,8 +10,9 @@ diff --git a/dashboard/src2/components/auth/LoginBox.vue b/dashboard/src2/components/auth/LoginBox.vue index 3eaab40f84..75c4b1a612 100644 --- a/dashboard/src2/components/auth/LoginBox.vue +++ b/dashboard/src2/components/auth/LoginBox.vue @@ -8,7 +8,7 @@ - {{ appName }} + {{ brandName }}
@@ -60,9 +60,9 @@ export default { } }, computed: { - appName() { + brandName() { let brandDetails = getBrandInfo(); - return brandDetails.app_name; + return brandDetails.brand_name; } } }; diff --git a/press/api/utils.py b/press/api/utils.py index 18fde2744d..ee58017922 100644 --- a/press/api/utils.py +++ b/press/api/utils.py @@ -1,15 +1,18 @@ import frappe +from press.press.doctype.brand_settings.brand_settings import ( + get_brand_details as _get_brand_details, + get_brand_name as _get_brand_name, +) @frappe.whitelist(allow_guest=True) def get_brand_details(): - return { - "app_logo": frappe.get_website_settings("app_logo"), - "app_name": frappe.get_website_settings("app_name"), - "app_footer_logo": frappe.get_website_settings("footer_logo"), - } + data = _get_brand_details() + + print(data) + return _get_brand_details() @frappe.whitelist(allow_guest=True) -def get_app_name(): - return frappe.get_website_settings("app_name") or "Frappe Cloud" +def get_brand_name(): + return _get_brand_name() or "Frappe Cloud" From 23fd8efb06b062c2ba6b353fe448576a32f488bf Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 22 Jul 2024 15:29:53 +0530 Subject: [PATCH 07/11] feat: provision to setup terms and policies --- dashboard/src2/pages/SetupAccount.vue | 13 +++++++------ press/api/utils.py | 3 --- .../doctype/brand_settings/brand_settings.json | 5 ++++- .../press/doctype/brand_settings/brand_settings.py | 7 ++++++- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/dashboard/src2/pages/SetupAccount.vue b/dashboard/src2/pages/SetupAccount.vue index 8f6e50df40..da13c756d2 100644 --- a/dashboard/src2/pages/SetupAccount.vue +++ b/dashboard/src2/pages/SetupAccount.vue @@ -76,17 +76,14 @@ By clicking on {{ isInvitation ? 'Accept' : 'Create account' }}, you accept our - Terms of Service , - + Privacy Policy & - + Cookie Policy @@ -120,6 +117,7 @@ import LoginBox from '../components/auth/LoginBox.vue'; import Link from '@/components/Link.vue'; import Form from '@/components/Form.vue'; import ProductSignupPitch from '../components/ProductSignupPitch.vue'; +import { getBrandInfo } from '../data/branding'; export default { name: 'SetupAccount', @@ -221,6 +219,9 @@ export default { df.required = true; return df; }); + }, + policies() { + return getBrandInfo(); } } }; diff --git a/press/api/utils.py b/press/api/utils.py index ee58017922..1e0f3c8d68 100644 --- a/press/api/utils.py +++ b/press/api/utils.py @@ -7,9 +7,6 @@ @frappe.whitelist(allow_guest=True) def get_brand_details(): - data = _get_brand_details() - - print(data) return _get_brand_details() diff --git a/press/press/doctype/brand_settings/brand_settings.json b/press/press/doctype/brand_settings/brand_settings.json index 366c0079db..0d64761874 100644 --- a/press/press/doctype/brand_settings/brand_settings.json +++ b/press/press/doctype/brand_settings/brand_settings.json @@ -37,11 +37,13 @@ "label": "Terms" }, { + "description": "Define full URL like https://frappecloud.com/terms", "fieldname": "terms_of_service", "fieldtype": "Data", "label": "Terms of Service" }, { + "description": "Define full URL like https://frappecloud.com/cookie-policy", "fieldname": "cookie_policy", "fieldtype": "Data", "label": "Cookie Policy" @@ -51,6 +53,7 @@ "fieldtype": "Column Break" }, { + "description": "Define full URL like https://frappecloud.com/privacy", "fieldname": "privacy_policy", "fieldtype": "Data", "label": "Privacy Policy" @@ -69,7 +72,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2024-07-22 14:31:18.289758", + "modified": "2024-07-22 15:27:04.394302", "modified_by": "Administrator", "module": "Press", "name": "Brand Settings", diff --git a/press/press/doctype/brand_settings/brand_settings.py b/press/press/doctype/brand_settings/brand_settings.py index 38aadd5c1e..0f6399f695 100644 --- a/press/press/doctype/brand_settings/brand_settings.py +++ b/press/press/doctype/brand_settings/brand_settings.py @@ -32,10 +32,15 @@ def get_brand_details(): "brand_logo": brand_details.get("brand_logo"), "brand_name": brand_details.get("brand_name") or "Frappe Cloud", "footer_logo": brand_details.get("footer_logo"), + "terms_of_service": brand_details.get("terms_of_service") + or "https://frappecloud.com/terms", + "cookie_policy": brand_details.get("cookie_policy") + or "https://frappecloud.com/cookie-policy", + "privacy_policy": brand_details.get("privacy_policy") + or "https://frappecloud.com/privacy", } def get_brand_name(): brand_details = frappe.get_cached_doc("Brand Settings") - print(brand_details.as_dict()) return brand_details.get("brand_name") or "Frappe Cloud" From aa34fef6dd328ff7b74ca07ae46c94d8539fe536 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 22 Jul 2024 18:36:12 +0530 Subject: [PATCH 08/11] feat: provision to setup custom welcome message while onboarding customer --- dashboard/src2/components/Onboarding.vue | 26 +++++++++++++++++-- press/api/utils.py | 6 +++++ .../brand_settings/brand_settings.json | 16 ++++++++++-- .../doctype/brand_settings/brand_settings.py | 5 ++++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/dashboard/src2/components/Onboarding.vue b/dashboard/src2/components/Onboarding.vue index 8f1cbe5351..3f402f448c 100644 --- a/dashboard/src2/components/Onboarding.vue +++ b/dashboard/src2/components/Onboarding.vue @@ -1,8 +1,11 @@