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

fix: provision to disable frappe.io auth dependency #1750

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
15 changes: 12 additions & 3 deletions dashboard/src2/components/AppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
>
<FCLogo class="mb-1 h-8 w-8 shrink-0 rounded" />
<BrandLogo type="header" />
<div class="ml-2 flex flex-1 flex-col overflow-hidden">
<div class="text-base font-medium leading-none text-gray-900">
Frappe Cloud
{{ brandName }}
</div>
<Tooltip :text="$team?.doc?.user || null">
<div
Expand Down Expand Up @@ -92,6 +92,8 @@ import { defineAsyncComponent } from 'vue';
import AppSidebarItem from './AppSidebarItem.vue';
import { Tooltip } from 'frappe-ui';
import NavigationItems from './NavigationItems.vue';
import { getBrandInfo } from '../data/branding';
import BrandLogo from './BrandLogo.vue';

export default {
name: 'AppSidebar',
Expand All @@ -101,7 +103,8 @@ export default {
import('./SwitchTeamDialog.vue')
),
Tooltip,
NavigationItems
NavigationItems,
BrandLogo
},
data() {
return {
Expand All @@ -118,6 +121,12 @@ export default {
'_blank'
);
}
},
computed: {
brandName() {
let brandInfo = getBrandInfo();
return brandInfo.brand_name;
}
}
};
</script>
44 changes: 44 additions & 0 deletions dashboard/src2/components/BrandLogo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<span v-if="type == 'header'">
<img
v-if="brandDetails && brandDetails.brand_logo"
:src="brandDetails.brand_logo"
class="inline-block h-7 w-7"
/>
<FCLogo class="inline-block h-7 w-7" v-else />
</span>

<span v-else-if="type == 'footer'">
<img
v-if="brandDetails && brandDetails.footer_logo"
:src="brandDetails.footer_logo"
class="h-4"
/>
<FrappeLogo class="h-4" v-else />
</span>

<span v-else> </span>
</template>
<script>
import FCLogo from '@/components/icons/FCLogo.vue';
import FrappeLogo from '@/components/icons/FrappeLogo.vue';
import { getBrandInfo } from '../data/branding';

export default {
name: 'BrandLogo',
components: {
FCLogo,
FrappeLogo
},
props: {
type: {
type: String
}
},
computed: {
brandDetails() {
return getBrandInfo();
}
}
};
</script>
26 changes: 24 additions & 2 deletions dashboard/src2/components/Onboarding.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<template>
<div class="mx-auto max-w-2xl rounded-lg border-0 px-2 sm:border sm:p-8">
<div class="prose prose-sm max-w-none">
<h1 class="text-2xl font-semibold">Welcome to Frappe Cloud</h1>
<p>
<h1 class="text-2xl font-semibold">Welcome to {{ brandName }}</h1>
<p v-if="onboarding">
{{ onboarding.message }}
</p>
<p v-else>
Frappe Cloud makes it easy to manage sites and apps like ERPNext in an
easy to use dashboard with powerful features like automatic backups,
custom domains, SSL certificates, custom apps, automatic updates and
Expand Down Expand Up @@ -266,6 +269,7 @@
<script>
import { defineAsyncComponent } from 'vue';
import TextInsideCircle from './TextInsideCircle.vue';
// import { fetchOnboardingDetails } from '../data/branding';

export default {
name: 'Onboarding',
Expand Down Expand Up @@ -340,6 +344,12 @@ export default {
},
trialSite() {
return this.$team.doc.trial_sites?.[0];
},
onboarding() {
return this.$resources.onboardingDetails.data;
},
brandName() {
return this.$resources.brandName.data;
}
},
resources: {
Expand All @@ -348,6 +358,18 @@ export default {
url: 'press.api.marketplace.get_marketplace_apps_for_onboarding',
auto: true
};
},
onboardingDetails() {
return {
url: 'press.api.utils.get_onboarding_details',
auto: true
};
},
brandName() {
return {
url: 'press.api.utils.get_brand_name',
auto: true
};
}
}
};
Expand Down
19 changes: 12 additions & 7 deletions dashboard/src2/components/auth/LoginBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<div class="flex" @dblclick="redirectForFrappeioAuth">
<slot name="logo">
<div class="mx-auto flex items-center space-x-2">
<FCLogo class="inline-block h-7 w-7" />
<BrandLogo type="header" />
<span
class="select-none text-xl font-semibold tracking-tight text-gray-900"
>
Frappe Cloud
{{ brandName }}
</span>
</div>
</slot>
Expand All @@ -27,22 +27,21 @@
</div>
</div>
<div class="absolute bottom-4 z-[1] flex w-full justify-center">
<FrappeLogo class="h-4" />
<BrandLogo type="footer" />
</div>
</div>
</template>

<script>
import FCLogo from '@/components/icons/FCLogo.vue';
import FrappeLogo from '@/components/icons/FrappeLogo.vue';
import BrandLogo from '../BrandLogo.vue';
import { notify } from '@/utils/toast';
import { getBrandInfo } from '../../data/branding';

export default {
name: 'LoginBox',
props: ['title', 'logo'],
components: {
FCLogo,
FrappeLogo
BrandLogo
},
mounted() {
const params = new URLSearchParams(window.location.search);
Expand All @@ -59,6 +58,12 @@ export default {
redirectForFrappeioAuth() {
window.location = '/f-login';
}
},
computed: {
brandName() {
let brandDetails = getBrandInfo();
return brandDetails.brand_name;
}
}
};
</script>
15 changes: 15 additions & 0 deletions dashboard/src2/data/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { createResource } from 'frappe-ui';

export let BrandInfo = createResource({
url: 'press.api.utils.get_brand_details',
cache: 'site.brand',
initialData: []
});

export function fetchBrandInfo() {
BrandInfo.fetch();
}

export function getBrandInfo() {
return BrandInfo.data || [];
}
3 changes: 3 additions & 0 deletions dashboard/src2/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};
Expand Down Expand Up @@ -50,6 +51,8 @@ getInitialData().then(() => {
app.config.globalProperties.$socket = socket;
window.$socket = socket;
subscribeToJobUpdates(socket);
fetchBrandInfo();

if (session.isLoggedIn) {
fetchPlans();
session.roles.fetch();
Expand Down
13 changes: 7 additions & 6 deletions dashboard/src2/pages/SetupAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,14 @@
By clicking on
<span>{{ isInvitation ? 'Accept' : 'Create account' }}</span
>, you accept our
<Link href="https://frappecloud.com/terms" target="_blank"
<Link :href="policies.terms_of_service" target="_blank"
>Terms of Service </Link
>,
<Link href="https://frappecloud.com/privacy" target="_blank">
<Link :href="policies.privacy_policy" target="_blank">
Privacy Policy
</Link>
&#38;
<Link
href="https://frappecloud.com/cookie-policy"
target="_blank"
>
<Link :href="policies.cookie_policy" target="_blank">
Cookie Policy
</Link>
</label>
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -221,6 +219,9 @@ export default {
df.required = true;
return df;
});
},
policies() {
return getBrandInfo();
}
}
};
Expand Down
5 changes: 4 additions & 1 deletion press/api/marketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
get_plans_for_app,
)
from press.utils import get_app_tag, get_current_team, get_last_doc, unique
from press.utils.billing import get_frappe_io_connection
from press.utils.billing import get_frappe_io_connection, disabled_frappeio_auth


@frappe.whitelist()
Expand Down Expand Up @@ -996,6 +996,9 @@ def get_discount_percent(plan, discount=0.0):
"Bronze": 30.0,
}

if disabled_frappeio_auth():
return discount

if team.erpnext_partner and frappe.get_value(
"Marketplace App Plan", plan, "partner_discount"
):
Expand Down
15 changes: 14 additions & 1 deletion press/api/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,20 @@ def update_partnership_date(team, partnership_date):

@frappe.whitelist()
def get_partner_details(partner_email):
from press.utils.billing import get_frappe_io_connection
from press.utils.billing import get_frappe_io_connection, disabled_frappeio_auth

if disabled_frappeio_auth():
return frappe._dict(
{
"email": "",
"partner_type": "",
"company_name": "",
"custom_ongoing_period_fc_invoice_contribution": "",
"custom_ongoing_period_enterprise_invoice_contribution": "",
"partner_name": "",
"custom_number_of_certified_members": "",
}
)

client = get_frappe_io_connection()
data = client.get_doc(
Expand Down
21 changes: 21 additions & 0 deletions press/api/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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,
get_onboarding_message,
)


@frappe.whitelist(allow_guest=True)
def get_brand_details():
return _get_brand_details()


@frappe.whitelist(allow_guest=True)
def get_brand_name():
return _get_brand_name() or "Frappe Cloud"


@frappe.whitelist(allow_guest=True)
def get_onboarding_details():
return {"message": get_onboarding_message()}
Empty file.
8 changes: 8 additions & 0 deletions press/press/doctype/brand_settings/brand_settings.js
Original file line number Diff line number Diff line change
@@ -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) {

// },
// });
Loading