Skip to content

Commit

Permalink
enhancment: fix and polish sidebar toasts (#2215)
Browse files Browse the repository at this point in the history
* enhancment: fix and polish sidebar toasts

* fix: check for prod not alpha

* chore: replace Early Access with Production

* fix: pr review comments

* Update packages/shared/src/locales/en.json

Co-authored-by: Mark Nardi <[email protected]>

---------

Co-authored-by: Mark Nardi <[email protected]>
  • Loading branch information
nicole-obrien and MarkNerdi authored Apr 2, 2024
1 parent 08870a9 commit ae51be8
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 47 deletions.
26 changes: 16 additions & 10 deletions packages/desktop/views/dashboard/components/DashboardSidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@
import { LogoName } from '@auxiliary/logo'
import { IconButton, IconName } from '@bloomwalletio/ui'
import { ProfileActionsMenu, SidebarTab } from '@components'
import { APP_STAGE, AppStage } from '@core/app'
import { localize } from '@core/i18n'
import { StardustNetworkId } from '@core/network'
import { activeProfile, isSoftwareProfile } from '@core/profile/stores'
import { DashboardRoute, collectiblesRouter, dashboardRouter, governanceRouter, settingsRouter } from '@core/router'
import {
DashboardRoute,
collectiblesRouter,
dashboardRoute,
dashboardRouter,
governanceRouter,
settingsRouter,
} from '@core/router'
import { isDashboardSideBarExpanded } from '@core/ui'
import { IDashboardSidebarTab } from '@desktop/routers'
import features from '@features/features'
import { Logo } from '@ui'
import { campaignsRouter } from '../campaigns'
import LedgerStatusTile from './LedgerStatusTile.svelte'
import StrongholdStatusTile from './StrongholdStatusTile.svelte'
import { AutoUpdateToast, BackupToast, VersionToast } from './toasts'
import { dashboardRoute } from '@core/router'
import { StardustNetworkId } from '@core/network'
import { isDashboardSideBarExpanded } from '@core/ui'
import { campaignsRouter } from '../campaigns'
import { BackupToast, VersionToast } from './toasts'
let expanded = true
function toggleExpand(): void {
Expand Down Expand Up @@ -160,12 +167,11 @@

{#if expanded}
<dashboard-sidebar-tiles class="w-full flex flex-col space-y-2">
{#if false}
<!-- TODO: logic of when to display toast one at a time -->
<AutoUpdateToast />
{#if APP_STAGE === AppStage.PROD}
<BackupToast />
{:else}
<VersionToast />
{/if}
<VersionToast />
{#if $isSoftwareProfile}
<StrongholdStatusTile />
{:else}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
}
</script>

<SidebarToast
color="yellow"
header={localize(`${localeKey}.header`)}
body={localize(`${localeKey}.body`)}
button={{
text: localize(`${localeKey}.button`),
onClick,
}}
open={$isSoftwareProfile && requiresBackup}
/>
{#if requiresBackup}
<SidebarToast
color="yellow"
header={localize(`${localeKey}.header`)}
body={localize(`${localeKey}.body`)}
button={{
text: localize(`${localeKey}.button`),
onClick,
}}
open={$isSoftwareProfile && requiresBackup}
/>
{/if}
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
<script lang="ts">
import { Color, SidebarToast } from '@bloomwalletio/ui'
import { APP_STAGE, AppStage, openUrlInBrowser } from '@core/app'
import { APP_STAGE, AppStage } from '@core/app'
import { localize } from '@core/i18n'
const TOAST_PROPS: { [key in AppStage]: Color } = {
[AppStage.ALPHA]: 'cyan',
[AppStage.BETA]: 'sky',
[AppStage.PROD]: 'blue',
}
const localeKey = 'views.dashboard.toasts.version'
function onClick(): void {
openUrlInBrowser('https://medium.com/bloom-wallet/unveiling-bloom-early-access-8038d29c5f86')
}
</script>

<SidebarToast
color={TOAST_PROPS[APP_STAGE]}
header={localize(`popups.appUpdate.${APP_STAGE}`)}
body={localize(`${localeKey}.body`)}
body={localize('views.dashboard.toasts.version.body')}
open
dismissable={false}
button={APP_STAGE === AppStage.PROD ? { text: localize(`${localeKey}.button`), onClick } : undefined}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import { onboardingProfile, updateOnboardingProfile } from '../stores'
* Creates an initial backup for a profile's Stronghold.
*/
export async function backupInitialStronghold(): Promise<void> {
const strongholdBackupDestination = await Platform.getStrongholdBackupDestination(getDefaultStrongholdName())
const password = get(onboardingProfile)?.strongholdPassword
const $onboardingProfile = get(onboardingProfile)
const strongholdBackupDestination = await Platform.getStrongholdBackupDestination(
getDefaultStrongholdName($onboardingProfile?.name)
)
const password = $onboardingProfile?.strongholdPassword
if (strongholdBackupDestination && password) {
await backup(strongholdBackupDestination, password)
updateOnboardingProfile({ lastStrongholdBackupTime: new Date() })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Platform } from '@core/app/classes'
import { IError } from '@core/error/interfaces'
import { backup } from '@core/profile-manager'
import { updateActiveProfile } from '@core/profile/stores'
import { getActiveProfile, updateActiveProfile } from '@core/profile/stores'
import { getDefaultStrongholdName } from '@core/stronghold'

export async function exportStronghold(
password: string,
callback?: (cancelled: boolean, error?: string) => void
): Promise<void> {
try {
const destination = await Platform.getStrongholdBackupDestination(getDefaultStrongholdName())
const activeProfile = getActiveProfile()
const destination = await Platform.getStrongholdBackupDestination(getDefaultStrongholdName(activeProfile?.name))
if (destination) {
await backup(destination, password)
updateActiveProfile({ lastStrongholdBackupTime: new Date() })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getTimestampForFilenames } from '@core/utils'

export function getDefaultStrongholdName(): string {
export function getDefaultStrongholdName(profileName: string | undefined): string {
const timestamp = getTimestampForFilenames()
return `bloom-backup-${timestamp}.stronghold`
return `bloom-backup-${profileName?.replaceAll(' ', '')}-${timestamp}.stronghold`
}
2 changes: 1 addition & 1 deletion packages/shared/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@
"installedVersion": "Installierte Version",
"newVersion": "Neue Version",
"stage": "Phase",
"prod": "Early Access",
"prod": "Production",
"alpha": "Alpha",
"beta": "Beta",
"releasedAt": "Veröffentlicht am",
Expand Down
7 changes: 3 additions & 4 deletions packages/shared/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,11 @@
"toasts": {
"backup": {
"header": "Backup Required",
"body": "You have not backed up your profile yet! We highly recommend backing this up in case you lose access to this device.",
"body": "You haven't backed up your profile in while.",
"button": "Backup now"
},
"version": {
"body": "You are currently using an early version of Bloom.",
"button": "Find out more"
"body": "You are currently using a development version of Bloom."
},
"update": {
"header": "Update Required",
Expand Down Expand Up @@ -848,7 +847,7 @@
"installedVersion": "Installed version",
"newVersion": "New version",
"stage": "Stage",
"prod": "Early Access",
"prod": "Production",
"alpha": "Alpha",
"beta": "Beta",
"releasedAt": "Released at",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/locales/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@
"installedVersion": "Installed version",
"newVersion": "New version",
"stage": "Stage",
"prod": "Early Access",
"prod": "Production",
"alpha": "Alpha",
"beta": "Beta",
"releasedAt": "Released at",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@
"installedVersion": "Version installée",
"newVersion": "New version",
"stage": "Étape",
"prod": "Early Access",
"prod": "Production",
"alpha": "Alpha",
"beta": "Bêta",
"releasedAt": "Publié le",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@
"installedVersion": "Installed version",
"newVersion": "New version",
"stage": "Stage",
"prod": "Early Access",
"prod": "Production",
"alpha": "Alpha",
"beta": "Beta",
"releasedAt": "Released at",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@
"installedVersion": "Geïnstalleerde versie",
"newVersion": "Nieuwe versie",
"stage": "Stage",
"prod": "Early Access",
"prod": "Production",
"alpha": "Alpha",
"beta": "Beta",
"releasedAt": "Uitgebracht op",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@
"installedVersion": "Versão instalada",
"newVersion": "Nova versão",
"stage": "Stage",
"prod": "Early Access",
"prod": "Production",
"alpha": "Alpha",
"beta": "Beta",
"releasedAt": "Released at",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/locales/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@
"installedVersion": "Installed version",
"newVersion": "New version",
"stage": "Stage",
"prod": "Early Access",
"prod": "Production",
"alpha": "Alpha",
"beta": "Beta",
"releasedAt": "Released at",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@
"installedVersion": "Installed version",
"newVersion": "New version",
"stage": "Stage",
"prod": "Early Access",
"prod": "Production",
"alpha": "Alpha",
"beta": "Beta",
"releasedAt": "Released at",
Expand Down

0 comments on commit ae51be8

Please sign in to comment.