Skip to content

Commit

Permalink
[CastIt.Server.ClientApp] Added a copy button
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Dec 12, 2021
1 parent bbeb6f9 commit aaabd39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 16 additions & 2 deletions CastIt.Server/ClientApp/src/components/file/file_item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@material-ui/core';
import { IFileItemResponseDto } from '../../models';
import { onFileChanged, onFileEndReached, onPlayerStatusChanged } from '../../services/castithub.service';
import { Add, ClearAll, Delete, Loop, PlayArrow, Refresh } from '@material-ui/icons';
import { Add, ClearAll, Delete, FileCopy, Loop, PlayArrow, Refresh } from '@material-ui/icons';
import translations from '../../services/translations';
import AddFilesDialog from '../dialogs/add_files_dialog';
import { Draggable } from 'react-beautiful-dnd';
Expand Down Expand Up @@ -216,6 +216,16 @@ function FileItem(props: Props) {
await castItHub.connection.removeAllMissingFiles(props.file.playListId);
};

const handleShowAddFilesDialog = (): void => {
handleCloseContextMenu();
setShowAddFilesDialog(true);
};

const handleCopy = (): void => {
handleCloseContextMenu();
navigator.clipboard.writeText(props.file.path);
};

const title = (
<Tooltip title={state.filename}>
<Typography className={'text-overflow-elipsis'}>{state.filename}</Typography>
Expand Down Expand Up @@ -287,10 +297,14 @@ function FileItem(props: Props) {
<ListItemText className={classes.menuItemText} primary={translations.playFromTheStart} />
</MenuItem>
{toggleLoopMenuItem}
<MenuItem onClick={() => setShowAddFilesDialog(true)}>
<MenuItem onClick={handleShowAddFilesDialog}>
<Add fontSize="small" />
<ListItemText className={classes.menuItemText} primary={translations.addFiles} />
</MenuItem>
<MenuItem onClick={handleCopy}>
<FileCopy fontSize="small" />
<ListItemText className={classes.menuItemText} primary={translations.copyPath} />
</MenuItem>
{/* TODO: REMOVE ALL SELECTED AND SELECT ALL */}
<MenuItem onClick={handleDelete}>
<Delete fontSize="small" />
Expand Down
3 changes: 3 additions & 0 deletions CastIt.Server/ClientApp/src/services/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ interface ITranslations {
connectionFailedMsg: string;
retry: string;
sort: string;
copyPath: string;
errorCodes: IAppMessageTranslations;
}

Expand Down Expand Up @@ -166,6 +167,7 @@ const enTrans: ITranslations = {
connectionFailedMsg: 'Connection failed. The server may not be running',
retry: 'Retry',
sort: 'Sort',
copyPath: 'Copy path',
errorCodes: {
unknownErrorOccurred: 'Unknown error occurred',
invalidRequest: 'Invalid request',
Expand Down Expand Up @@ -258,6 +260,7 @@ const esTrans: ITranslations = {
connectionFailedMsg: 'La conexión falló. El servidor podria no estar ejecutandose',
retry: 'Reintentar',
sort: 'Ordenar',
copyPath: 'Copiar ruta',
errorCodes: {
unknownErrorOccurred: 'Un error inesperado ha ocurrido',
invalidRequest: 'Petición no válida',
Expand Down

0 comments on commit aaabd39

Please sign in to comment.