Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion client/dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/userform.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/dist/userform.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 17 additions & 7 deletions client/src/js/components/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,17 @@ export default class Field extends Component {
}

componentDidMount() {
this.setState({
loading: false,
});
const interval = setInterval(() => {
if ('CLOUDINARY_CONFIG' in window === false) {
return;
}

clearInterval(interval);

this.setState({
loading: false,
});
}, 100);
}

showLibrary() {
Expand Down Expand Up @@ -365,17 +373,19 @@ export default class Field extends Component {
</div>
) }

{ showButton === true && (
{ this.state.loading === false && showButton === true && (
<div className="cloudinary-field__insert">
<button type="button" className="btn btn-primary cloudinary-field__button" onClick={this.showLibrary}>
<span className="btn__title">{ this.props.buttonLabel }</span>
</button>
</div>
) }

<div className="cloudinary-field__items">
{ this.renderResources() }
</div>
{ this.state.loading === false && (
<div className="cloudinary-field__items">
{ this.renderResources() }
</div>
)}
</div>
);
}
Expand Down
12 changes: 6 additions & 6 deletions client/src/js/components/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export default class Resource extends Component {
{this.fields().map(field => {
if (field === 'title') {
return (
<div className="cloudinary-field__field">
<div className="cloudinary-field__field" key={ field }>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The key will always have a value of title it seems

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Which is fine, as long as it's unique for that instance. There's only one title field for an instance of a Cloudinary field.

<label htmlFor={ `${public_id}_title` } className="cloudinary-field__label">
{ this.titleFieldLabel() }
</label>
Expand All @@ -259,7 +259,7 @@ export default class Resource extends Component {

if (field === 'description') {
return (
<div className="cloudinary-field__field">
<div className="cloudinary-field__field" key={ field }>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The key will always have a value of description it seems

<label htmlFor={ `${public_id}_description` } className="cloudinary-field__label">
{ this.descriptionFieldLabel() }
</label>
Expand All @@ -273,7 +273,7 @@ export default class Resource extends Component {

if (field === 'credit') {
return (
<div className="cloudinary-field__field">
<div className="cloudinary-field__field" key={ field }>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The key will always have a value of credit it seems

<label htmlFor={ `${public_id}_credit` } className="cloudinary-field__label">
{ this.creditFieldLabel() }
</label>
Expand All @@ -287,7 +287,7 @@ export default class Resource extends Component {

if (field === 'gravity') {
return (
<div className="cloudinary-field__field">
<div className="cloudinary-field__field" key={ field }>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

again

<label htmlFor={ `${public_id}_gravity` } className="cloudinary-field__label">
{ this.gravityFieldLabel() }
</label>
Expand All @@ -305,7 +305,7 @@ export default class Resource extends Component {

if (field === 'fg-colour' && resource_type === 'image' && top_colours && top_colours.length) {
return (
<div className="cloudinary-field__field">
<div className="cloudinary-field__field" key={ field }>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

again

<label className="cloudinary-field__label">
{ this.fgColourFieldLabel() }
</label>
Expand Down Expand Up @@ -333,7 +333,7 @@ export default class Resource extends Component {

if (field === 'bg-colour' && resource_type === 'image' && top_colours && top_colours.length) {
return (
<div className="cloudinary-field__field">
<div className="cloudinary-field__field" key={ field }>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

...

<label className="cloudinary-field__label">
{ this.bgColourFieldLabel() }
</label>
Expand Down
2 changes: 1 addition & 1 deletion src/Extensions/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function init()
'signature' => $signature,
];

$script = sprintf('const CLOUDINARY_CONFIG = %s;', json_encode($options));
$script = sprintf('window.CLOUDINARY_CONFIG = %s;', json_encode($options));

Requirements::customScript($script, 'MadeHQ\\Cloudinary');
}
Expand Down