-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web/satellite/v2: add partner upgrade banner to project dashboard
This change adds a banner that prompt eligible users to upgrade their account with their corresponding partner. Also, some minor changes to the upgrade dialog are made, particularly the success notice of the pricing plan step. Issue: storj/storj-private#559 Change-Id: I580e13dbd3ea7c676e96dfa68768c184ec536400
- Loading branch information
1 parent
8258809
commit 2c9c698
Showing
8 changed files
with
207 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
web/satellite/vuetify-poc/src/components/NextStepsContainer.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (C) 2024 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
<template> | ||
<div v-if="!hideContainer"> | ||
<h5 class="text-h5 font-weight-bold">Welcome {{ user.fullName }}!</h5> | ||
<p class="my-3">Your next steps</p> | ||
|
||
<partner-upgrade-notice-banner v-model="partnerBannerVisible" /> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed, ref, watch } from 'vue'; | ||
import { User } from '@/types/users'; | ||
import { useUsersStore } from '@/store/modules/usersStore'; | ||
import PartnerUpgradeNoticeBanner from '@poc/components/PartnerUpgradeNoticeBanner.vue'; | ||
const usersStore = useUsersStore(); | ||
const partnerBannerVisible = ref(true); | ||
const hideContainer = ref(false); | ||
const user = computed<User>(() => usersStore.state.user); | ||
// hide container when no content is visible. | ||
watch(partnerBannerVisible, (value) => { | ||
if (!value) { | ||
// hide container when no content is visible | ||
hideContainer.value = true; | ||
} | ||
}); | ||
</script> |
141 changes: 141 additions & 0 deletions
141
web/satellite/vuetify-poc/src/components/PartnerUpgradeNoticeBanner.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
// Copyright (C) 2024 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
<template> | ||
<v-alert | ||
v-if="!isLoading && planInfo" | ||
:model-value="model" | ||
:title="planInfo.bannerTitle" | ||
closable | ||
variant="tonal" | ||
type="success" | ||
rounded="lg" | ||
class="mt-2 mb-4" | ||
@click:close="dismiss" | ||
> | ||
<template #prepend /> | ||
<template #text> | ||
<p> | ||
{{ planInfo.bannerText }} | ||
</p> | ||
<v-btn | ||
class="mt-2" | ||
color="success" | ||
@click="toggleUpgradeDialog" | ||
> | ||
Learn More | ||
</v-btn> | ||
</template> | ||
</v-alert> | ||
|
||
<upgrade-account-dialog | ||
ref="upgradeDialog" | ||
v-model="isUpgradeDialogShown" | ||
/> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { VAlert, VBtn } from 'vuetify/components'; | ||
import { computed, onBeforeMount, ref, watch } from 'vue'; | ||
import { User } from '@/types/users'; | ||
import { PricingPlanInfo } from '@/types/common'; | ||
import { useUsersStore } from '@/store/modules/usersStore'; | ||
import { AnalyticsErrorEventSource } from '@/utils/constants/analyticsEventNames'; | ||
import { useNotify } from '@/utils/hooks'; | ||
import { useConfigStore } from '@/store/modules/configStore'; | ||
import { PaymentsHttpApi } from '@/api/payments'; | ||
import { useLoading } from '@/composables/useLoading'; | ||
import UpgradeAccountDialog from '@poc/components/dialogs/upgradeAccountFlow/UpgradeAccountDialog.vue'; | ||
const payments: PaymentsHttpApi = new PaymentsHttpApi(); | ||
const configStore = useConfigStore(); | ||
const usersStore = useUsersStore(); | ||
const { isLoading, withLoading } = useLoading(); | ||
const notify = useNotify(); | ||
const isUpgradeDialogShown = ref<boolean>(false); | ||
const planInfo = ref<PricingPlanInfo>(); | ||
const upgradeDialog = ref<{ setSecondStep: ()=>void }>(); | ||
const props = defineProps<{ | ||
modelValue: boolean, | ||
}>(); | ||
const model = computed<boolean>({ | ||
get: () => props.modelValue, | ||
set: value => emit('update:modelValue', value), | ||
}); | ||
const emit = defineEmits<{ | ||
(event: 'update:modelValue', value: boolean): void, | ||
}>(); | ||
async function dismiss() { | ||
model.value = false; | ||
try { | ||
const noticeDismissal = { ...usersStore.state.settings.noticeDismissal }; | ||
noticeDismissal.partnerUpgradeBanner = true; | ||
await usersStore.updateSettings({ noticeDismissal }); | ||
} catch (error) { | ||
notify.notifyError(error, AnalyticsErrorEventSource.PROJECT_DASHBOARD_PAGE); | ||
} | ||
} | ||
function toggleUpgradeDialog() { | ||
// go to the second step, which in this case | ||
// will be the pricing plan selection step. | ||
upgradeDialog.value?.setSecondStep(); | ||
isUpgradeDialogShown.value = true; | ||
} | ||
onBeforeMount(() => { | ||
withLoading(async () => { | ||
if (!configStore.state.config.billingFeaturesEnabled | ||
|| !configStore.state.config.pricingPackagesEnabled | ||
|| usersStore.noticeDismissal.partnerUpgradeBanner) { | ||
model.value = false; | ||
return; | ||
} | ||
const user: User = usersStore.state.user; | ||
if (user.paidTier || !user.partner) { | ||
model.value = false; | ||
return; | ||
} | ||
try { | ||
model.value = await payments.pricingPackageAvailable(); | ||
} catch (error) { | ||
notify.notifyError(error, AnalyticsErrorEventSource.PROJECT_DASHBOARD_PAGE); | ||
model.value = false; | ||
return; | ||
} | ||
let config; | ||
try { | ||
config = (await import('@/components/account/billing/pricingPlans/pricingPlanConfig.json')).default; | ||
} catch { | ||
model.value = false; | ||
return; | ||
} | ||
planInfo.value = config[user.partner] as PricingPlanInfo; | ||
if (!planInfo.value) { | ||
model.value = false; | ||
return; | ||
} | ||
model.value = true; | ||
}); | ||
}); | ||
watch(() => [usersStore.state.user.paidTier, isUpgradeDialogShown.value], (value) => { | ||
if (value[0] && !value[1]) { | ||
// throttle the banner dismissal for the dialog close animation. | ||
setTimeout(() => model.value = false, 500); | ||
} | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,4 +240,6 @@ watch(content, (value) => { | |
return; | ||
} | ||
}); | ||
defineExpose({ setSecondStep }); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters