Skip to content

Commit

Permalink
Revert changes on AttachedImageWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Apr 26, 2023
1 parent 669d06f commit 88eafeb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-object-widget",
"version": "5.2.0",
"version": "5.1.0",
"description": "volto-object-widget: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand All @@ -17,12 +17,6 @@
"type": "git",
"url": "git@github.com:eea/volto-object-widget.git"
},
"addons": [
"@eeacms/volto-widgets-view"
],
"dependencies": {
"@eeacms/volto-widgets-view": "*"
},
"devDependencies": {
"@cypress/code-coverage": "^3.10.0",
"@plone/scripts": "*",
Expand Down
30 changes: 10 additions & 20 deletions src/Widget/AttachedImageWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import {
isInternalURL,
} from '@plone/volto/helpers';

import { getURL } from '@eeacms/volto-widgets-view/helpers';

import imageBlockSVG from '@plone/volto/components/manage/Blocks/Image/block-image.svg';
import clearSVG from '@plone/volto/icons/clear.svg';
import navTreeSVG from '@plone/volto/icons/nav.svg';
Expand Down Expand Up @@ -77,10 +75,7 @@ export class AttachedImageWidget extends Component {
this.setState({
uploading: false,
});
this.props.onChange(this.props.id, {
'@type': 'URL',
value: nextProps.content['@id'],
});
this.props.onChange(this.props.id, nextProps.content['@id']);
}
}

Expand Down Expand Up @@ -146,10 +141,7 @@ export class AttachedImageWidget extends Component {
* @returns {undefined}
*/
onSubmitUrl = () => {
this.props.onChange(this.props.id, {
'@type': 'URL',
value: flattenToAppURL(this.state.url),
});
this.props.onChange(this.props.id, flattenToAppURL(this.state.url));
};

resetSubmitUrl = () => {
Expand Down Expand Up @@ -205,8 +197,6 @@ export class AttachedImageWidget extends Component {
messages.AttachedImageWidgetInputPlaceholder,
);

const imgSrc = getURL(this.props.value);

return (
<FormFieldWrapper
columns={1}
Expand All @@ -216,13 +206,15 @@ export class AttachedImageWidget extends Component {
<div className="wrapper">
<label>{this.props.title}</label>
</div>
{imgSrc && (
{this.props.value && (
<div className="preview">
<img
src={
isInternalURL(imgSrc)
? `${flattenToAppURL(imgSrc)}/@@images/image/preview`
: imgSrc
isInternalURL(this.props.value)
? `${flattenToAppURL(
this.props.value,
)}/@@images/image/preview`
: this.props.value
}
alt="Preview"
/>
Expand All @@ -243,7 +235,7 @@ export class AttachedImageWidget extends Component {
</Button.Group>
</div>
)}
{!imgSrc && (
{!this.props.value && (
<Dropzone
noClick
onDrop={this.onDrop}
Expand Down Expand Up @@ -277,9 +269,7 @@ export class AttachedImageWidget extends Component {
mode: 'image',
currentPath: this.props.pathname,
onSelectItem: (url) => {
this.setState({ url }, () => {
this.onSubmitUrl();
});
this.setState({ url });
},
});
}}
Expand Down

0 comments on commit 88eafeb

Please sign in to comment.