Compare commits

...

4 Commits

Author SHA1 Message Date
Derrick Hammer 6252979d28
refactor: update columns 2024-03-21 16:46:02 -04:00
Derrick Hammer 23cc02b26e
dep: add date-fns 2024-03-21 16:45:20 -04:00
Derrick Hammer ea395df494
refactor: add pinned property for date 2024-03-21 16:45:06 -04:00
Derrick Hammer 7ea4af1346
dep: update portal-sdk 2024-03-21 16:37:25 -04:00
3 changed files with 14 additions and 19 deletions

View File

@ -3,9 +3,7 @@ import {S5Client} from "@lumeweb/s5-js";
import {PROTOCOL_S5} from "@lumeweb/portal-sdk"; import {PROTOCOL_S5} from "@lumeweb/portal-sdk";
import {Multihash} from "@lumeweb/libs5/lib/multihash.js"; import {Multihash} from "@lumeweb/libs5/lib/multihash.js";
import {AxiosProgressEvent} from "axios"; import {AxiosProgressEvent} from "axios";
import {CancelablePromise} from "@lumeweb/s5-js/lib/axios.js"; import {CID, CID_TYPES, METADATA_TYPES, metadataMagicByte, Unpacker} from "@lumeweb/libs5";
import {MetadataResult} from "@lumeweb/s5-js/lib/options/download.js";
import {metadataMagicByte, Unpacker, CID, METADATA_TYPES, CID_TYPES} from "@lumeweb/libs5";
async function getIsManifest(s5: S5Client, hash: string): Promise<boolean | number> { async function getIsManifest(s5: S5Client, hash: string): Promise<boolean | number> {
@ -63,6 +61,7 @@ export interface FileItem {
cid: string; cid: string;
type: string; type: string;
mimeType: string; mimeType: string;
pinned: string;
} }
export const fileProvider: SdkProvider = { export const fileProvider: SdkProvider = {
@ -81,12 +80,14 @@ export const fileProvider: SdkProvider = {
cid: new CID(manifest, mHash, pin.size).toString(), cid: new CID(manifest, mHash, pin.size).toString(),
type: "manifest", type: "manifest",
mimeType: "application/octet-stream", mimeType: "application/octet-stream",
pinned: pin.pinned_at,
}); });
} else { } else {
items.push({ items.push({
cid: new CID(CID_TYPES.RAW, Multihash.fromBase64Url(pin.hash), pin.size).toString(), cid: new CID(CID_TYPES.RAW, Multihash.fromBase64Url(pin.hash), pin.size).toString(),
type: "raw", type: "raw",
mimeType: pin.mime_type, mimeType: pin.mime_type,
pinned: pin.pinned_at,
}); });
} }
} }

View File

@ -4,15 +4,8 @@ import { FileIcon, MoreIcon } from "~/components/icons";
import { Checkbox } from "~/components/ui/checkbox"; import { Checkbox } from "~/components/ui/checkbox";
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "~/components/ui/dropdown-menu"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "~/components/ui/dropdown-menu";
import { cn } from "~/utils"; import { cn } from "~/utils";
import {FileItem} from "~/data/file-provider.js";
// This type is used to define the shape of our data. import {format} from "date-fns/fp";
// You can use a Zod schema here if you want.
export type File = {
name: string;
cid: string;
size: string;
createdOn: string;
};
declare module '@tanstack/table-core' { declare module '@tanstack/table-core' {
interface TableMeta<TData extends RowData> { interface TableMeta<TData extends RowData> {
@ -20,7 +13,7 @@ declare module '@tanstack/table-core' {
} }
} }
export const columns: ColumnDef<File>[] = [ export const columns: ColumnDef<FileItem>[] = [
{ {
id: "select", id: "select",
size: 20, size: 20,
@ -64,12 +57,12 @@ export const columns: ColumnDef<File>[] = [
header: "Size", header: "Size",
}, },
{ {
accessorKey: "createdOn", accessorKey: "pinnedOn",
size: 200, size: 200,
header: "Created On", header: "Pinned On",
cell: ({ row }) => ( cell: ({ row }) => (
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
{row.getValue("createdOn")} {format(row.getValue("pinned")) as unknown as string}
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger className={ <DropdownMenuTrigger className={
cn("hidden group-hover:block data-[state=open]:block", row.getIsSelected() && "block") cn("hidden group-hover:block data-[state=open]:block", row.getIsSelected() && "block")

View File

@ -16,7 +16,7 @@
"@conform-to/react": "^1.0.2", "@conform-to/react": "^1.0.2",
"@conform-to/zod": "^1.0.2", "@conform-to/zod": "^1.0.2",
"@fontsource-variable/manrope": "^5.0.19", "@fontsource-variable/manrope": "^5.0.19",
"@lumeweb/portal-sdk": "0.0.0-20240321203143", "@lumeweb/portal-sdk": "0.0.0-20240321203634",
"@radix-ui/react-avatar": "^1.0.4", "@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4", "@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-dialog": "^1.0.5",
@ -42,6 +42,7 @@
"@visx/visx": "^3.10.2", "@visx/visx": "^3.10.2",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.1.0", "clsx": "^2.1.0",
"date-fns": "^3.6.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"tailwind-merge": "^2.2.1", "tailwind-merge": "^2.2.1",