Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to open IPFS folder #56

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 87 additions & 88 deletions src/renderer/views/PinsView/PinsViewComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
// Path: src\renderer\views\PinsView\PinsViewComponent.tsx
import React from 'react';
import React from 'react'
import { Button, Col, Dropdown, Row, Table } from 'react-bootstrap'
import { CustomPinsViewToggle } from './CustomToggle'
import { CustomPinsViewMenu } from './CustomMenu'
import DateTime from 'date-and-time'
export interface PinsViewProps {
pinRows: React.ReactNode;
showExplorer: boolean;
newVideos: any[];
trendingVideos: any[];
actionSelect: (key: string) => Promise<void>;
removePin: (reflink: string) => Promise<void>;
PinLocally: (cids: string[], title: string, _id: string) => Promise<void>;
setShowExplorer: (show: boolean) => void;
updateSearchTables: (community?: string, creator?: string) => Promise<void>;
pinRows: React.ReactNode
showExplorer: boolean
newVideos: any[]
trendingVideos: any[]
actionSelect: (key: string) => Promise<void>
removePin: (reflink: string) => Promise<void>
PinLocally: (cids: string[], title: string, _id: string) => Promise<void>
setShowExplorer: (show: boolean) => void
updateSearchTables: (community?: string, creator?: string) => Promise<void>
}

export const PinsViewComponent: React.FC<PinsViewProps> =
({
pinRows,
showExplorer,
newVideos,
trendingVideos,
actionSelect,
removePin,
PinLocally,
setShowExplorer,
updateSearchTables,
}) => {
export const PinsViewComponent: React.FC<PinsViewProps> = ({
pinRows,
showExplorer,
newVideos,
trendingVideos,
actionSelect,
removePin,
PinLocally,
setShowExplorer,
updateSearchTables,
}) => {
return (
<div className="container">
<div>
Expand All @@ -41,23 +40,24 @@ export const PinsViewComponent: React.FC<PinsViewProps> =
<Dropdown.Menu as={CustomPinsViewMenu}>
<Dropdown.Item eventKey="1">Manual Pin</Dropdown.Item>
<Dropdown.Item eventKey="2">Manual GC</Dropdown.Item>
<Dropdown.Item eventKey="3">IPFS Folder</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</Col>
</Row>
<Table striped bordered hover size="sm">
<thead>
<tr>
<th>Reflink</th>
<th>Title</th>
<th>CID(s)</th>
<th>Source</th>
<th>Expiration</th>
<th>Pin Date</th>
<th>Size/Status</th>
<th>Remove?</th>
<th>SPoA</th>
</tr>
<tr>
<th>Reflink</th>
<th>Title</th>
<th>CID(s)</th>
<th>Source</th>
<th>Expiration</th>
<th>Pin Date</th>
<th>Size/Status</th>
<th>Remove?</th>
<th>SPoA</th>
</tr>
</thead>
<tbody>{pinRows}</tbody>
</Table>
Expand Down Expand Up @@ -92,61 +92,61 @@ export const PinsViewComponent: React.FC<PinsViewProps> =
<Col key={type}>
<Table striped bordered hover size="sm">
<thead>
<tr>
<th>{type} videos</th>
<th>Title</th>
<th>Creator</th>
<th>pinned</th>
</tr>
<tr>
<th>{type} videos</th>
<th>Title</th>
<th>Creator</th>
<th>pinned</th>
</tr>
</thead>
<tbody>
{/* {this.state[`${type}Videos`].map((video) => ( */}
{(type === 'new' ? newVideos : trendingVideos).map((video) => (
<tr key={`${type}-${video.author}-${video.permlink}`}>
<td>
<div className="teaser_holder video-card-image">
<div className="card-label">
{(() => {
const pattern = DateTime.compile('mm:ss')
return DateTime.format(new Date(video.duration * 1000), pattern)
})()}
{/* {this.state[`${type}Videos`].map((video) => ( */}
{(type === 'new' ? newVideos : trendingVideos).map((video) => (
<tr key={`${type}-${video.author}-${video.permlink}`}>
<td>
<div className="teaser_holder video-card-image">
<div className="card-label">
{(() => {
const pattern = DateTime.compile('mm:ss')
return DateTime.format(new Date(video.duration * 1000), pattern)
})()}
</div>
<a href={`#/watch/hive:${video.author}:${video.permlink}`}>
<img
className="img-fluid bg-dark"
src={video.images.thumbnail}
alt=""
/>
</a>
</div>
<a href={`#/watch/hive:${video.author}:${video.permlink}`}>
<img
className="img-fluid bg-dark"
src={video.images.thumbnail}
alt=""
/>
</a>
</div>
</td>
<td>{video.title}</td>
<td>{video.author}</td>
<td>
{video.isPinned ? (
<Button
variant="danger"
onClick={async () => {
await removePin(video.id)
updateSearchTables()
}}
>
X
</Button>
) : (
<Button
variant="success"
onClick={async () => {
await PinLocally([video.ipfs], video.title, video.id)
updateSearchTables()
}}
>
O
</Button>
)}
</td>
</tr>
))}
</td>
<td>{video.title}</td>
<td>{video.author}</td>
<td>
{video.isPinned ? (
<Button
variant="danger"
onClick={async () => {
await removePin(video.id)
updateSearchTables()
}}
>
X
</Button>
) : (
<Button
variant="success"
onClick={async () => {
await PinLocally([video.ipfs], video.title, video.id)
updateSearchTables()
}}
>
O
</Button>
)}
</td>
</tr>
))}
</tbody>
</Table>
</Col>
Expand All @@ -156,6 +156,5 @@ export const PinsViewComponent: React.FC<PinsViewProps> =
)}
</div>
</div>
);
};

)
}
Loading
Loading