diff --git a/client/dist/js/bundle.js b/client/dist/js/bundle.js index 392d933..e04935d 100644 --- a/client/dist/js/bundle.js +++ b/client/dist/js/bundle.js @@ -1 +1 @@ -!function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=6)}([function(t,e){t.exports=React},function(t,e){t.exports=ReactRedux},function(t,e){t.exports=Redux},function(t,e,n){"use strict";var r=n(8),o=n(1),u=(n.n(o),n(2)),i=(n.n(u),n.i(u.compose)(n.i(o.connect)(function(){return{}}),r.a));e.a=i},function(t,e,n){"use strict";var r=n(0),o=n.n(r),u=Object.assign||function(t){for(var e=1;e0&&void 0!==arguments[0]?arguments[0]:null;return function(e){return e({type:_.default.SELECT_FILES,payload:{ids:t}})}}function u(t){return function(e){return e({type:_.default.CONCATENATE_SELECT,payload:!!t})}}function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return function(e){return e({type:_.default.DESELECT_FILES,payload:{ids:t}})}}function a(t){return function(e){return e({type:_.default.SET_NOTICE_MESSAGE,payload:{message:t}})}}function c(t){return function(e){return e({type:_.default.SET_ERROR_MESSAGE,payload:{message:t}})}}function s(t){return function(e){return e({type:_.default.SET_ENABLE_DROPZONE,payload:{enableDropzone:t}})}}function l(t){return function(e){e({type:_.default.CLEAR_FILE_BADGE,payload:{id:t}})}}function f(t,e,n,r){return function(o,u){var i=u(),a=i.assetAdmin,c=a.gallery.badges.find(function(e){return e.id===t});c&&c.timer&&clearTimeout(c.timer);var s=r>0?setTimeout(function(){return l(t)(o)},r):null;o({type:_.default.SET_FILE_BADGE,payload:{id:t,message:e,status:n,timer:s}})}}function d(t){return function(e){e({type:_.default.ACTIVATE_MODAL,payload:t})}}function p(){return function(t){t({type:_.default.DEACTIVATE_MODAL})}}function E(t){return function(e){e({type:_.default.SET_LOADING,payload:!!t})}}Object.defineProperty(e,"__esModule",{value:!0}),e.loadFile=r,e.selectFiles=o,e.setConcatenateSelect=u,e.deselectFiles=i,e.setNoticeMessage=a,e.setErrorMessage=c,e.setEnableDropzone=s,e.clearFileBadge=l,e.setFileBadge=f,e.activateModal=d,e.deactivateModal=p,e.setLoading=E;var y=n(9),_=function(t){return t&&t.__esModule?t:{default:t}}(y)},function(t,e){t.exports=IsomorphicFetch}]); \ No newline at end of file +!function(e){function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r={};n.m=e,n.c=r,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=2)}([function(e,n,r){"use strict";var t=r(3),o=r.n(t),u=Object.assign||function(e){for(var n=1;n { - updater.component('GalleryToolbar', CloudinaryEnhancedGalleryToolbar); - } -); - Injector.transform( 'cloudinary-preview-image-field', updater => { diff --git a/client/src/js/components/CloudinaryEnhancedGalleryToolbar.js b/client/src/js/components/CloudinaryEnhancedGalleryToolbar.js deleted file mode 100644 index 10052cb..0000000 --- a/client/src/js/components/CloudinaryEnhancedGalleryToolbar.js +++ /dev/null @@ -1,14 +0,0 @@ - -import CloudinaryToolbarFields from './CloudinaryToolbarFields'; - -import { connect } from 'react-redux'; -import { compose } from 'redux'; - -const CloudinaryEnhancedGalleryToolbar = compose( - connect( - () => ({}) - ), - CloudinaryToolbarFields -); - -export default CloudinaryEnhancedGalleryToolbar; diff --git a/client/src/js/components/CloudinarySync.js b/client/src/js/components/CloudinarySync.js deleted file mode 100644 index 29405d1..0000000 --- a/client/src/js/components/CloudinarySync.js +++ /dev/null @@ -1,101 +0,0 @@ -/* global ss */ - -import React, { Component } from 'react'; -import fetch from 'isomorphic-fetch'; -import { connect } from 'react-redux'; -import { compose } from 'redux'; - -import { setErrorMessage } from '../../../../../../silverstripe/asset-admin/client/src/state/gallery/GalleryActions'; - -export const CONSTANTS = { SYNC_BUTTON_KEY: 'sync-with-cloudinary-button' }; - -class CloudinarySync extends Component { - constructor(props) { - super(props); - this.state = { updating: false }; - this.fetch = fetch; - } - - handleSyncWithCloudinary() { - const opts = { credentials: 'include' }; - this.fetch('/cloudinary-api/sync', opts).then(response => { - if (response.status === 200) { - response.json().then(this.handleSyncSuccess.bind(this)); - } else { - response.json().then(this.handleSyncError.bind(this)); - } - }); - delete this.state.updated; - this.setState({ - updating: true - }); - } - handleSyncSuccess(data) { - this.setState({ - updating: false, - updated: data.result.count - }); - - this.props.refreshPage(); - } - - handleSyncError(data) { - const { setError } = this.props; - this.setState({ - updating: false - }); - setError(ss.i18n._t(`Cloudinary.SYNC_WITH_CLOUDINARY_${data.error.toUpperCase()}`, data.description)); - setTimeout(() => { - setError(null); - }, 3000); - } - - render() { - const classes = ['btn', 'btn-secondary', 'font-icon-sync', 'btn--icon-xl']; - if (this.state.updating) { - classes.push('updating'); - } - - let message = ss.i18n._t('Cloudinary.SYNC_WITH_CLOUDINARY', 'Sync with Cloudinary'); - if (this.state.updating) { - message = ss.i18n._t('Cloudinary.UPDATING_FROM_CLOUDINARY', 'Updating from Cloudinary'); - } else if (this.state.updated !== undefined) { - message = ss.i18n.sprintf(ss.i18n._t('Cloudinary.UPDATED_FROM_CLOUDINARY', '%s Synced from Cloudinary'), this.state.updated); - } - - const handleSyncWithCloudinary = () => { - this.handleSyncWithCloudinary(); - }; - - return ( - - ); - } -} - - -function mapStateToProps() { - return {}; -} - -function mapDispatchToProps(dispatch) { - return { - setError(msg) { - dispatch(setErrorMessage(msg)); - }, - }; -} - -export default compose( - connect(mapStateToProps, mapDispatchToProps) -)(CloudinarySync); diff --git a/client/src/js/components/CloudinaryToolbarFields.js b/client/src/js/components/CloudinaryToolbarFields.js deleted file mode 100644 index 5434906..0000000 --- a/client/src/js/components/CloudinaryToolbarFields.js +++ /dev/null @@ -1,25 +0,0 @@ - -import React from 'react'; -import CloudinarySync, { CONSTANTS } from './CloudinarySync'; - -const CloudinaryToolbarFields = (GalleryToolbar) => (props) => { - const newProps = { - ...props, - }; - - function renderSyncButton() { - return (); - } - - newProps.children = newProps.children || []; - newProps.children = newProps.children.filter(el => el.key !== CONSTANTS.SYNC_BUTTON_KEY); - newProps.children.push(renderSyncButton()); - return ( - - ); -}; - -export default CloudinaryToolbarFields; diff --git a/composer.json b/composer.json index 5f4f32b..ca6537b 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "require": { "cloudinary/cloudinary_php": "dev-master", "php": ">=7.0.0", + "silverstripe/assets": "^1.1", "silverstripe/asset-admin": "^1.1" }, "autoload": { diff --git a/src/Model/File.php b/src/Model/File.php index 01a8716..3e91a48 100644 --- a/src/Model/File.php +++ b/src/Model/File.php @@ -36,4 +36,11 @@ public function doArchive() $r = $api->delete_resources(array($this->PublicID)); return parent::doArchive(); } + + public static function getOneByPublicId($publicId) + { + return static::get_one(static::class, [ + 'PublicID' => $publicId, + ]); + } } diff --git a/src/Traits/CloudinaryFileTrait.php b/src/Traits/CloudinaryFileTrait.php index 8d957f6..7f9e858 100644 --- a/src/Traits/CloudinaryFileTrait.php +++ b/src/Traits/CloudinaryFileTrait.php @@ -29,13 +29,6 @@ trait CloudinaryFileTrait 'RemoteData' => 'Text', ]; - public static function getOneByPublicId($publicId) - { - return static::get_one(static::class, [ - 'PublicID' => $publicId, - ]); - } - public function updateFromCloudinary($resource) { $parentFolder = static::getParentFolderForResouce($resource);