Skip to content
Open
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
42 changes: 41 additions & 1 deletion app/components/AssetDetails/AssetDetails.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { FaTrash, FaEdit } from 'react-icons/fa';
import { IconButton } from '@mui/material';
import { IconButton, Box, Button } from '@mui/material';
import OverflowDiv from '../OverflowDiv/OverflowDiv';
import Constants from '../../constants/constants';
import Accordion from '@mui/material/Accordion';
Expand All @@ -14,6 +14,8 @@ import Loading from '../Loading/Loading';
import SourceControlHistory from '../SourceControlHistory/SourceControlHistory';
import styles from './AssetDetails.css';
import { styled } from '@mui/material/styles';
const { ipcRenderer } = window.require('electron');
const Messages = require('../../constants/messages');

const CustomAccordionSummary = styled(AccordionSummary)(({ theme }) => ({
backgroundColor: 'rgba(0, 0, 0, .03)',
Expand Down Expand Up @@ -93,6 +95,24 @@ const assetDetails = (props) => {
}
};

const handleShowInFolder = () => {
if (asset) {
const filePath = asset.uri;
if (filePath) {
ipcRenderer.send(Messages.SHOW_ITEM_IN_FOLDER, filePath);
}
}
};

const handleOpenFile = () => {
if (asset) {
const filePath = asset.uri;
if (filePath) {
ipcRenderer.send(Messages.OPEN_FILE_WITH_DEFAULT, filePath);
}
}
};

const isExternalAsset = asset && asset.type === Constants.AssetType.URL;

let sourceControlAccordion = null;
Expand Down Expand Up @@ -151,6 +171,25 @@ const assetDetails = (props) => {
);
}

let fileActions = null;
if (asset) {
const filePath = asset.uri;
if (filePath) {
fileActions = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make a few modifications to the available actions here? One of these is a new request I did not think of originally, so it can be considered out of scope.

  1. For a folder, "Open File" works, but does the same action as "Show in Folder". We should hide the "Open File" action if the asset type is a folder
  2. For external resources, these options should not be available
  3. (New request) For external resources, because those would be a URL, the action could be "Open URL" or "Open Link"

If possible to address 1 & 2 in this PR, that would be great. Item 3 is expanding the scope of this request, but if you would be willing to tackle it that would be awesome.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure sir, I will fix this ASAP!!
Thanks :)

<Box mt={2} mb={2} display="flex" gap={1}>
<Button size="small" variant="outlined" onClick={handleShowInFolder}>
Show in Folder
</Button>
<Button size="small" variant="outlined" onClick={handleOpenFile}>
Open File
</Button>
</Box>
);
} else {
console.warn('Asset missing file path property');
}
}

return (
<div className={styles.container}>
<OverflowDiv>{asset.uri}</OverflowDiv>
Expand All @@ -173,6 +212,7 @@ const assetDetails = (props) => {
</AccordionDetails>
</Accordion>
{attributesAccordion}
{fileActions}
{sourceControlAccordion}
</div>
);
Expand Down