Skip to content

Commit

Permalink
Merge pull request #94 from safiyamak/DataSetDownloaded
Browse files Browse the repository at this point in the history
Marking downloaded datasets properly
  • Loading branch information
aliasaria authored May 27, 2024
2 parents adcf7fb + 095cb9d commit 12300b7
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
7 changes: 4 additions & 3 deletions src/renderer/components/Data/DataStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ export default function DataStore() {
>
<Grid container spacing={2} sx={{ flexGrow: 1 }}>
{data &&
filterByFilters(data, searchText).map((row) => (
data.data &&
filterByFilters(data.data, searchText).map((row) => (
<Grid xs={4}>
<DatasetCard
name={row.name}
size={row.size}
key={row.id}
description={row.description}
repo={row.huggingfacerepo}
download
downloaded={row.downloaded}
local={false}
location={undefined}
parentMutate={mutate}
/>
Expand Down
36 changes: 25 additions & 11 deletions src/renderer/components/Data/DatasetCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from 'react';
import { useState } from 'react';

import {
Expand All @@ -11,7 +10,12 @@ import {
ModalDialog,
Typography,
} from '@mui/joy';
import { DownloadIcon, FileTextIcon, Trash2Icon } from 'lucide-react';
import {
DownloadIcon,
FileTextIcon,
Trash2Icon,
CheckIcon,
} from 'lucide-react';

import { formatBytes } from 'renderer/lib/utils';
import * as chatAPI from '../../lib/transformerlab-api-sdk';
Expand All @@ -25,14 +29,14 @@ export default function DatasetCard({
size,
description,
repo,
download = false,
downloaded,
location,
parentMutate,
local,
}) {
const [installing, setInstalling] = useState(null);
const [previewDatasetModalOpen, setPreviewDatasetModalOpen] =
React.useState(false);
const [datasetInfoModalOpen, setDatasetInfoModalOpen] = React.useState(false);
const [previewDatasetModalOpen, setPreviewDatasetModalOpen] = useState(false);
const [datasetInfoModalOpen, setDatasetInfoModalOpen] = useState(false);

return (
<>
Expand Down Expand Up @@ -81,7 +85,7 @@ export default function DatasetCard({
</div>
</CardContent>
<CardContent orientation="horizontal">
{!download && (
{downloaded && local && (
<>
<Button
color="neutral"
Expand Down Expand Up @@ -111,16 +115,22 @@ export default function DatasetCard({
</Button>
</>
)}
{download && (
{!local && (
<Button
variant="solid"
size="sm"
color="primary"
aria-label="Download"
sx={{ ml: 'auto' }}
disabled={installing}
disabled={downloaded || installing}
endDecorator={
installing ? <CircularProgress /> : <DownloadIcon size="18px" />
downloaded ? (
<CheckIcon />
) : installing ? (
<CircularProgress />
) : (
<DownloadIcon size="18px" />
)
}
onClick={() => {
setInstalling(true);
Expand All @@ -146,7 +156,11 @@ export default function DatasetCard({
});
}}
>
{installing ? 'Downloading' : 'Download'}
{downloaded
? 'Downloaded'
: installing
? 'Downloading'
: 'Download'}{' '}
</Button>
)}
</CardContent>
Expand Down
1 change: 0 additions & 1 deletion src/renderer/components/Data/DatasetInfoModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable camelcase */
import React, { useEffect, useState } from 'react';
import useSWR from 'swr';

import {
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/components/Data/LocalDatasets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export default function LocalDatasets() {
}}
>
<Grid container spacing={2} sx={{ flexGrow: 1 }}>
{data && console.log(data)}
{data &&
filterByFiltersDatasetID(data, searchText).map((row) => (
<Grid xs={4}>
Expand All @@ -118,6 +117,8 @@ export default function LocalDatasets() {
description={row?.description}
repo={row.huggingfacerepo}
location={row?.location}
downloaded={true}
local={true}
parentMutate={mutate}
/>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/Data/PreviewDatasetModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable camelcase */
import React, { useEffect, useState } from 'react';
import { useEffect, useState } from 'react';
import useSWR from 'swr';
import {
Button,
Expand Down

0 comments on commit 12300b7

Please sign in to comment.