-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add AppsPlayGround component and refactor imports for consi…
…stency
- Loading branch information
1 parent
02952d4
commit 1ec6361
Showing
13 changed files
with
92 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export * from './PkgView'; | ||
export * from './TokenView'; |
75 changes: 75 additions & 0 deletions
75
apps/wallet/src/ui/app/components/iota-apps/AppsPlayGround.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// Modifications Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { useAppSelector } from '_hooks'; | ||
import { Feature } from '@iota/core'; | ||
import { prepareLinkToCompare } from '_src/shared/utils'; | ||
import { useFeature } from '@growthbook/growthbook-react'; | ||
import { useMemo } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { permissionsSelectors } from '../../redux/slices/permissions'; | ||
import { AppsPageBanner } from './Banner'; | ||
import { IotaApp, type DAppEntry } from './IotaApp'; | ||
import { IotaAppEmpty } from './IotaAppEmpty'; | ||
import { InfoBox, InfoBoxStyle, InfoBoxType, Header } from '@iota/apps-ui-kit'; | ||
import { Info } from '@iota/ui-icons'; | ||
|
||
export function AppsPlayGround() { | ||
const ecosystemApps = useFeature<DAppEntry[]>(Feature.WalletDapps).value; | ||
const { tagName } = useParams(); | ||
|
||
const filteredEcosystemApps = useMemo(() => { | ||
if (!ecosystemApps) { | ||
return []; | ||
} else if (tagName) { | ||
return ecosystemApps.filter((app) => app.tags.includes(tagName)); | ||
} | ||
return ecosystemApps; | ||
}, [ecosystemApps, tagName]); | ||
|
||
const allPermissions = useAppSelector(permissionsSelectors.selectAll); | ||
const linkToPermissionID = useMemo(() => { | ||
const map = new Map<string, string>(); | ||
for (const aPermission of allPermissions) { | ||
map.set(prepareLinkToCompare(aPermission.origin), aPermission.id); | ||
if (aPermission.pagelink) { | ||
map.set(prepareLinkToCompare(aPermission.pagelink), aPermission.id); | ||
} | ||
} | ||
return map; | ||
}, [allPermissions]); | ||
|
||
return ( | ||
<> | ||
<Header titleCentered title="IOTA Apps" /> | ||
<AppsPageBanner /> | ||
|
||
{filteredEcosystemApps?.length ? ( | ||
<InfoBox | ||
type={InfoBoxType.Default} | ||
icon={<Info />} | ||
style={InfoBoxStyle.Elevated} | ||
supportingText="Apps below are actively curated but do not indicate any endorsement or | ||
relationship with IOTA Wallet. Please DYOR." | ||
/> | ||
) : null} | ||
|
||
{filteredEcosystemApps?.length ? ( | ||
<div className="mt-md flex flex-col gap-sm"> | ||
{filteredEcosystemApps.map((app) => ( | ||
<IotaApp | ||
key={app.link} | ||
{...app} | ||
permissionID={linkToPermissionID.get(prepareLinkToCompare(app.link))} | ||
displayType="full" | ||
openAppSite | ||
/> | ||
))} | ||
</div> | ||
) : ( | ||
<IotaAppEmpty displayType="full" /> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,5 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// Modifications Copyright (c) 2024 IOTA Stiftung | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { useAppSelector } from '_hooks'; | ||
import { Feature } from '@iota/core'; | ||
import { prepareLinkToCompare } from '_src/shared/utils'; | ||
import { useFeature } from '@growthbook/growthbook-react'; | ||
import { useMemo } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { permissionsSelectors } from '../../redux/slices/permissions'; | ||
import { AppsPageBanner } from './Banner'; | ||
import { IotaApp, type DAppEntry } from './IotaApp'; | ||
import { IotaAppEmpty } from './IotaAppEmpty'; | ||
import { InfoBox, InfoBoxStyle, InfoBoxType, Header } from '@iota/apps-ui-kit'; | ||
import { Info } from '@iota/ui-icons'; | ||
|
||
export function AppsPlayGround() { | ||
const ecosystemApps = useFeature<DAppEntry[]>(Feature.WalletDapps).value; | ||
const { tagName } = useParams(); | ||
|
||
const filteredEcosystemApps = useMemo(() => { | ||
if (!ecosystemApps) { | ||
return []; | ||
} else if (tagName) { | ||
return ecosystemApps.filter((app) => app.tags.includes(tagName)); | ||
} | ||
return ecosystemApps; | ||
}, [ecosystemApps, tagName]); | ||
|
||
const allPermissions = useAppSelector(permissionsSelectors.selectAll); | ||
const linkToPermissionID = useMemo(() => { | ||
const map = new Map<string, string>(); | ||
for (const aPermission of allPermissions) { | ||
map.set(prepareLinkToCompare(aPermission.origin), aPermission.id); | ||
if (aPermission.pagelink) { | ||
map.set(prepareLinkToCompare(aPermission.pagelink), aPermission.id); | ||
} | ||
} | ||
return map; | ||
}, [allPermissions]); | ||
|
||
return ( | ||
<> | ||
<Header titleCentered title="IOTA Apps" /> | ||
<AppsPageBanner /> | ||
|
||
{filteredEcosystemApps?.length ? ( | ||
<InfoBox | ||
type={InfoBoxType.Default} | ||
icon={<Info />} | ||
style={InfoBoxStyle.Elevated} | ||
supportingText="Apps below are actively curated but do not indicate any endorsement or | ||
relationship with IOTA Wallet. Please DYOR." | ||
/> | ||
) : null} | ||
|
||
{filteredEcosystemApps?.length ? ( | ||
<div className="mt-md flex flex-col gap-sm"> | ||
{filteredEcosystemApps.map((app) => ( | ||
<IotaApp | ||
key={app.link} | ||
{...app} | ||
permissionID={linkToPermissionID.get(prepareLinkToCompare(app.link))} | ||
displayType="full" | ||
openAppSite | ||
/> | ||
))} | ||
</div> | ||
) : ( | ||
<IotaAppEmpty displayType="full" /> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export * from './AppsPlayGround'; | ||
export * from './ConnectedAppsCard'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters