Skip to content

Commit

Permalink
Merge remote-tracking branch 'official/master' into feature/rollup
Browse files Browse the repository at this point in the history
* official/master:
  update release ticker
  Publish
  feat: add cloudinary support (decaporg#1932)
  fix(netlify-cms-core): duplicate key warning (decaporg#1930)
  Update image.md (decaporg#1923)
  chore(netlify-cms-core): upgrade react-frame-component to 4.x (decaporg#1925)
  chore(netlify-cms-core): upgrade gray-matter to 4.x (decaporg#1924)
  feat(netlify-cms-widget-select): add support for multiple selection (decaporg#1901)

# Conflicts:
#	packages/netlify-cms-widget-select/package.json
#	packages/netlify-cms/src/media-libraries.js
  • Loading branch information
LoicMahieu committed Dec 5, 2018
2 parents 10d6258 + ec5b077 commit 3e74598
Show file tree
Hide file tree
Showing 38 changed files with 733 additions and 96 deletions.
16 changes: 15 additions & 1 deletion dev-test/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ collections: # A list of collections the CMS should be able to edit
create: true # Allow users to create new documents in this collection
fields: # The fields each document in this collection have
- { label: 'Title', name: 'title', widget: 'string', tagname: 'h1' }
- { label: 'Publish Date', name: 'date', widget: 'datetime', dateFormat: 'YYYY-MM-DD', timeFormat: 'HH:mm', format: 'YYYY-MM-DD HH:mm' }
- {
label: 'Publish Date',
name: 'date',
widget: 'datetime',
dateFormat: 'YYYY-MM-DD',
timeFormat: 'HH:mm',
format: 'YYYY-MM-DD HH:mm',
}
- label: 'Cover Image'
name: 'image'
widget: 'image'
Expand Down Expand Up @@ -92,6 +99,13 @@ collections: # A list of collections the CMS should be able to edit
- { label: 'Image', name: 'image', widget: 'image' }
- { label: 'File', name: 'file', widget: 'file' }
- { label: 'Select', name: 'select', widget: 'select', options: ['a', 'b', 'c'] }
- {
label: 'Select multiple',
name: 'select_multiple',
widget: 'select',
options: ['a', 'b', 'c'],
multiple: true,
}
- { label: 'Hidden', name: 'hidden', widget: 'hidden', default: 'hidden' }
- label: 'Object'
name: 'object'
Expand Down
17 changes: 17 additions & 0 deletions packages/netlify-cms-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.3.0](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core/compare/netlify-cms-core@2.2.1...netlify-cms-core@2.3.0) (2018-12-04)


### Bug Fixes

* **netlify-cms-core:** duplicate key warning ([#1930](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core/issues/1930)) ([9662eb2](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core/commit/9662eb2))


### Features

* **netlify-cms-widget-select:** add support for multiple selection ([#1901](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core/issues/1901)) ([88bf287](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core/commit/88bf287))
* add cloudinary support ([#1932](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core/issues/1932)) ([1fc2f50](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core/commit/1fc2f50))





## [2.2.1](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core/compare/netlify-cms-core@2.2.0...netlify-cms-core@2.2.1) (2018-11-29)


Expand Down
8 changes: 4 additions & 4 deletions packages/netlify-cms-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "netlify-cms-core",
"description": "Netlify CMS core application, see netlify-cms package for the main distribution.",
"version": "2.2.1",
"version": "2.3.0",
"repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-core",
"bugs": "https://github.com/netlify/netlify-cms/issues",
"module": "dist/netlify-cms-core.esm.js",
Expand All @@ -27,15 +27,15 @@
"emotion": "^9.2.6",
"fuzzy": "^0.1.1",
"gotrue-js": "^0.9.15",
"gray-matter": "^3.0.6",
"gray-matter": "^4.0.1",
"history": "^4.7.2",
"immutable": "^3.7.6",
"js-base64": "^2.1.9",
"js-yaml": "^3.10.0",
"jwt-decode": "^2.1.0",
"lodash": "^4.17.10",
"moment": "^2.11.2",
"netlify-cms-editor-component-image": "^2.0.4",
"netlify-cms-editor-component-image": "^2.1.0",
"netlify-cms-lib-auth": "^2.0.5",
"netlify-cms-lib-util": "^2.1.1",
"netlify-cms-ui-default": "^2.1.1",
Expand All @@ -46,7 +46,7 @@
"react-dnd-html5-backend": "^7.0.0",
"react-dom": "^16.0.0",
"react-emotion": "^9.2.5",
"react-frame-component": "^2.0.0",
"react-frame-component": "^4.0.2",
"react-hot-loader": "^4.0.0",
"react-immutable-proptypes": "^2.1.0",
"react-is": "16.3.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/netlify-cms-core/src/actions/mediaLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export function openMediaLibrary(payload = {}) {
const state = getState();
const mediaLibrary = state.mediaLibrary.get('externalLibrary');
if (mediaLibrary) {
const { controlID: id, value, config = Map(), forImage } = payload;
mediaLibrary.show({ id, value, config: config.toJS(), imagesOnly: forImage });
const { controlID: id, value, config = Map(), allowMultiple, forImage } = payload;
mediaLibrary.show({ id, value, config: config.toJS(), allowMultiple, imagesOnly: forImage });
}
dispatch({ type: MEDIA_LIBRARY_OPEN, payload });
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { Map } from 'immutable';
import { Map, List } from 'immutable';
import ValidationErrorTypes from 'Constants/validationErrorTypes';

const truthy = () => ({ error: false });
Expand All @@ -10,7 +10,8 @@ const isEmpty = value =>
value === null ||
value === undefined ||
(value.hasOwnProperty('length') && value.length === 0) ||
(value.constructor === Object && Object.keys(value).length === 0);
(value.constructor === Object && Object.keys(value).length === 0) ||
(List.isList(value) && value.size === 0);

export default class Widget extends Component {
static propTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import { isElement } from 'react-is';
import { ScrollSyncPane } from 'react-scroll-sync';
import { FrameContextConsumer } from 'react-frame-component';

/**
* We need to create a lightweight component here so that we can access the
Expand All @@ -12,19 +13,19 @@ class PreviewContent extends React.Component {
render() {
const { previewComponent, previewProps } = this.props;
return (
<ScrollSyncPane attachTo={this.context.document.scrollingElement}>
{isElement(previewComponent)
? React.cloneElement(previewComponent, previewProps)
: React.createElement(previewComponent, previewProps)}
</ScrollSyncPane>
<FrameContextConsumer>
{context => (
<ScrollSyncPane attachTo={context.document.scrollingElement}>
{isElement(previewComponent)
? React.cloneElement(previewComponent, previewProps)
: React.createElement(previewComponent, previewProps)}
</ScrollSyncPane>
)}
</FrameContextConsumer>
);
}
}

PreviewContent.contextTypes = {
document: PropTypes.any,
};

PreviewContent.propTypes = {
previewComponent: PropTypes.func.isRequired,
previewProps: PropTypes.object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class WorkflowList extends React.Component {
return (
<DragSource
namespace={DNDNamespace}
key={slug}
key={`${collection}-${slug}`}
slug={slug}
collection={collection}
ownStatus={ownStatus}
Expand Down
11 changes: 9 additions & 2 deletions packages/netlify-cms-core/src/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,12 @@ export const selectUnpublishedEntriesByStatus = (state, status) =>
export const selectIntegration = (state, collection, hook) =>
fromIntegrations.selectIntegration(state.integrations, collection, hook);

export const getAsset = (state, path) =>
fromMedias.getAsset(state.config.get('public_folder'), state.medias, path);
export const getAsset = (state, path) => {
/**
* If an external media library is in use, just return the path.
*/
if (state.mediaLibrary.get('externalLibrary')) {
return path;
}
return fromMedias.getAsset(state.config.get('public_folder'), state.medias, path);
};
11 changes: 11 additions & 0 deletions packages/netlify-cms-editor-component-image/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.1.0](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-editor-component-image/compare/netlify-cms-editor-component-image@2.0.4...netlify-cms-editor-component-image@2.1.0) (2018-12-04)


### Features

* add cloudinary support ([#1932](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-editor-component-image/issues/1932)) ([1fc2f50](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-editor-component-image/commit/1fc2f50))





<a name="2.0.4"></a>
## [2.0.4](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-editor-component-image/compare/netlify-cms-editor-component-image@2.0.3...netlify-cms-editor-component-image@2.0.4) (2018-08-24)

Expand Down
2 changes: 1 addition & 1 deletion packages/netlify-cms-editor-component-image/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "netlify-cms-editor-component-image",
"description": "Image component for Netlify CMS editor widget",
"version": "2.0.4",
"version": "2.1.0",
"repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-editor-component-image",
"bugs": "https://github.com/netlify/netlify-cms/issues",
"module": "dist/netlify-cms-editor-component-image.esm.js",
Expand Down
3 changes: 3 additions & 0 deletions packages/netlify-cms-editor-component-image/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const image = {
label: 'Image',
name: 'image',
widget: 'image',
media_library: {
allow_multiple: false,
},
},
{
label: 'Alt Text',
Expand Down
11 changes: 11 additions & 0 deletions packages/netlify-cms-media-library-cloudinary/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# 1.1.0 (2018-12-04)


### Features

* add cloudinary support ([#1932](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-media-library-cloudinary/issues/1932)) ([1fc2f50](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-media-library-cloudinary/commit/1fc2f50))
11 changes: 11 additions & 0 deletions packages/netlify-cms-media-library-cloudinary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Docs coming soon!

Netlify CMS was recently converted from a single npm package to a "monorepo" of over 20 packages.
That's over 20 Readme's! We haven't created one for this package yet, but we will soon.

In the meantime, you can:

1. Check out the [main readme](https://github.com/netlify/netlify-cms/#readme) or the [documentation
site](https://www.netlifycms.org) for more info.
2. Reach out to the [community chat](https://gitter.im/netlify/netlifycms/) if you need help.
3. Help out and [write the readme yourself](https://github.com/netlify/netlify-cms/edit/master/packages/netlify-cms-media-library-cloudinary/README.md)!
34 changes: 34 additions & 0 deletions packages/netlify-cms-media-library-cloudinary/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "netlify-cms-media-library-cloudinary",
"description": "Cloudinary integration for Netlify CMS",
"version": "1.1.0",
"repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-media-library-cloudinary",
"bugs": "https://github.com/netlify/netlify-cms/issues",
"main": "dist/netlify-cms-media-library-cloudinary.js",
"license": "MIT",
"keywords": [
"netlify",
"netlify-cms",
"cloudinary",
"image",
"images",
"media",
"assets",
"files",
"uploads"
],
"sideEffects": false,
"scripts": {
"watch": "webpack -w",
"develop": "npm run watch",
"build": "cross-env NODE_ENV=production webpack"
},
"devDependencies": {
"cross-env": "^5.2.0",
"webpack": "^4.16.1",
"webpack-cli": "^3.1.0"
},
"peerDependencies": {
"netlify-cms-lib-util": "^2.0.4"
}
}
82 changes: 82 additions & 0 deletions packages/netlify-cms-media-library-cloudinary/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { pick } from 'lodash';
import { loadScript } from 'netlify-cms-lib-util';

const defaultOptions = {
use_secure_url: true,
use_transformations: true,
output_filename_only: false,
};
/**
* This configuration hash cannot be overriden, as the values here are required
* for the integration to work properly.
*/
const enforcedConfig = {
button_class: undefined,
inline_container: undefined,
insert_transformation: false,
z_index: '99999',
};

const defaultConfig = {
multiple: false,
};

function getAssetUrl(asset, { use_secure_url, use_transformations, output_filename_only }) {
/**
* Allow output of the file name only, in which case the rest of the url (including)
* transformations) can be handled by the static site generator.
*/
if (output_filename_only) {
return `${asset.public_id}.${asset.format}`;
}

/**
* Get url from `derived` property if it exists. This property contains the
* transformed version of image if transformations have been applied.
*/
const urlObject = asset.derived && use_transformations ? asset.derived[0] : asset;

/**
* Retrieve the `https` variant of the image url if the `useSecureUrl` option
* is set to `true` (this is the default setting).
*/
const urlKey = use_secure_url ? 'secure_url' : 'url';

return urlObject[urlKey];
}

async function init({ options, handleInsert }) {
const { config: providedConfig = {}, ...integrationOptions } = options;
const resolvedOptions = { ...defaultOptions, ...integrationOptions };
const cloudinaryConfig = { ...defaultConfig, ...providedConfig, ...enforcedConfig };
const cloudinaryBehaviorConfigKeys = ['default_transformations', 'max_files', 'multiple'];
const cloudinaryBehaviorConfig = pick(cloudinaryConfig, cloudinaryBehaviorConfigKeys);

await loadScript('https://media-library.cloudinary.com/global/all.js');

const insertHandler = data => {
const assets = data.assets.map(asset => getAssetUrl(asset, resolvedOptions));
handleInsert(cloudinaryConfig.multiple ? assets : assets[0]);
};

const mediaLibrary = window.cloudinary.createMediaLibrary(cloudinaryConfig, { insertHandler });

return {
show: ({ config: instanceConfig = {}, allowMultiple }) => {
/**
* Ensure multiple selection is not available if the field is configured
* to disallow it.
*/
if (allowMultiple === false) {
instanceConfig.multiple = false;
}
return mediaLibrary.show({ config: { ...cloudinaryBehaviorConfig, instanceConfig } });
},
hide: () => mediaLibrary.hide(),
enableStandalone: () => true,
};
}

const cloudinaryMediaLibrary = { name: 'cloudinary', init };

export default cloudinaryMediaLibrary;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { getConfig } = require('../../scripts/webpack.js');

module.exports = getConfig();
11 changes: 11 additions & 0 deletions packages/netlify-cms-media-library-uploadcare/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.3.0](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-media-library-uploadcare/compare/netlify-cms-media-library-uploadcare@0.2.1...netlify-cms-media-library-uploadcare@0.3.0) (2018-12-04)


### Features

* add cloudinary support ([#1932](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-media-library-uploadcare/issues/1932)) ([1fc2f50](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-media-library-uploadcare/commit/1fc2f50))





## [0.2.1](https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-media-library-uploadcare/compare/netlify-cms-media-library-uploadcare@0.2.0...netlify-cms-media-library-uploadcare@0.2.1) (2018-11-12)


Expand Down
2 changes: 1 addition & 1 deletion packages/netlify-cms-media-library-uploadcare/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "netlify-cms-media-library-uploadcare",
"description": "Uploadcare integration for Netlify CMS",
"version": "0.2.1",
"version": "0.3.0",
"repository": "https://github.com/netlify/netlify-cms/tree/master/packages/netlify-cms-media-library-uploadcare",
"bugs": "https://github.com/netlify/netlify-cms/issues",
"module": "dist/netlify-cms-media-library-uploadcare.esm.js",
Expand Down
Loading

0 comments on commit 3e74598

Please sign in to comment.