Skip to content

Commit

Permalink
Merge branch 'develop' into sc-platform/issue-3087-display-object-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriyr authored Nov 6, 2024
2 parents 267ca2a + 8c1255d commit afde423
Show file tree
Hide file tree
Showing 43 changed files with 611 additions and 352 deletions.
12 changes: 0 additions & 12 deletions .changeset/seven-falcons-return.md

This file was deleted.

32 changes: 16 additions & 16 deletions .github/workflows/release_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ jobs:
type=raw,value={{sha}},enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value={{tag}},enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-alpha.*\d*,group=0,value=alphanet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-beta.*\d*,group=0,value=devnet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-rc.*\d*,group=0,value=testnet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+$,group=0,value=mainnet,enable=${{ github.event_name == 'release' }}
type=raw,value=alphanet,enable=${{ github.event_name == 'release' && contains(github.ref, '-alpha') }}
type=raw,value=devnet,enable=${{ github.event_name == 'release' && contains(github.ref, '-beta') }}
type=raw,value=testnet,enable=${{ github.event_name == 'release' && contains(github.ref, '-rc') }}
type=raw,value=mainnet,enable=${{ github.event_name == 'release' && !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') && !contains(github.ref, '-rc') }}
- name: Login to Docker Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pin@v3
Expand Down Expand Up @@ -114,10 +114,10 @@ jobs:
type=raw,value={{sha}},enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value={{tag}},enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-alpha.*\d*,group=0,value=alphanet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-beta.*\d*,group=0,value=devnet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-rc.*\d*,group=0,value=testnet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+$,group=0,value=mainnet,enable=${{ github.event_name == 'release' }}
type=raw,value=alphanet,enable=${{ github.event_name == 'release' && contains(github.ref, '-alpha') }}
type=raw,value=devnet,enable=${{ github.event_name == 'release' && contains(github.ref, '-beta') }}
type=raw,value=testnet,enable=${{ github.event_name == 'release' && contains(github.ref, '-rc') }}
type=raw,value=mainnet,enable=${{ github.event_name == 'release' && !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') && !contains(github.ref, '-rc') }}
- name: Login to Docker Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pin@v3
Expand Down Expand Up @@ -173,10 +173,10 @@ jobs:
type=raw,value={{sha}},enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value={{tag}},enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-alpha.*\d*,group=0,value=alphanet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-beta.*\d*,group=0,value=devnet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-rc.*\d*,group=0,value=testnet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+$,group=0,value=mainnet,enable=${{ github.event_name == 'release' }}
type=raw,value=alphanet,enable=${{ github.event_name == 'release' && contains(github.ref, '-alpha') }}
type=raw,value=devnet,enable=${{ github.event_name == 'release' && contains(github.ref, '-beta') }}
type=raw,value=testnet,enable=${{ github.event_name == 'release' && contains(github.ref, '-rc') }}
type=raw,value=mainnet,enable=${{ github.event_name == 'release' && !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') && !contains(github.ref, '-rc') }}
- name: Login to Docker Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pin@v3
Expand Down Expand Up @@ -232,10 +232,10 @@ jobs:
type=raw,value={{sha}},enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' }}
type=raw,value={{tag}},enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-alpha.*\d*,group=0,value=alphanet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-beta.*\d*,group=0,value=devnet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+-rc.*\d*,group=0,value=testnet,enable=${{ github.event_name == 'release' }}
type=match,pattern=v\d+\.\d+\.\d+$,group=0,value=mainnet,enable=${{ github.event_name == 'release' }}
type=raw,value=alphanet,enable=${{ github.event_name == 'release' && contains(github.ref, '-alpha') }}
type=raw,value=devnet,enable=${{ github.event_name == 'release' && contains(github.ref, '-beta') }}
type=raw,value=testnet,enable=${{ github.event_name == 'release' && contains(github.ref, '-rc') }}
type=raw,value=mainnet,enable=${{ github.event_name == 'release' && !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') && !contains(github.ref, '-rc') }}
- name: Login to Docker Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # pin@v3
Expand Down
45 changes: 45 additions & 0 deletions apps/wallet-dashboard/app/(protected)/assets/[objectId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

'use client';

import React, { useCallback } from 'react';
import { useParams } from 'next/navigation';
import { AssetCard, Button, RouteLink, SendAssetPopup } from '@/components';
import { isAssetTransferable, useGetObject } from '@iota/core';
import { usePopups } from '@/hooks';
import { useCurrentAccount } from '@iota/dapp-kit';
import { ASSETS_ROUTE } from '@/lib/constants/routes.constants';

const VisualAssetDetailPage = () => {
const params = useParams();
const objectId = params.objectId as string;
const { data: asset } = useGetObject(objectId);
const activeAccount = useCurrentAccount();

const { openPopup, closePopup } = usePopups();

const showSendAssetPopup = useCallback(() => {
if (asset?.data) {
openPopup(<SendAssetPopup asset={asset?.data} onClose={closePopup} />);
}
}, [asset, openPopup, closePopup]);

const assetIsTransferable = asset?.data ? isAssetTransferable(asset?.data) : false;

return (
<div className="flex h-full w-full flex-col space-y-4 px-40">
<RouteLink path={ASSETS_ROUTE.path} title="Back" />
{asset?.data ? (
<AssetCard key={asset.data.objectId} asset={asset.data} />
) : (
<div className="flex justify-center p-20">Asset not found</div>
)}
{assetIsTransferable && activeAccount ? (
<Button onClick={showSendAssetPopup}>Send Asset</Button>
) : null}
</div>
);
};

export default VisualAssetDetailPage;

This file was deleted.

27 changes: 0 additions & 27 deletions apps/wallet-dashboard/app/(protected)/assets/layout.tsx

This file was deleted.

97 changes: 91 additions & 6 deletions apps/wallet-dashboard/app/(protected)/assets/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,97 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

function AssetsDashboardPage(): JSX.Element {
'use client';

import { AssetCard, VirtualList } from '@/components';
import { ASSETS_ROUTE } from '@/lib/constants/routes.constants';
import { Panel, Title, Chip } from '@iota/apps-ui-kit';
import { hasDisplayData, useGetOwnedObjects } from '@iota/core';
import { useCurrentAccount } from '@iota/dapp-kit';
import { IotaObjectData } from '@iota/iota-sdk/client';
import { useState } from 'react';
import { AssetCategory } from '@/lib/enums';
import Link from 'next/link';

const ASSET_CATEGORIES: { label: string; value: AssetCategory }[] = [
{
label: 'Visual',
value: AssetCategory.Visual,
},
{
label: 'Other',
value: AssetCategory.Other,
},
];

export default function AssetsDashboardPage(): React.JSX.Element {
const [selectedCategory, setSelectedCategory] = useState<AssetCategory>(AssetCategory.Visual);

const account = useCurrentAccount();
const {
data: ownedObjects,
fetchNextPage,
hasNextPage,
isFetchingNextPage,
} = useGetOwnedObjects(account?.address);

const [visual, nonVisual] = (() => {
const visual: IotaObjectData[] = [];
const nonVisual: IotaObjectData[] = [];

ownedObjects?.pages
.flatMap((page) => page.data)
.filter((asset) => asset.data && asset.data.objectId)
.forEach((asset) => {
if (asset.data) {
if (hasDisplayData(asset)) {
visual.push(asset.data);
} else {
nonVisual.push(asset.data);
}
}
});

return [visual, nonVisual];
})();

const categoryToAsset: Record<AssetCategory, IotaObjectData[]> = {
[AssetCategory.Visual]: visual,
[AssetCategory.Other]: nonVisual,
};

const assetList = categoryToAsset[selectedCategory];

return (
<div className="flex items-center justify-center pt-12">
<h1>ASSETS</h1>
</div>
<Panel>
<Title title="Assets" />
<div className="px-lg">
<div className="flex flex-row items-center justify-start gap-xs py-xs">
{ASSET_CATEGORIES.map((tab) => (
<Chip
key={tab.label}
label={tab.label}
onClick={() => setSelectedCategory(tab.value)}
selected={selectedCategory === tab.value}
/>
))}
</div>

<div className="max-h-[600px] overflow-auto py-sm">
<VirtualList
items={assetList}
hasNextPage={hasNextPage}
isFetchingNextPage={isFetchingNextPage}
fetchNextPage={fetchNextPage}
estimateSize={() => 180}
render={(asset) => (
<Link href={ASSETS_ROUTE.path + `/${asset.objectId}`}>
<AssetCard asset={asset} />
</Link>
)}
/>
</div>
</div>
</Panel>
);
}

export default AssetsDashboardPage;

This file was deleted.

4 changes: 2 additions & 2 deletions apps/wallet-dashboard/app/(protected)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ function DashboardLayout({ children }: PropsWithChildren): JSX.Element {
<Sidebar />
</div>

<div className="container relative min-h-screen">
<div className="container relative flex min-h-screen flex-col">
<div className="sticky top-0">
<TopNav />
</div>
<div>{children}</div>
<div className="flex-1 py-md--rs">{children}</div>
</div>

<div className="fixed bottom-5 right-5">
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet-dashboard/components/VirtualList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function VirtualList<T>({
]);

return (
<div className="relative h-[50vh] w-full overflow-auto" ref={containerRef}>
<div className="relative h-full w-full" ref={containerRef}>
<div
style={{
height: `${virtualizer.getTotalSize()}px`,
Expand Down
7 changes: 7 additions & 0 deletions apps/wallet-dashboard/lib/enums/assetCategory.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

export enum AssetCategory {
Visual = 'Visual',
Other = 'Other',
}
1 change: 1 addition & 0 deletions apps/wallet-dashboard/lib/enums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
// SPDX-License-Identifier: Apache-2.0

export * from './protectedRouteTitle.enum';
export * from './assetCategory.enum';
Loading

0 comments on commit afde423

Please sign in to comment.