Show image name and path in image name modal

Change-type: patch
This commit is contained in:
Alexis Svinartchouk 2020-05-27 17:45:44 +02:00
parent 4752fa6dd2
commit aee3a0a281

View File

@ -439,9 +439,8 @@ export class SourceSelector extends React.Component<
const hasImage = selectionState.hasImage(); const hasImage = selectionState.hasImage();
const imageBasename = hasImage const imagePath = selectionState.getImagePath();
? path.basename(selectionState.getImagePath()) const imageBasename = hasImage ? path.basename(imagePath) : '';
: '';
const imageName = selectionState.getImageName(); const imageName = selectionState.getImageName();
const imageSize = selectionState.getImageSize(); const imageSize = selectionState.getImageSize();
@ -466,7 +465,7 @@ export class SourceSelector extends React.Component<
<StepNameButton <StepNameButton
plain plain
onClick={this.showSelectedImageDetails} onClick={this.showSelectedImageDetails}
tooltip={imageBasename} tooltip={imageName || imageBasename}
> >
{middleEllipsis(imageName || imageBasename, 20)} {middleEllipsis(imageName || imageBasename, 20)}
</StepNameButton> </StepNameButton>
@ -533,21 +532,28 @@ export class SourceSelector extends React.Component<
{showImageDetails && ( {showImageDetails && (
<Modal <Modal
title="Image File Name" title="Image"
done={() => { done={() => {
this.setState({ showImageDetails: false }); this.setState({ showImageDetails: false });
}} }}
> >
{selectionState.getImagePath()} <Txt.p>
<Txt.span bold>Name: </Txt.span>
<Txt.span>{imageName || imageBasename}</Txt.span>
</Txt.p>
<Txt.p>
<Txt.span bold>Path: </Txt.span>
<Txt.span>{imagePath}</Txt.span>
</Txt.p>
</Modal> </Modal>
)} )}
{showURLSelector && ( {showURLSelector && (
<URLSelector <URLSelector
done={async (imagePath: string) => { done={async (imageURL: string) => {
// Avoid analytics and selection state changes // Avoid analytics and selection state changes
// if no file was resolved from the dialog. // if no file was resolved from the dialog.
if (!imagePath) { if (!imageURL) {
analytics.logEvent('URL selector closed'); analytics.logEvent('URL selector closed');
this.setState({ this.setState({
showURLSelector: false, showURLSelector: false,
@ -556,7 +562,7 @@ export class SourceSelector extends React.Component<
} }
await this.selectImageByPath({ await this.selectImageByPath({
imagePath, imagePath: imageURL,
SourceType: sourceDestination.Http, SourceType: sourceDestination.Http,
}); });
this.setState({ this.setState({