fix: added login to fc button in dropdown
This commit is contained in:
parent
a3b880e95b
commit
37e535a28e
23
frontend/src/components/Icons/FrappeCloudIcon.vue
Normal file
23
frontend/src/components/Icons/FrappeCloudIcon.vue
Normal file
@ -0,0 +1,23 @@
|
||||
<template>
|
||||
<svg
|
||||
width="32"
|
||||
height="32"
|
||||
viewBox="0 0 32 32"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<rect
|
||||
x="0.75"
|
||||
y="0.75"
|
||||
width="30.5"
|
||||
height="30.5"
|
||||
rx="6.25"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.5"
|
||||
/>
|
||||
<path
|
||||
d="M24.5011 14.1124C23.3954 12.4873 21.532 11.5477 19.594 11.6747C18.7616 10.1384 17.2211 9.12267 15.4198 9.0084C14.1651 8.93222 12.8979 9.3766 11.9165 10.24C11.2456 10.8367 10.7611 11.5223 10.463 12.2968C10.289 12.7539 9.89151 13.0459 9.46912 13.0459H6.5V15.5852H9.46912C10.9226 15.5852 12.2271 14.6584 12.7737 13.2237C12.9227 12.8301 13.1712 12.4873 13.5439 12.1571C14.0284 11.7255 14.662 11.4969 15.2583 11.535C16.1528 11.5985 16.7863 12.0175 17.1839 12.538C17.6063 13.0205 17.8423 13.7696 17.979 14.5187C18.774 14.2902 19.6437 14.0997 20.476 14.2394C21.1593 14.3536 21.7929 14.7218 22.2525 15.2678C22.327 15.3567 22.4016 15.4456 22.4637 15.5471C23.06 16.4232 23.1718 17.5024 22.7743 18.5689C22.414 19.5592 21.0847 20.4607 19.9791 20.4607H11.3326C10.1524 20.4607 9.18339 19.5592 9.03432 18.4038H6.54969C6.71119 20.9686 8.78585 23 11.3326 23H19.9915C22.1283 23 24.3769 21.451 25.1098 19.4704C25.7931 17.6167 25.5695 15.6614 24.5135 14.0997L24.5011 14.1124Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
@ -50,11 +50,13 @@
|
||||
|
||||
<script setup>
|
||||
import BrandLogo from '@/components/BrandLogo.vue'
|
||||
import FrappeCloudIcon from '@/components/Icons/FrappeCloudIcon.vue'
|
||||
import Apps from '@/components/Apps.vue'
|
||||
import { sessionStore } from '@/stores/session'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { getSettings } from '@/stores/settings'
|
||||
import { showSettings, isMobileView } from '@/composables/settings'
|
||||
import { confirmLoginToFrappeCloud } from '@/composables/frappecloud'
|
||||
import { Dropdown } from 'frappe-ui'
|
||||
import { theme, toggleTheme } from '@/stores/theme'
|
||||
import { computed, h, markRaw } from 'vue'
|
||||
@ -156,6 +158,13 @@ function getStandardItem(item) {
|
||||
onClick: () => (showSettings.value = true),
|
||||
condition: () => !isMobileView.value,
|
||||
}
|
||||
case 'login_to_fc':
|
||||
return {
|
||||
icon: h(FrappeCloudIcon),
|
||||
label: __(item.label),
|
||||
onClick: () => confirmLoginToFrappeCloud(),
|
||||
condition: () => !isMobileView.value && window.is_fc_site,
|
||||
}
|
||||
case 'logout':
|
||||
return {
|
||||
icon: item.icon,
|
||||
|
||||
42
frontend/src/composables/frappecloud.js
Normal file
42
frontend/src/composables/frappecloud.js
Normal file
@ -0,0 +1,42 @@
|
||||
import { globalStore } from '@/stores/global'
|
||||
import { call } from 'frappe-ui'
|
||||
|
||||
const frappeCloudBaseEndpoint = 'https://frappecloud.com'
|
||||
|
||||
export const confirmLoginToFrappeCloud = () => {
|
||||
const { $dialog } = globalStore()
|
||||
$dialog({
|
||||
title: __('Login to Frappe Cloud?'),
|
||||
message: __(
|
||||
'Are you sure you want to login to your Frappe Cloud dashboard?',
|
||||
),
|
||||
actions: [
|
||||
{
|
||||
label: __('Confirm'),
|
||||
variant: 'solid',
|
||||
onClick(close) {
|
||||
loginToFrappeCloud()
|
||||
close()
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
const loginToFrappeCloud = () => {
|
||||
call(
|
||||
'frappe.integrations.frappe_providers.frappecloud_billing.current_site_info',
|
||||
).then((response) => {
|
||||
if (!response) return
|
||||
|
||||
let redirectRoute = ''
|
||||
|
||||
if (response.is_payment_method_added) {
|
||||
redirectRoute = '/dashboard'
|
||||
} else {
|
||||
redirectRoute = '/dashboard/welcome'
|
||||
}
|
||||
|
||||
window.open(`${frappeCloudBaseEndpoint}${redirectRoute}`, '_blank')
|
||||
})
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user