Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
c02cd333
Commit
c02cd333
authored
Mar 15, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace type
parent
17dced86
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
13 deletions
+18
-13
marketplace.ts
types/client/marketplace.ts
+4
-1
MarketplaceAppModal.pw.tsx
ui/marketplace/MarketplaceAppModal.pw.tsx
+3
-1
MarketplaceAppModal.tsx
ui/marketplace/MarketplaceAppModal.tsx
+2
-2
MarketplaceListWithScores.tsx
ui/marketplace/MarketplaceListWithScores.tsx
+2
-2
useMarketplaceApps.tsx
ui/marketplace/useMarketplaceApps.tsx
+7
-7
No files found.
types/client/marketplace.ts
View file @
c02cd333
...
...
@@ -22,7 +22,10 @@ export type MarketplaceAppOverview = MarketplaceAppPreview & MarketplaceAppSocia
author
:
string
;
description
:
string
;
site
?:
string
;
securityReport
?:
any
;
// eslint-disable-line @typescript-eslint/no-explicit-any
}
export
type
MarketplaceAppWithSecurityReport
=
MarketplaceAppOverview
&
{
securityReport
:
any
;
// eslint-disable-line @typescript-eslint/no-explicit-any
}
export
enum
MarketplaceCategory
{
...
...
ui/marketplace/MarketplaceAppModal.pw.tsx
View file @
c02cd333
import
{
test
,
expect
,
devices
}
from
'
@playwright/experimental-ct-react
'
;
import
React
from
'
react
'
;
import
type
{
MarketplaceAppWithSecurityReport
}
from
'
types/client/marketplace
'
;
import
{
apps
as
appsMock
}
from
'
mocks/apps/apps
'
;
import
TestApp
from
'
playwright/TestApp
'
;
...
...
@@ -10,7 +12,7 @@ const props = {
onClose
:
()
=>
{},
onFavoriteClick
:
()
=>
{},
showContractList
:
()
=>
{},
data
:
appsMock
[
0
],
data
:
appsMock
[
0
]
as
MarketplaceAppWithSecurityReport
,
isFavorite
:
false
,
};
...
...
ui/marketplace/MarketplaceAppModal.tsx
View file @
c02cd333
...
...
@@ -4,7 +4,7 @@ import {
}
from
'
@chakra-ui/react
'
;
import
React
,
{
useCallback
}
from
'
react
'
;
import
type
{
MarketplaceApp
Overview
}
from
'
types/client/marketplace
'
;
import
type
{
MarketplaceApp
WithSecurityReport
}
from
'
types/client/marketplace
'
;
import
{
ContractListTypes
}
from
'
types/client/marketplace
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
...
...
@@ -20,7 +20,7 @@ type Props = {
onClose
:
()
=>
void
;
isFavorite
:
boolean
;
onFavoriteClick
:
(
id
:
string
,
isFavorite
:
boolean
)
=>
void
;
data
:
MarketplaceApp
Overview
;
data
:
MarketplaceApp
WithSecurityReport
;
showContractList
:
(
id
:
string
,
type
:
ContractListTypes
)
=>
void
;
}
...
...
ui/marketplace/MarketplaceListWithScores.tsx
View file @
c02cd333
...
...
@@ -2,7 +2,7 @@ import { Hide, Show } from '@chakra-ui/react';
import
React
from
'
react
'
;
import
type
{
MouseEvent
}
from
'
react
'
;
import
type
{
MarketplaceApp
Overview
,
ContractListTypes
}
from
'
types/client/marketplace
'
;
import
type
{
MarketplaceApp
WithSecurityReport
,
ContractListTypes
}
from
'
types/client/marketplace
'
;
import
{
MarketplaceCategory
}
from
'
types/client/marketplace
'
;
import
{
apos
}
from
'
lib/html-entities
'
;
...
...
@@ -14,7 +14,7 @@ import ListItem from './MarketplaceListWithScores/ListItem';
import
Table
from
'
./MarketplaceListWithScores/Table
'
;
interface
Props
{
apps
:
Array
<
MarketplaceApp
Overview
>
;
apps
:
Array
<
MarketplaceApp
WithSecurityReport
>
;
showAppInfo
:
(
id
:
string
)
=>
void
;
favoriteApps
:
Array
<
string
>
;
onFavoriteClick
:
(
id
:
string
,
isFavorite
:
boolean
)
=>
void
;
...
...
ui/marketplace/useMarketplaceApps.tsx
View file @
c02cd333
import
{
useQuery
}
from
'
@tanstack/react-query
'
;
import
React
from
'
react
'
;
import
type
{
MarketplaceApp
Overview
}
from
'
types/client/marketplace
'
;
import
type
{
MarketplaceApp
WithSecurityReport
}
from
'
types/client/marketplace
'
;
import
{
MarketplaceCategory
}
from
'
types/client/marketplace
'
;
import
config
from
'
configs/app
'
;
...
...
@@ -14,17 +14,17 @@ import useSecurityReports from './useSecurityReports';
const
feature
=
config
.
features
.
marketplace
;
function
isAppNameMatches
(
q
:
string
,
app
:
MarketplaceApp
Overview
)
{
function
isAppNameMatches
(
q
:
string
,
app
:
MarketplaceApp
WithSecurityReport
)
{
return
app
.
title
.
toLowerCase
().
includes
(
q
.
toLowerCase
());
}
function
isAppCategoryMatches
(
category
:
string
,
app
:
MarketplaceApp
Overview
,
favoriteApps
:
Array
<
string
>
)
{
function
isAppCategoryMatches
(
category
:
string
,
app
:
MarketplaceApp
WithSecurityReport
,
favoriteApps
:
Array
<
string
>
)
{
return
category
===
MarketplaceCategory
.
ALL
||
(
category
===
MarketplaceCategory
.
FAVORITES
&&
favoriteApps
.
includes
(
app
.
id
))
||
app
.
categories
.
includes
(
category
);
}
function
sortApps
(
apps
:
Array
<
MarketplaceApp
Overview
>
,
favoriteApps
:
Array
<
string
>
)
{
function
sortApps
(
apps
:
Array
<
MarketplaceApp
WithSecurityReport
>
,
favoriteApps
:
Array
<
string
>
)
{
return
apps
.
sort
((
a
,
b
)
=>
{
const
priorityA
=
a
.
priority
||
0
;
const
priorityB
=
b
.
priority
||
0
;
...
...
@@ -66,18 +66,18 @@ export default function useMarketplaceApps(
lastFavoriteAppsRef
.
current
=
favoriteApps
;
},
[
selectedCategoryId
,
isFavoriteAppsLoaded
]);
// eslint-disable-line react-hooks/exhaustive-deps
const
{
isPlaceholderData
,
isError
,
error
,
data
}
=
useQuery
<
unknown
,
ResourceError
<
unknown
>
,
Array
<
MarketplaceApp
Overview
>>
({
const
{
isPlaceholderData
,
isError
,
error
,
data
}
=
useQuery
<
unknown
,
ResourceError
<
unknown
>
,
Array
<
MarketplaceApp
WithSecurityReport
>>
({
queryKey
:
[
'
marketplace-dapps
'
],
queryFn
:
async
()
=>
{
if
(
!
feature
.
isEnabled
)
{
return
[];
}
else
if
(
'
configUrl
'
in
feature
)
{
return
fetch
<
Array
<
MarketplaceApp
Overview
>
,
unknown
>
(
feature
.
configUrl
,
undefined
,
{
resource
:
'
marketplace-dapps
'
});
return
fetch
<
Array
<
MarketplaceApp
WithSecurityReport
>
,
unknown
>
(
feature
.
configUrl
,
undefined
,
{
resource
:
'
marketplace-dapps
'
});
}
else
{
return
apiFetch
(
'
marketplace_dapps
'
,
{
pathParams
:
{
chainId
:
config
.
chain
.
id
}
});
}
},
select
:
(
data
)
=>
sortApps
(
data
as
Array
<
MarketplaceApp
Overview
>
,
lastFavoriteAppsRef
.
current
),
select
:
(
data
)
=>
sortApps
(
data
as
Array
<
MarketplaceApp
WithSecurityReport
>
,
lastFavoriteAppsRef
.
current
),
placeholderData
:
feature
.
isEnabled
?
Array
(
9
).
fill
(
MARKETPLACE_APP
)
:
undefined
,
staleTime
:
Infinity
,
enabled
:
feature
.
isEnabled
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment