Skip to content

Commit

Permalink
feat(user-profile-overview-panel): add downloads menu item and wire u…
Browse files Browse the repository at this point in the history
…p download panel navigation (#2113)

* feat(env-and-config): add web app download path environment variable

* feat(user-profile-saga): add and handle downloads stage and actions

* feat(downloads-panel): add downloads panel

* feat(user-profile-overview-panel): add downloads menu item and wire up download panel navigation

* refactor: rename panel header and menu item
  • Loading branch information
domw30 authored Jul 22, 2024
1 parent 1533d53 commit cc2755a
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/messenger/user-profile/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
openEditProfile,
openUserProfile,
openSettings,
openDownloads,
openAccountManagement,
} from '../../../store/user-profile';
import { logout } from '../../../store/authentication';
Expand All @@ -32,6 +33,7 @@ export interface Properties extends PublicProperties {
openEditProfile: () => void;
openRewardsDialog: () => void;
openSettings: () => void;
openDownloads: () => void;
openAccountManagement: () => void;
}

Expand Down Expand Up @@ -59,6 +61,7 @@ export class Container extends React.Component<Properties> {
openEditProfile,
openRewardsDialog,
openSettings,
openDownloads,
openAccountManagement,
};
}
Expand All @@ -77,6 +80,7 @@ export class Container extends React.Component<Properties> {
onBackToOverview={this.props.openUserProfile}
onRewards={this.props.openRewardsDialog}
onSettings={this.props.openSettings}
onDownloads={this.props.openDownloads}
onManageAccounts={this.props.openAccountManagement}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class DownloadsPanel extends React.Component<Properties> {
return (
<div {...cn()}>
<div {...cn('header-container')}>
<PanelHeader title={'Downloads'} onBack={this.back} />
<PanelHeader title={'Download'} onBack={this.back} />
</div>

<div {...cn('body')}>
Expand Down
8 changes: 8 additions & 0 deletions src/components/messenger/user-profile/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { OverviewPanel } from './overview-panel';
import { EditProfileContainer } from '../../edit-profile/container';
import { SettingsPanelContainer } from './settings-panel/container';
import { AccountManagementContainer } from './account-management-panel/container';
import { DownloadsPanel } from './downloads-panel';

describe(UserProfile, () => {
const subject = (props: Partial<Properties> = {}) => {
Expand All @@ -22,6 +23,7 @@ describe(UserProfile, () => {
onBackToOverview: () => {},
onRewards: () => {},
onSettings: () => {},
onDownloads: () => {},
onManageAccounts: () => {},
...props,
};
Expand All @@ -47,6 +49,12 @@ describe(UserProfile, () => {
expect(wrapper).toHaveElement(SettingsPanelContainer);
});

it('renders Downloads Panel Container when stage is Downloads', () => {
const wrapper = subject({ stage: Stage.Downloads });

expect(wrapper).toHaveElement(DownloadsPanel);
});

it('renders Wallets Panel Container when stage is Wallets', () => {
const wrapper = subject({ stage: Stage.AccountManagement });

Expand Down
4 changes: 4 additions & 0 deletions src/components/messenger/user-profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Stage } from '../../../store/user-profile';
import { EditProfileContainer } from '../../edit-profile/container';
import { SettingsPanelContainer } from './settings-panel/container';
import { AccountManagementContainer } from './account-management-panel/container';
import { DownloadsPanel } from './downloads-panel';

export interface Properties {
stage: Stage;
Expand All @@ -19,6 +20,7 @@ export interface Properties {
onBackToOverview: () => void;
onRewards: () => void;
onSettings: () => void;
onDownloads: () => void;
onManageAccounts: () => void;
}

Expand All @@ -37,12 +39,14 @@ export class UserProfile extends React.Component<Properties> {
onOpenEditProfile={this.props.onEdit}
onOpenRewards={this.props.onRewards}
onOpenSettings={this.props.onSettings}
onOpenDownloads={this.props.onDownloads}
onManageAccounts={this.props.onManageAccounts}
/>
)}

{this.props.stage === Stage.EditProfile && <EditProfileContainer onClose={this.props.onBackToOverview} />}
{this.props.stage === Stage.Settings && <SettingsPanelContainer onClose={this.props.onBackToOverview} />}
{this.props.stage === Stage.Downloads && <DownloadsPanel onClose={this.props.onBackToOverview} />}
{this.props.stage === Stage.AccountManagement && (
<AccountManagementContainer onClose={this.props.onBackToOverview} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe(OverviewPanel, () => {
onOpenEditProfile: () => {},
onOpenRewards: () => {},
onOpenSettings: () => {},
onOpenDownloads: () => {},
onManageAccounts: () => {},

...props,
Expand Down Expand Up @@ -96,6 +97,17 @@ describe(OverviewPanel, () => {
expect(onOpenSettings).toHaveBeenCalled();
});

it('publishes onOpenDownloads event', () => {
featureFlags.enableUserSettings = true;

const onOpenDownloads = jest.fn();
const wrapper = subject({ onOpenDownloads });

wrapper.find(Button).at(5).simulate('press');

expect(onOpenDownloads).toHaveBeenCalled();
});

it('publishes openAccountManagement event', () => {
const onOpenAccountManagement = jest.fn();
const wrapper = subject({ onManageAccounts: onOpenAccountManagement });
Expand Down
16 changes: 16 additions & 0 deletions src/components/messenger/user-profile/overview-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Image, Modal } from '@zero-tech/zui/components';
import { Button, Variant as ButtonVariant, Color as ButtonColor } from '@zero-tech/zui/components/Button';
import {
IconCurrencyEthereum,
IconDownload2,
IconLock1,
IconLogOut3,
IconPlus,
Expand All @@ -33,6 +34,7 @@ export interface Properties {
onOpenEditProfile: () => void;
onOpenRewards: () => void;
onOpenSettings: () => void;
onOpenDownloads: () => void;
onManageAccounts: () => void;
}

Expand Down Expand Up @@ -85,6 +87,10 @@ export class OverviewPanel extends React.Component<Properties, State> {
this.props.onOpenSettings();
};

openDownloads = () => {
this.props.onOpenDownloads();
};

onManageAccounts = () => {
this.props.onManageAccounts();
};
Expand Down Expand Up @@ -163,6 +169,16 @@ export class OverviewPanel extends React.Component<Properties, State> {
Settings
</Button>
)}

<Button
{...cn('action-button')}
variant={ButtonVariant.Secondary}
onPress={this.openDownloads}
startEnhancer={<IconDownload2 size={20} />}
color={ButtonColor.Greyscale}
>
Download
</Button>
</div>
);
}
Expand Down

0 comments on commit cc2755a

Please sign in to comment.