Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
115fd39
speed-up load time for safe-apps
nicosampler Nov 2, 2020
fac9409
Merge branch 'development' into issue-1282
nicosampler Nov 2, 2020
f03a901
show loading status until all the apps are loaded
nicosampler Nov 3, 2020
89d30af
remove commented code
nicosampler Nov 3, 2020
8e14c48
Merge remote-tracking branch 'origin/development' into issue-1282
nicosampler Nov 6, 2020
8730750
Merge remote-tracking branch 'origin/development' into issue-1282
nicosampler Nov 10, 2020
45c6b95
Add App route
nicosampler Nov 10, 2020
0ac4c03
partial imp (broken)
nicosampler Nov 11, 2020
c16d66f
Add cards for each safe-app
nicosampler Nov 11, 2020
7443571
move logic to AppFrame
nicosampler Nov 11, 2020
1220f6c
add basic skeleton styles
alongoni Nov 11, 2020
8a2412d
Merge branch 'issue-1294' of https://github.com/gnosis/safe-react int…
alongoni Nov 11, 2020
1fbb740
css fixes
nicosampler Nov 11, 2020
fc2d00a
fix image sizes
nicosampler Nov 11, 2020
c160095
Merge branch 'issue-1294' of github.com:gnosis/safe-react into issue-…
nicosampler Nov 11, 2020
da31053
add transition animation to skeleton
alongoni Nov 12, 2020
1562e10
remove duplicated code
alongoni Nov 12, 2020
164d7ce
Modals
nicosampler Nov 12, 2020
3c235c4
Merge branch 'issue-1294' of github.com:gnosis/safe-react into issue-…
nicosampler Nov 12, 2020
510d0a7
refactor skeleton
nicosampler Nov 12, 2020
514f683
Merge branch 'development' into issue-1294
nicosampler Nov 12, 2020
133b987
refactor layout using flexfox
nicosampler Nov 13, 2020
1f00af2
comments
nicosampler Nov 13, 2020
673e920
Merge branch 'issue-1590' into issue-1294
nicosampler Nov 13, 2020
4350492
make content clickable in cards
nicosampler Nov 16, 2020
2e84d1d
cards container as css-grid
nicosampler Nov 16, 2020
1c2a833
remove fixed width for cards
nicosampler Nov 16, 2020
d1f2acf
replace auto by 1fr
nicosampler Nov 16, 2020
49accc9
remove margin for cards
alongoni Nov 16, 2020
1188732
add card component and remove some css
alongoni Nov 16, 2020
fdbcd99
rename buttons
nicosampler Nov 16, 2020
7b2db47
add margin to app list
alongoni Nov 16, 2020
81b93bd
Merge branch 'issue-1294' of github.com:gnosis/safe-react into issue-…
nicosampler Nov 16, 2020
dade47e
refactor useAppList
nicosampler Nov 16, 2020
81284b3
fix disclaimer always flashing
nicosampler Nov 16, 2020
c518f11
fix pointer cursor for Add app icon
nicosampler Nov 16, 2020
5b81c6e
uncoment needed code
nicosampler Nov 16, 2020
00db2e8
Merge branch 'development' into issue-1294
fernandomg Nov 17, 2020
f0f4da4
add styled component keyframe
alongoni Nov 17, 2020
421c7a4
update safe-react-components
nicosampler Nov 17, 2020
2d6fd85
review fixes
nicosampler Nov 17, 2020
1fbb83d
fix margin and card height, icon size
alongoni Nov 17, 2020
19762f1
Merge branch 'issue-1294' of https://github.com/gnosis/safe-react int…
alongoni Nov 17, 2020
a121c17
fix margin in iconImg and app name
alongoni Nov 17, 2020
210358b
fix margins on apps container (breadcrumb area)
alongoni Nov 18, 2020
3613122
remove style comment
alongoni Nov 18, 2020
2937fb4
fix margin on HelpCenter
alongoni Nov 20, 2020
7aa55b4
Merge branch 'development' into issue-1294
nicosampler Nov 20, 2020
497ada5
review changes
nicosampler Nov 24, 2020
3dac823
review changes
nicosampler Nov 24, 2020
60b9ef9
Merge branch 'development' into issue-1294
nicosampler Nov 25, 2020
3dd6d67
Improve featuresEnabled for sidebar and apps page.
nicosampler Nov 25, 2020
8442d2b
Merge branch 'issue-1294' of github.com:gnosis/safe-react into issue-…
nicosampler Nov 25, 2020
5b0f390
Merge branch 'development' into issue-1294
Nov 25, 2020
44b3875
Merge branch 'development' into issue-1294
Nov 26, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
"dependencies": {
"@gnosis.pm/safe-apps-sdk": "https://github.com/gnosis/safe-apps-sdk.git#3f0689f",
"@gnosis.pm/safe-contracts": "1.1.1-dev.2",
"@gnosis.pm/safe-react-components": "https://github.com/gnosis/safe-react-components.git#03ff672d6f73366297986d58631f9582fe2ed4a3",
"@gnosis.pm/safe-react-components": "https://github.com/gnosis/safe-react-components.git#ff29c3c",
"@gnosis.pm/util-contracts": "2.0.6",
"@ledgerhq/hw-transport-node-hid-singleton": "5.30.0",
"@material-ui/core": "4.11.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppLayout/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const HelpContainer = styled.div`
const HelpCenterLink = styled.a`
height: 30px;
width: 166px;
padding: 8px 0 8px 16px;
padding: 6px 0 8px 16px;
margin: 14px 0px;
text-decoration: none;
display: block;
Expand Down
4 changes: 2 additions & 2 deletions src/components/AppLayout/Sidebar/useSidebarItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const useSidebarItems = (): ListItemType[] => {
}

return useMemo((): ListItemType[] => {
if (!matchSafe || !matchSafeWithAddress) {
if (!matchSafe || !matchSafeWithAddress || !featuresEnabled) {
return []
}

Expand Down Expand Up @@ -63,7 +63,7 @@ const useSidebarItems = (): ListItemType[] => {
},
...safeSidebar,
]
}, [matchSafe, matchSafeWithAction, matchSafeWithAddress, safeAppsEnabled])
}, [matchSafe, matchSafeWithAction, matchSafeWithAddress, safeAppsEnabled, featuresEnabled])
}

export { useSidebarItems }
2 changes: 1 addition & 1 deletion src/components/AppLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const SidebarWrapper = styled.aside`
flex-direction: column;
z-index: 1;

padding: 8px;
padding: 8px 8px 0 8px;
background-color: ${({ theme }) => theme.colors.white};
border-right: 2px solid ${({ theme }) => theme.colors.separator};
`
Expand Down
9 changes: 9 additions & 0 deletions src/components/LoaderContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import styled from 'styled-components'

export const LoadingContainer = styled.div`
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
`
11 changes: 7 additions & 4 deletions src/logic/safe/utils/safeVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ export const safeNeedsUpdate = (currentVersion?: string, latestVersion?: string)
export const getCurrentSafeVersion = (gnosisSafeInstance: GnosisSafe): Promise<string> =>
gnosisSafeInstance.methods.VERSION().call()

const checkFeatureEnabledByVersion = (featureConfig: FeatureConfigByVersion, version: string) => {
const checkFeatureEnabledByVersion = (featureConfig: FeatureConfigByVersion, version?: string) => {
if (!version) {
return false
}
return featureConfig.validVersion ? semverSatisfies(version, featureConfig.validVersion) : true
}

export const enabledFeatures = (version?: string): FEATURES[] => {
return FEATURES_BY_VERSION.reduce((acc: FEATURES[], feature: Feature) => {
if (isFeatureEnabled(feature.name) && version && checkFeatureEnabledByVersion(feature, version)) {
return FEATURES_BY_VERSION.reduce((acc, feature: Feature) => {
if (isFeatureEnabled(feature.name) && checkFeatureEnabledByVersion(feature, version)) {
acc.push(feature.name)
}
return acc
}, [])
}, [] as FEATURES[])
}

interface SafeVersionInfo {
Expand Down
27 changes: 0 additions & 27 deletions src/routes/safe/components/Apps/AddAppForm/SubmitButtonStatus.tsx

This file was deleted.

31 changes: 31 additions & 0 deletions src/routes/safe/components/Apps/assets/addApp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Button, Divider } from '@gnosis.pm/safe-react-components'
import React, { ReactElement, useMemo } from 'react'
import { useFormState } from 'react-final-form'
import styled from 'styled-components'

import GnoButton from 'src/components/layout/Button'
import { SafeApp } from 'src/routes/safe/components/Apps/types.d'
import { isAppManifestValid } from 'src/routes/safe/components/Apps/utils'

const StyledDivider = styled(Divider)`
margin: 16px -24px;
`

const ButtonsContainer = styled.div`
display: flex;
justify-content: space-between;
`

interface Props {
appInfo: SafeApp
onCancel: () => void
}

const FormButtons = ({ appInfo, onCancel }: Props): ReactElement => {
const { valid, validating, visited } = useFormState({
subscription: { valid: true, validating: true, visited: true },
})

const isSubmitDisabled = useMemo(() => {
// if non visited, fields were not evaluated yet. Then, the default value is considered invalid
const fieldsVisited = visited?.agreementAccepted && visited?.appUrl

return validating || !valid || !fieldsVisited || !isAppManifestValid(appInfo)
}, [validating, valid, visited, appInfo])

return (
<>
<StyledDivider />
<ButtonsContainer>
<Button size="md" onClick={onCancel} color="secondary">
Cancel
</Button>
<GnoButton color="primary" variant="contained" type="submit" disabled={isSubmitDisabled}>
Add
</GnoButton>
</ButtonsContainer>
</>
)
}

export default FormButtons
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { Text, TextField } from '@gnosis.pm/safe-react-components'
import React from 'react'
import { TextField } from '@gnosis.pm/safe-react-components'
import React, { useState, ReactElement } from 'react'
import styled from 'styled-components'

import AppAgreement from './AppAgreement'
import AppUrl, { AppInfoUpdater, appUrlResolver } from './AppUrl'
import SubmitButtonStatus from './SubmitButtonStatus'

import { SafeApp } from 'src/routes/safe/components/Apps/types.d'
import GnoForm from 'src/components/forms/GnoForm'
import Img from 'src/components/layout/Img'
import appsIconSvg from 'src/routes/safe/components/Transactions/TxsTable/TxType/assets/appsIcon.svg'

const StyledText = styled(Text)`
margin-bottom: 19px;
`
import AppAgreement from './AppAgreement'
import AppUrl, { AppInfoUpdater, appUrlResolver } from './AppUrl'
import FormButtons from './FormButtons'
import { APPS_STORAGE_KEY, getEmptySafeApp } from 'src/routes/safe/components/Apps/utils'
import { saveToStorage } from 'src/utils/storage'
import { SAFELIST_ADDRESS } from 'src/routes/routes'
import { useHistory, useRouteMatch } from 'react-router-dom'

const FORM_ID = 'add-apps-form'

const StyledTextFileAppName = styled(TextField)`
&& {
Expand All @@ -39,38 +40,34 @@ const INITIAL_VALUES: AddAppFormValues = {
agreementAccepted: false,
}

const APP_INFO: SafeApp = {
id: '',
url: '',
name: '',
iconUrl: appsIconSvg,
error: false,
description: '',
}
const APP_INFO = getEmptySafeApp()

interface AddAppProps {
appList: SafeApp[]
closeModal: () => void
formId: string
onAppAdded: (app: SafeApp) => void
setIsSubmitDisabled: (disabled: boolean) => void
}

const AddApp = ({ appList, closeModal, formId, onAppAdded, setIsSubmitDisabled }: AddAppProps): React.ReactElement => {
const [appInfo, setAppInfo] = React.useState<SafeApp>(APP_INFO)
const AddApp = ({ appList, closeModal }: AddAppProps): ReactElement => {
const [appInfo, setAppInfo] = useState<SafeApp>(APP_INFO)
const history = useHistory()
const matchSafeWithAddress = useRouteMatch<{ safeAddress: string }>({ path: `${SAFELIST_ADDRESS}/:safeAddress` })

const handleSubmit = () => {
closeModal()
onAppAdded(appInfo)
const newAppList = [
{ url: appInfo.url, disabled: false },
...appList.map(({ url, disabled }) => ({ url, disabled })),
]
saveToStorage(APPS_STORAGE_KEY, newAppList)
const goToApp = `${matchSafeWithAddress?.url}/apps?appUrl=${encodeURI(appInfo.url)}`
history.push(goToApp)
}
Comment on lines 55 to 63
Copy link
Contributor

Choose a reason for hiding this comment

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

This only updates the stored app list and not app's state, is it intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, what do you mean by app's state?

Copy link
Contributor

Choose a reason for hiding this comment

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

we hold an apps list in state inside useAppList hook

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh, I see what you mean. No, it's not needed anymore, because the useAppList is only used in /apps URL, when we add a new app, we redirect it to /apps/new_app_url.
then, if the user goes back to /apps it will load the just added_app because it's already in the storage.


return (
<GnoForm decorators={[appUrlResolver]} initialValues={INITIAL_VALUES} onSubmit={handleSubmit} testId={formId}>
<GnoForm decorators={[appUrlResolver]} initialValues={INITIAL_VALUES} onSubmit={handleSubmit} testId={FORM_ID}>
{() => (
<>
<StyledText size="xl">Add custom app</StyledText>

<AppUrl appList={appList} />

{/* Fetch app from url and return a SafeApp */}
<AppInfoUpdater onAppInfo={setAppInfo} />

Expand All @@ -81,7 +78,7 @@ const AddApp = ({ appList, closeModal, formId, onAppAdded, setIsSubmitDisabled }

<AppAgreement />

<SubmitButtonStatus onSubmitButtonStatusChange={setIsSubmitDisabled} appInfo={appInfo} />
<FormButtons appInfo={appInfo} onCancel={closeModal} />
</>
)}
</GnoForm>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react'

import AppCard from './index'

import AddAppIcon from 'src/routes/safe/components/Apps/assets/addApp.svg'

export default {
title: 'Apps/AppCard',
component: AppCard,
}

export const Loading = (): React.ReactElement => <AppCard isLoading />

export const AddCustomApp = (): React.ReactElement => (
<AppCard iconUrl={AddAppIcon} onClick={console.log} buttonText="Add custom app" />
)

export const LoadedApp = (): React.ReactElement => (
<AppCard
iconUrl="https://cryptologos.cc/logos/versions/gnosis-gno-gno-logo-circle.svg?v=007"
name="Gnosis"
description="Gnosis safe app"
onClick={console.log}
/>
)
Loading