Skip to content

Commit

Permalink
Merge branch 'master' into stripe-mandate
Browse files Browse the repository at this point in the history
  • Loading branch information
shadrak98 committed Jun 26, 2024
2 parents 4580e7e + 1ef0085 commit b6b804d
Show file tree
Hide file tree
Showing 51 changed files with 1,184 additions and 1,100 deletions.
2 changes: 1 addition & 1 deletion dashboard/src/views/auth/Auth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export default {
},
computed: {
saasProduct() {
return this.$resources.signupSettings.data?.saas_product;
return this.$resources.signupSettings.data?.product_trial;
},
isLogin() {
return this.$route.name == 'Login' && !this.$route.query.forgot;
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/views/auth/SetupAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default {
this.invitedByParentTeam = res.invited_by_parent_team;
this.oauthSignup = res.oauth_signup;
this.countries = res.countries;
this.saasProduct = res.saas_product;
this.saasProduct = res.product_trial;
}
}
};
Expand Down
4 changes: 3 additions & 1 deletion dashboard/src2/components/NavigationItems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export default {
icon: () => h(App),
route: '/apps',
isActive: routeName.startsWith('Marketplace'),
condition: this.$team.doc.is_desk_user || this.$session.hasAppsAccess,
condition:
this.$team.doc.is_desk_user ||
(!!this.$team.doc.is_developer && this.$session.hasAppsAccess),
disabled
},
{
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src2/components/Onboarding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</p>
<Button
class="mt-2"
:route="`/app-trial/${pendingSiteRequest.saas_product}`"
:route="`/app-trial/${pendingSiteRequest.product_trial}`"
>
Continue
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<Card title="Email Notifications">
<Card v-if="$team.doc.user === $session.user" title="Email Notifications">
<template #actions>
<Button icon-left="edit" @click="showEmailsEditDialog = true">
Edit
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src2/components/settings/profile/AccountPartner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<strong>Add Partner Code</strong> to link with your Partner team.
</span>
<ListItem
v-else
:title="partner_billing_name"
:subtitle="$team.doc.partner_email"
v-else="$team.doc.partner_email"
/>
</div>
<Dialog
Expand All @@ -41,7 +41,7 @@
v-model="showAddPartnerCodeDialog"
>
<template v-slot:body-content>
<p class="text-p-base pb-3">
<p class="pb-3 text-p-base">
Enter partner code provided by your Partner
</p>
<FormControl
Expand Down
85 changes: 35 additions & 50 deletions dashboard/src2/components/settings/profile/AccountProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
<ListItem
title="Become Marketplace Developer"
subtitle="Become a marketplace app publisher"
v-if="showBecomePublisherButton"
v-if="!$team.doc.is_developer"
>
<template #actions>
<Button @click="confirmPublisherAccount()">
<Button @click="confirmPublisherAccount">
<span>Become a Publisher</span>
</Button>
</template>
Expand Down Expand Up @@ -163,11 +163,10 @@
</template>

<script>
import { toast } from 'vue-sonner';
import FileUploader from '@/components/FileUploader.vue';
import { notify } from '@/utils/toast';
import { getSessionUser } from '../../../data/session';
import { getTeam } from '../../../data/team';
import FinalizeInvoicesDialog from '../../billing/FinalizeInvoicesDialog.vue';
import { confirmDialog } from '../../../utils/components';
export default {
name: 'AccountProfile',
Expand All @@ -180,16 +179,15 @@ export default {
showProfileEditDialog: false,
showEnableAccountDialog: false,
showDisableAccountDialog: false,
showBecomePublisherButton: false,
showFinalizeInvoicesDialog: false
};
},
computed: {
teamEnabled() {
return getTeam().doc.enabled;
return this.$team.doc.enabled;
},
user() {
return this.$team.doc.user_info;
return this.$team?.doc?.user_info;
}
},
resources: {
Expand All @@ -216,74 +214,61 @@ export default {
if (data === 'Unpaid Invoices') {
this.showFinalizeInvoicesDialog = true;
} else {
notify({
title: 'Account disabled',
message: 'Your account was disabled successfully',
icon: 'check',
color: 'green'
});
toast.success('Your account was disabled successfully');
this.reloadAccount();
}
}
},
enableAccount: {
url: 'press.api.account.enable_account',
onSuccess() {
notify({
title: 'Account enabled',
message: 'Your account was enabled successfully',
icon: 'check',
color: 'green'
});
toast.success('Your account was enabled successfully');
this.reloadAccount();
this.showEnableAccountDialog = false;
}
},
isDeveloperAccountAllowed() {
return {
url: 'press.api.marketplace.developer_toggle_allowed',
auto: true,
onSuccess(data) {
if (data) {
this.showBecomePublisherButton = true;
}
}
};
},
becomePublisher() {
return {
url: 'press.api.marketplace.become_publisher',
onSuccess() {
this.$router.push('/marketplace');
}
};
}
},
methods: {
reloadAccount() {
getTeam().reload();
this.$team.doc.reload();
this.$resources.user.reload();
},
onProfilePhotoChange() {
this.reloadAccount();
this.notifySuccess();
},
notifySuccess() {
notify({
title: 'Updated profile information',
icon: 'check',
color: 'green'
});
toast.success('Your profile was updated successfully');
},
confirmPublisherAccount() {
this.$confirm({
confirmDialog({
title: 'Become a marketplace app developer?',
message:
'You will be able to publish apps to our Marketplace upon confirmation.',
actionLabel: 'Yes',
action: closeDialog => {
this.$resources.becomePublisher.submit();
closeDialog();
onSuccess: ({ hide }) => {
toast.promise(
this.$team.setValue.submit(
{
is_developer: 1
},
{
onSuccess: () => {
hide();
this.$router.push({
name: 'Marketplace App List'
});
},
onError(e) {
console.error(e);
}
}
),
{
success: 'You can now publish apps to our Marketplace',
error: 'Failed to mark you as a developer',
loading: 'Making you a developer...'
}
);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="space-y-5 p-5">
<div class="grid grid-cols-1 items-start gap-5 sm:grid-cols-2">
<div class="p-5">
<div class="space-y-5">
<AccountProfile />
<AccountEmails />
<AccountReferral />
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src2/pages/LoginSignup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export default {
},
computed: {
saasProduct() {
return this.$resources.signupSettings.data?.saas_product;
return this.$resources.signupSettings.data?.product_trial;
},
isLogin() {
return this.$route.name == 'Login' && !this.$route.query.forgot;
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src2/pages/NewAppTrial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ export default {
saasProduct() {
return {
type: 'document',
doctype: 'SaaS Product',
doctype: 'Product Trial',
name: this.productId
};
},
siteRequest() {
if (!this.pendingSiteRequest || this.completedSites.length) return;
return {
type: 'document',
doctype: 'SaaS Product Site Request',
doctype: 'Product Trial Request',
name: this.pendingSiteRequest,
realtime: true,
onSuccess(doc) {
Expand Down
1 change: 0 additions & 1 deletion dashboard/src2/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<script setup>
import Header from '../components/Header.vue';
import { Breadcrumbs } from 'frappe-ui';
import { provide, ref } from 'vue';
import { icon } from '../utils/components';
import TabsWithRouter from '../components/TabsWithRouter.vue';
import { getTeam } from '../data/team';
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src2/pages/SetupAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default {
this.oauthSignup = res.oauth_signup;
this.oauthDomain = res.oauth_domain;
this.countries = res.countries;
this.saasProduct = res.saas_product;
this.saasProduct = res.product_trial;
}
}
};
Expand Down
8 changes: 6 additions & 2 deletions press/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,13 +943,17 @@ def get_site_sid(self, site, user=None):
return result and result.get("sid")

def get_site_info(self, site):
return self.get(f"benches/{site.bench}/sites/{site.name}/info")["data"]
result = self.get(f"benches/{site.bench}/sites/{site.name}/info")
if result:
return result["data"]

def get_sites_info(self, bench, since):
return self.post(f"benches/{bench.name}/info", data={"since": since})

def get_site_analytics(self, site):
return self.get(f"benches/{site.bench}/sites/{site.name}/analytics")["data"]
result = self.get(f"benches/{site.bench}/sites/{site.name}/analytics")
if result:
return result["data"]

def get_sites_analytics(self, bench):
return self.get(f"benches/{bench.name}/analytics")
Expand Down
48 changes: 24 additions & 24 deletions press/api/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def signup(email, product=None, referrer=None, new_signup_flow=False):
"email": email,
"role": "Press Admin",
"referrer_id": referrer,
"saas_product": product,
"product_trial": product,
"send_email": True,
"new_signup_flow": new_signup_flow,
}
Expand Down Expand Up @@ -136,10 +136,10 @@ def setup_account(
doc.append("child_team_members", {"child_team": team})
doc.save()

if account_request.saas_product:
if account_request.product_trial:
frappe.new_doc(
"SaaS Product Site Request",
saas_product=account_request.saas_product,
"Product Trial Request",
product_trial=account_request.product_trial,
account_request=account_request.name,
team=team_doc.name,
).insert(ignore_permissions=True)
Expand Down Expand Up @@ -278,13 +278,13 @@ def validate_request_key(key, timezone=None):
if account_request:
data = get_country_info()
possible_country = data.get("country") or get_country_from_timezone(timezone)
saas_product = frappe.db.get_value(
"SaaS Product",
{"name": account_request.saas_product},
product_trial = frappe.db.get_value(
"Product Trial",
{"name": account_request.product_trial},
pluck="name",
)
saas_product_doc = (
frappe.get_doc("SaaS Product", saas_product) if saas_product else None
product_trial_doc = (
frappe.get_doc("Product Trial", product_trial) if product_trial else None
)
capture("clicked_verify_link", "fc_signup", account_request.email)
return {
Expand All @@ -302,14 +302,14 @@ def validate_request_key(key, timezone=None):
"oauth_domain": frappe.db.exists(
"OAuth Domain Mapping", {"email_domain": account_request.email.split("@")[1]}
),
"saas_product": {
"name": saas_product_doc.name,
"title": saas_product_doc.title,
"logo": saas_product_doc.logo,
"signup_fields": saas_product_doc.signup_fields,
"description": saas_product_doc.description,
"product_trial": {
"name": product_trial_doc.name,
"title": product_trial_doc.title,
"logo": product_trial_doc.logo,
"signup_fields": product_trial_doc.signup_fields,
"description": product_trial_doc.description,
}
if saas_product_doc
if product_trial_doc
else None,
}

Expand Down Expand Up @@ -464,18 +464,18 @@ def signup_settings(product=None):
settings = frappe.get_single("Press Settings")

product = frappe.utils.cstr(product)
saas_product = None
product_trial = None
if product:
saas_product = frappe.db.get_value(
"SaaS Product",
product_trial = frappe.db.get_value(
"Product Trial",
{"name": product, "published": 1},
["title", "description", "logo"],
as_dict=1,
)

return {
"enable_google_oauth": settings.enable_google_oauth,
"saas_product": saas_product,
"product_trial": product_trial,
"oauth_domains": frappe.get_all(
"OAuth Domain Mapping", ["email_domain", "social_login_key", "provider_name"]
),
Expand Down Expand Up @@ -794,18 +794,18 @@ def user_prompts():
def get_site_request(product):
team = frappe.local.team()
requests = frappe.qb.get_query(
"SaaS Product Site Request",
"Product Trial Request",
filters={
"team": team.name,
"saas_product": product,
"product_trial": product,
},
fields=["name", "status", "site", "site.trial_end_date as trial_end_date"],
order_by="creation desc",
).run(as_dict=1)
if not requests:
site_request = frappe.new_doc(
"SaaS Product Site Request",
saas_product=product,
"Product Trial Request",
product_trial=product,
team=team.name,
).insert(ignore_permissions=True)
return {"pending": site_request.name}
Expand Down
Loading

0 comments on commit b6b804d

Please sign in to comment.