Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

feat: Dashboard Safe Apps #3738

Merged
merged 34 commits into from
Apr 13, 2022
Merged

feat: Dashboard Safe Apps #3738

merged 34 commits into from
Apr 13, 2022

Conversation

DiogoSoaress
Copy link
Member

@DiogoSoaress DiogoSoaress commented Mar 29, 2022

What it solves

Resolves #3698

How this PR fixes it

Implements a "Safe Apps" section in the Dashboard with 5 SafeApps and a button to the Safe Apps page.
The first Safe Apps displayed are the most relevant by usage and are followed by random Safe Apps to fill the 5 Cards.

How to test it

Go to /home.
The "Safe Apps" section should show the ranked apps + random apps.

Screenshots

Screen Shot 2022-03-29 at 17 28 29

Screen Shot 2022-03-29 at 17 28 44

Screen Shot 2022-03-30 at 11 02 44

@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Mar 29, 2022

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@github-actions
Copy link

Deployment links

🟠 Rinkeby Mainnet 🟣 Polygon 🟡 BSC Arbitrum 🟢 Gnosis Chain

src/components/Dashboard/SafeApps/Card.tsx Outdated Show resolved Hide resolved
src/components/Dashboard/SafeApps/Card.tsx Show resolved Hide resolved
src/components/Dashboard/SafeApps/Card.tsx Outdated Show resolved Hide resolved
src/components/Dashboard/SafeApps/Grid.tsx Outdated Show resolved Hide resolved
@katspaugh katspaugh changed the title feat: Dashboard safeapps feat: Dashboard Safe Apps Mar 29, 2022
@iamacook
Copy link
Member

I'd suggest merging dev into the branch this is based off. It's hard to follow the changes.

<div>
<h2>Safe Apps</h2>
{isLoading ? (
<h2>Loading...</h2>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good enough for now, but we should ideally display a card skeleton here instead. So that the height of the widget doesn't jump.

@github-actions
Copy link

github-actions bot commented Apr 7, 2022

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 2 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

src/routes/Home/index.tsx Outdated Show resolved Hide resolved
src/routes/safe/components/Apps/components/AppFrame.tsx Outdated Show resolved Hide resolved
src/routes/safe/components/Apps/types.ts Outdated Show resolved Hide resolved
src/routes/safe/components/Apps/utils.ts Outdated Show resolved Hide resolved
@@ -75,6 +79,8 @@ export const ReviewConfirm = ({
const nativeCurrency = getNativeCurrency()
const explorerUrl = getExplorerInfo(safeAddress)
const isOwner = useSelector(grantedSelector)
const { remoteSafeApps } = useRemoteSafeApps()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this. The modal takes an app prop that has an id.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That id is not the id of type number that we are looking for. It is something of the type {"url":"https://dapp.daohaus.club/","name":"DAOhaus"}

as SafeApp type is https://github.com/gnosis/safe-react/blob/dda7f419599661d828165c111bbe58506c2ac5ca/src/routes/safe/components/Apps/types.ts#L4-L9

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number id is overwritten

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference in the ids? Can we not just reference the 'new' id instead then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the overwritten id

That id is not the id of type number that we are looking for. It is something of the type {"url":"https://dapp.daohaus.club/","name":"DAOhaus"}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we then pass the right id as a prop? I find it weird that the modal should fetch the list of apps again just to find an id.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have misunderstood your comment @katspaugh !! It makes all sense that we don't fetch the remote apps again so I prop drilled the appId from <AppFrame /> . 👍

const bTimeMultiplier =
b[1].timestamp.valueOf() - a[1].timestamp.valueOf() > 0 ? MORE_RECENT_MULTIPLIER : LESS_RECENT_MULTIPLIER

// The sorting score is a weighted function where the OPEN_C0UNT weights differently than the TX_COUNT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OPEN_C0UNT is spelled with a zero for some reason :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice catch!

let currentTxCount = trackData[app.id]?.txCount
local.setItem(APPS_DASHBOARD, {
...trackData,
[app.id]: { ...trackData[app.id], txCount: currentTxCount ? ++currentTxCount : 1 },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and on line 22, it's a bit hard to read. I would suggest to write it like this:

const currentTxCount = trackData[app.id]?.txCount || 0
...
[app.id]: { ...trackData[app.id], txCount: currentTxCount + 1 }

You don't need to modify the variable, so no need for ++.

{/* Bookmark button */}
<IconBtn onClick={handlePinClick}>{localPinned ? <Bookmark /> : <BookmarkBorder />}</IconBtn>

{/* TODO: Share button */}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No share button?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per discussion:

sharing is not enabled yet by Safe Apps, so no need to tackle it here already.

I will remove the comment.


local.setItem(APPS_DASHBOARD, {
...trackData,
[id]: { ...trackData[id], txCount: currentTxCount + 1 },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it will always have an openCount here as the App has opened?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment

Copy link
Member

@usame-algan usame-algan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work on this! 💯

@DiogoSoaress DiogoSoaress merged commit 33560e1 into epic-dashboard Apr 13, 2022
@DiogoSoaress DiogoSoaress deleted the dashboard-safeapps branch April 13, 2022 09:21
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants