Skip to content

Commit

Permalink
[DDW-852] Display tooltip for list view
Browse files Browse the repository at this point in the history
  • Loading branch information
renanvalentin committed Feb 2, 2022
1 parent b8b1830 commit 07d8fd5
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 15 deletions.
1 change: 1 addition & 0 deletions source/common/config/electron-store.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const STORAGE_KEYS: Record<string, StorageKey> = {
READ_NEWS: 'READ-NEWS',
RESET: 'RESET',
SMASH_SERVER: 'SMASH-SERVER',
STAKE_POOLS_LIST_VIEW_TOOLTIP: 'STAKE-POOLS-LIST-VIEW-TOOLTIP',
STAKING_INFO_WAS_OPEN: 'ALONZO-INFO-WAS-OPEN',
TERMS_OF_USE_ACCEPTANCE: 'TERMS-OF-USE-ACCEPTANCE',
THEME: 'THEME',
Expand Down
1 change: 1 addition & 0 deletions source/common/types/electron-store.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type StorageKey =
| 'READ-NEWS'
| 'RESET'
| 'SMASH-SERVER'
| 'STAKE-POOLS-LIST-VIEW-TOOLTIP'
| 'TERMS-OF-USE-ACCEPTANCE'
| 'THEME'
| 'TOKEN-FAVORITES'
Expand Down
4 changes: 4 additions & 0 deletions source/renderer/app/api/utils/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ export default class LocalStorageApi {
LocalStorageApi.unset(keys.HARDWARE_WALLET_DEVICES, deviceId);
unsetHardwareWalletDevicesAll = async (): Promise<void> =>
LocalStorageApi.unset(keys.HARDWARE_WALLET_DEVICES);
setStakePoolsListViewTooltip = async (visited: boolean): Promise<void> =>
LocalStorageApi.set(keys.STAKE_POOLS_LIST_VIEW_TOOLTIP, visited);
getStakePoolsListViewTooltip = async (): Promise<boolean> =>
LocalStorageApi.get(keys.STAKE_POOLS_LIST_VIEW_TOOLTIP, true);
reset = async () => {
await LocalStorageApi.reset();
};
Expand Down
34 changes: 20 additions & 14 deletions source/renderer/app/components/staking/stake-pools/StakePools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,26 @@ const messages = defineMessages({
});
const SELECTED_INDEX_TABLE = 'selectedIndexTable';
type Props = {
wallets: Array<Wallet>;
currentLocale: string;
stakePoolsList: Array<StakePool>;
onOpenExternalLink: (...args: Array<any>) => any;
currentTheme: string;
updateDelegatingStake: (...args: Array<any>) => any;
rankStakePools: (...args: Array<any>) => any;
selectedDelegationWalletId?: string | null | undefined;
stake?: number | null | undefined;
onDelegate: (...args: Array<any>) => any;
isLoading: boolean;
getStakePoolById: (...args: Array<any>) => any;
isFetching: boolean;
isListViewTooltipVisible?: boolean;
isLoading: boolean;
isRanking: boolean;
stakePoolsDelegatingList: Array<StakePool>;
getStakePoolById: (...args: Array<any>) => any;
maxDelegationFunds: number;
onDelegate: (...args: Array<any>) => any;
onListViewClick: (...args: Array<any>) => any;
onOpenExternalLink: (...args: Array<any>) => any;
onSmashSettingsClick: (...args: Array<any>) => any;
rankStakePools: (...args: Array<any>) => any;
selectedDelegationWalletId?: string | null | undefined;
smashServerUrl: string | null | undefined;
maxDelegationFunds: number;
stake?: number | null | undefined;
stakePoolsDelegatingList: Array<StakePool>;
stakePoolsList: Array<StakePool>;
updateDelegatingStake: (...args: Array<any>) => any;
wallets: Array<Wallet>;
};
type State = {
search: string;
Expand Down Expand Up @@ -135,12 +137,14 @@ class StakePools extends Component<Props, State> {
isListView: false,
});
};
handleListView = () =>
handleListView = () => {
this.setState({
isGridView: false,
isGridRewardsView: false,
isListView: true,
});
this.props.onListViewClick();
};
handleSetListActive = (selectedList: string) =>
this.setState({
selectedList,
Expand Down Expand Up @@ -170,8 +174,9 @@ class StakePools extends Component<Props, State> {
stake,
onOpenExternalLink,
currentTheme,
isLoading,
isFetching,
isListViewTooltipVisible,
isLoading,
isRanking,
stakePoolsDelegatingList,
getStakePoolById,
Expand Down Expand Up @@ -270,6 +275,7 @@ class StakePools extends Component<Props, State> {
onGridRewardsView={this.handleGridRewardsView}
onListView={this.handleListView}
isListView={isListView}
isListViewTooltipVisible={isListViewTooltipVisible}
isGridView={isGridView}
isGridRewardsView={isGridRewardsView}
// @ts-ignore ts-migrate(2769) FIXME: No overload matches this call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
background-color: var(
--theme-staking-stake-pools-search-clear-button-background-color
);

svg {
> g > g {
opacity: 1;
}
}
}

svg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Props = {
label?: string;
placeholder?: string;
isListView?: boolean;
isListViewTooltipVisible?: boolean;
isGridView?: boolean;
isGridRewardsView?: boolean;
onSearch: (...args: Array<any>) => any;
Expand Down Expand Up @@ -100,6 +101,7 @@ export class StakePoolsSearch extends Component<Props> {
placeholder,
search,
isListView,
isListViewTooltipVisible,
isGridView,
isGridRewardsView,
} = this.props;
Expand Down Expand Up @@ -182,7 +184,10 @@ export class StakePoolsSearch extends Component<Props> {
</button>
</PopOver>
)}
<PopOver content={intl.formatMessage(messages.listIconTooltip)}>
<PopOver
visible={isListViewTooltipVisible}
content={intl.formatMessage(messages.listIconTooltip)}
>
<button className={listButtonClasses} onClick={onListView}>
<SVGInline svg={listIcon} />
</button>
Expand Down
2 changes: 2 additions & 0 deletions source/renderer/app/containers/staking/StakePoolsListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class StakePoolsListPage extends Component<Props> {
stake={stake}
onDelegate={this.handleDelegate}
isLoading={isLoading}
isListViewTooltipVisible={staking.stakePoolsListViewTooltipVisible}
onListViewClick={staking.hideStakePoolsListViewTooltip}
isFetching={isFetchingStakePools}
isRanking={isRanking}
getStakePoolById={getStakePoolById}
Expand Down
17 changes: 17 additions & 0 deletions source/renderer/app/stores/StakingStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export default class StakingStore extends Store {
smashServerUrlError: LocalizableError | null | undefined = null;
@observable
smashServerLoading = false;
@observable
stakePoolsListViewTooltipVisible = true;

/* ---------- Redeem ITN Rewards ---------- */
@observable
Expand Down Expand Up @@ -143,6 +145,7 @@ export default class StakingStore extends Store {
this._startStakePoolsFetchTracker();

this._getStakingInfoWasOpen();
this._getStakePoolsListViewTooltip();
}

// REQUESTS
Expand Down Expand Up @@ -280,6 +283,20 @@ export default class StakingStore extends Store {
this.api.localStorage.setStakingInfoWasOpen();
};
@action
_getStakePoolsListViewTooltip = async () => {
const tooltipShown = await this.api.localStorage.getStakePoolsListViewTooltip();
runInAction(() => {
this.stakePoolsListViewTooltipVisible = tooltipShown;
});
};
@action
hideStakePoolsListViewTooltip = () => {
this.stakePoolsListViewTooltipVisible = false;
this.api.localStorage.setStakePoolsListViewTooltip(
this.stakePoolsListViewTooltipVisible
);
};
@action
_stakePoolsFetchTracker = () => {
const lastNumberOfStakePoolsFetched = this.numberOfStakePoolsFetched;
this.numberOfStakePoolsFetched = this.stakePools.length;
Expand Down

0 comments on commit 07d8fd5

Please sign in to comment.