Skip to content

Commit

Permalink
Merge pull request #2199 from Chia-Network/cmj.fix-add-plot-directory…
Browse files Browse the repository at this point in the history
…-button

Fixed add plot directory button
  • Loading branch information
seeden authored Oct 16, 2023
2 parents 3a27497 + 2c501a9 commit c97ea12
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
17 changes: 14 additions & 3 deletions packages/gui/src/components/plot/PlotAddDirectoryDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useShowError, Button, Loading } from '@chia-network/core';
import { Trans } from '@lingui/macro';
import { Folder as FolderIcon, Delete as DeleteIcon } from '@mui/icons-material';
import {
Alert,
Avatar,
Box,
Dialog,
Expand All @@ -19,6 +20,7 @@ import {
ListItemAvatar,
ListItemSecondaryAction,
ListItemText,
Tooltip,
Typography,
} from '@mui/material';
import React from 'react';
Expand Down Expand Up @@ -85,6 +87,13 @@ export default function PlotAddDirectoryDialog(props: Props) {
plotting screen.
</Trans>
</Typography>
{directories && directories.length > 0 && (
<Alert severity="info">
<Trans>
Clicking a delete icon only removes a directory from this list and never deletes the directory itself
</Trans>
</Alert>
)}
<Box display="flex">
{isLoading ? (
<Loading center />
Expand All @@ -99,9 +108,11 @@ export default function PlotAddDirectoryDialog(props: Props) {
</ListItemAvatar>
<ListItemText primary={dir} />
<ListItemSecondaryAction>
<IconButton edge="end" aria-label="delete" onClick={() => removePlotDir(dir)}>
<DeleteIcon color="info" />
</IconButton>
<Tooltip title={<Trans>Remove from the list</Trans>}>
<IconButton edge="end" aria-label="delete" onClick={() => removePlotDir(dir)}>
<DeleteIcon color="info" />
</IconButton>
</Tooltip>
</ListItemSecondaryAction>
</ListItem>
))}
Expand Down
13 changes: 9 additions & 4 deletions packages/gui/src/components/plot/overview/PlotOverviewPlots.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRefreshPlotsMutation } from '@chia-network/api-react';
import { useRefreshPlotsMutation, useGetPlotDirectoriesQuery } from '@chia-network/api-react';
import { Button, Flex, useOpenDialog, MenuItem, More } from '@chia-network/core';
import { Trans } from '@lingui/macro';
import { Add, Refresh } from '@mui/icons-material';
import { Folder, Refresh } from '@mui/icons-material';
import { ListItemIcon, Typography } from '@mui/material';
import React from 'react';
import { useNavigate } from 'react-router';
Expand All @@ -15,6 +15,7 @@ import PlotOverviewCards from './PlotOverviewCards';
export default function PlotOverviewPlots() {
const navigate = useNavigate();
const openDialog = useOpenDialog();
const { data: directories, isLoading } = useGetPlotDirectoriesQuery();
const [refreshPlots] = useRefreshPlotsMutation();

function handleAddPlot() {
Expand Down Expand Up @@ -44,10 +45,14 @@ export default function PlotOverviewPlots() {
<More>
<MenuItem onClick={handleAddPlotDirectory} close>
<ListItemIcon>
<Add fontSize="small" color="info" />
<Folder fontSize="small" color="info" />
</ListItemIcon>
<Typography variant="inherit" noWrap>
<Trans>Add Plot Directory</Trans>
{isLoading || directories.length === 0 ? (
<Trans>Add Plot Directory</Trans>
) : (
<Trans>Manage Plot Directories</Trans>
)}
</Typography>
</MenuItem>
<MenuItem onClick={handleRefreshPlots} close>
Expand Down

0 comments on commit c97ea12

Please sign in to comment.