Skip to content

Commit

Permalink
Merge branch 'main' of github.com:safe-global/safe-wallet-web into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Dec 15, 2023
2 parents cbc431d + 2b36a31 commit 60b670f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "safe-wallet-web",
"homepage": "https://github.com/safe-global/safe-wallet-web",
"license": "GPL-3.0",
"version": "1.25.0",
"version": "1.25.1",
"type": "module",
"scripts": {
"dev": "next dev",
Expand Down
11 changes: 9 additions & 2 deletions src/components/sidebar/SidebarNavigation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { type ReactElement } from 'react'
import React, { useMemo, type ReactElement } from 'react'
import { useRouter } from 'next/router'
import ListItem from '@mui/material/ListItem'
import { ImplementationVersionState } from '@safe-global/safe-gateway-typescript-sdk'
Expand All @@ -14,6 +14,8 @@ import { type NavItem, navItems } from './config'
import useSafeInfo from '@/hooks/useSafeInfo'
import { AppRoutes } from '@/config/routes'
import { useQueuedTxsLength } from '@/hooks/useTxQueue'
import { useHasFeature } from '@/hooks/useChains'
import { FEATURES } from '@/utils/chains'

const getSubdirectory = (pathname: string): string => {
return pathname.split('/')[1]
Expand All @@ -24,6 +26,11 @@ const Navigation = (): ReactElement => {
const { safe } = useSafeInfo()
const currentSubdirectory = getSubdirectory(router.pathname)
const queueSize = useQueuedTxsLength()
const isSafeAppsEnabled = useHasFeature(FEATURES.SAFE_APPS)

const enabledNavItems = useMemo(() => {
return isSafeAppsEnabled ? navItems : navItems.filter((item) => item.href !== AppRoutes.apps.index)
}, [isSafeAppsEnabled])

const getBadge = (item: NavItem) => {
// Indicate whether the current Safe needs an upgrade
Expand All @@ -49,7 +56,7 @@ const Navigation = (): ReactElement => {

return (
<SidebarList>
{navItems.map((item) => {
{enabledNavItems.map((item) => {
const isSelected = currentSubdirectory === getSubdirectory(item.href)

return (
Expand Down
5 changes: 5 additions & 0 deletions src/pages/apps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import SafeAppList from '@/components/safe-apps/SafeAppList'
import { AppRoutes } from '@/config/routes'
import useSafeAppsFilters from '@/hooks/safe-apps/useSafeAppsFilters'
import SafeAppsFilters from '@/components/safe-apps/SafeAppsFilters'
import { useHasFeature } from '@/hooks/useChains'
import { FEATURES } from '@/utils/chains'

const SafeApps: NextPage = () => {
const router = useRouter()
const { remoteSafeApps, remoteSafeAppsLoading, pinnedSafeApps, pinnedSafeAppIds, togglePin } = useSafeApps()
const { filteredApps, query, setQuery, setSelectedCategories, setOptimizedWithBatchFilter, selectedCategories } =
useSafeAppsFilters(remoteSafeApps)
const isFiltered = filteredApps.length !== remoteSafeApps.length
const isSafeAppsEnabled = useHasFeature(FEATURES.SAFE_APPS)

const nonPinnedApps = useMemo(
() => remoteSafeApps.filter((app) => !pinnedSafeAppIds.has(app.id)),
Expand All @@ -35,6 +38,8 @@ const SafeApps: NextPage = () => {
}
}, [router])

if (!isSafeAppsEnabled) return <></>

return (
<>
<Head>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/apps/open.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import useChainId from '@/hooks/useChainId'
import { AppRoutes } from '@/config/routes'
import { getOrigin } from '@/components/safe-apps/utils'
import { WalletConnectContext } from '@/services/walletconnect/WalletConnectContext'
import { useHasFeature } from '@/hooks/useChains'
import { FEATURES } from '@/utils/chains'

// TODO: Remove this once we properly deprecate the WC app
const WC_SAFE_APP = /wallet-connect/
Expand All @@ -25,6 +27,7 @@ const SafeApps: NextPage = () => {
const router = useRouter()
const appUrl = useSafeAppUrl()
const { safeApp, isLoading } = useSafeAppFromManifest(appUrl || '', chainId)
const isSafeAppsEnabled = useHasFeature(FEATURES.SAFE_APPS)

const { remoteSafeApps, remoteSafeAppsLoading } = useSafeApps()

Expand Down Expand Up @@ -56,7 +59,7 @@ const SafeApps: NextPage = () => {
}, [router])

// appUrl is required to be present
if (!appUrl || !router.isReady) return null
if (!isSafeAppsEnabled || !appUrl || !router.isReady) return null

if (WC_SAFE_APP.test(appUrl)) {
setOpen(true)
Expand Down
2 changes: 2 additions & 0 deletions src/tests/pages/apps.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import AppsPage from '@/pages/apps'
import CustomSafeAppsPage from '@/pages/apps/custom'
import * as safeAppsService from '@/services/safe-apps/manifest'
import { LS_NAMESPACE } from '@/config/constants'
import * as chainHooks from '@/hooks/useChains'

jest.mock('@safe-global/safe-gateway-typescript-sdk', () => ({
...jest.requireActual('@safe-global/safe-gateway-typescript-sdk'),
Expand All @@ -33,6 +34,7 @@ describe('AppsPage', () => {
beforeEach(() => {
jest.restoreAllMocks()
window.localStorage.clear()
jest.spyOn(chainHooks, 'useHasFeature').mockImplementation(() => true)
})

describe('Safe Apps List Page', () => {
Expand Down

0 comments on commit 60b670f

Please sign in to comment.