mirror of
https://github.com/strapi/strapi.git
synced 2025-10-26 23:51:10 +00:00
Merge branch 'feature/upload' of github.com:strapi/strapi into feature/upload
This commit is contained in:
commit
74ee186be2
@ -19,4 +19,14 @@ const selectAdminPage = () => createSelector(
|
||||
(substate) => substate.toJS(),
|
||||
);
|
||||
|
||||
const makeSelectEnv = () => createSelector(
|
||||
selectAdminPageDomain(),
|
||||
(substate) => substate.get('appEnvironments').toJS(),
|
||||
);
|
||||
|
||||
export {
|
||||
selectAdminPage,
|
||||
makeSelectEnv,
|
||||
};
|
||||
|
||||
export default selectAdminPage;
|
||||
|
||||
@ -16,6 +16,7 @@ import cn from 'classnames';
|
||||
import PluginHeader from 'components/PluginHeader';
|
||||
import ListPlugins from 'components/ListPlugins';
|
||||
|
||||
import { makeSelectEnv } from 'containers/AdminPage/selectors';
|
||||
import injectSaga from 'utils/injectSaga';
|
||||
import injectReducer from 'utils/injectReducer';
|
||||
import { makeSelectPluginDeleteAction, makeSelectPlugins } from './selectors';
|
||||
@ -25,6 +26,12 @@ import saga from './saga';
|
||||
import styles from './styles.scss';
|
||||
|
||||
export class ListPluginsPage extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
||||
getChildContext = () => {
|
||||
return {
|
||||
appEnvironments: this.props.appEnvironments,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.getPlugins();
|
||||
}
|
||||
@ -65,7 +72,12 @@ export class ListPluginsPage extends React.Component { // eslint-disable-line re
|
||||
|
||||
ListPluginsPage.contextTypes = {};
|
||||
|
||||
ListPluginsPage.childContextTypes = {
|
||||
appEnvironments: PropTypes.array.isRequired,
|
||||
};
|
||||
|
||||
ListPluginsPage.propTypes = {
|
||||
appEnvironments: PropTypes.array.isRequired,
|
||||
getPlugins: PropTypes.func.isRequired,
|
||||
history: PropTypes.object.isRequired,
|
||||
onDeletePluginClick: PropTypes.func.isRequired,
|
||||
@ -75,6 +87,7 @@ ListPluginsPage.propTypes = {
|
||||
};
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
appEnvironments: makeSelectEnv(),
|
||||
pluginActionSucceeded: makeSelectPluginDeleteAction(),
|
||||
plugins: makeSelectPlugins(),
|
||||
});
|
||||
|
||||
@ -17,6 +17,11 @@ import styles from './styles.scss';
|
||||
class PluginInputFile extends React.PureComponent {
|
||||
state = { isDraging: false };
|
||||
|
||||
handleChange = (e) => {
|
||||
const dataTransfer = e.target;
|
||||
this.props.onDrop({ dataTransfer });
|
||||
}
|
||||
|
||||
handleDragEnter = () => this.setState({ isDraging: true });
|
||||
|
||||
handleDragLeave = () => this.setState({ isDraging: false });
|
||||
@ -30,7 +35,6 @@ class PluginInputFile extends React.PureComponent {
|
||||
render() {
|
||||
const {
|
||||
name,
|
||||
onChange,
|
||||
showLoader,
|
||||
} = this.props;
|
||||
const { isDraging } = this.state;
|
||||
@ -62,7 +66,7 @@ class PluginInputFile extends React.PureComponent {
|
||||
<input
|
||||
multiple
|
||||
name={name}
|
||||
onChange={onChange}
|
||||
onChange={this.handleChange}
|
||||
type="file"
|
||||
/>
|
||||
</label>
|
||||
@ -70,13 +74,10 @@ class PluginInputFile extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
PluginInputFile.defaultProps = {
|
||||
onChange: () => {},
|
||||
};
|
||||
PluginInputFile.defaultProps = {};
|
||||
|
||||
PluginInputFile.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
onChange: PropTypes.func,
|
||||
onDrop: PropTypes.func.isRequired,
|
||||
showLoader: PropTypes.bool.isRequired,
|
||||
};
|
||||
|
||||
@ -33,6 +33,7 @@ module.exports = async cb => {
|
||||
mime text,
|
||||
size text,
|
||||
url text,
|
||||
provider text,
|
||||
updated_at ${Model.client === 'pg' ? 'timestamp with time zone' : 'timestamp'},
|
||||
created_at ${Model.client === 'pg' ? 'timestamp with time zone' : 'timestamp'}
|
||||
);
|
||||
|
||||
@ -37,6 +37,11 @@
|
||||
"configurable": false,
|
||||
"required": true
|
||||
},
|
||||
"provider": {
|
||||
"type": "string",
|
||||
"configurable": false,
|
||||
"required": true
|
||||
},
|
||||
"related": {
|
||||
"collection": "*",
|
||||
"filter": "field",
|
||||
|
||||
@ -59,6 +59,8 @@ module.exports = {
|
||||
// Remove buffer to don't save it.
|
||||
delete file.buffer;
|
||||
|
||||
file.provider = provider.provider;
|
||||
|
||||
return await strapi.plugins['upload'].services.upload.add(file);
|
||||
})
|
||||
);
|
||||
@ -105,10 +107,12 @@ module.exports = {
|
||||
// get upload provider settings to configure the provider to use
|
||||
const provider = _.cloneDeep(_.find(strapi.plugins.upload.config.providers, {provider: config.provider}));
|
||||
_.assign(provider, config);
|
||||
const actions = provider.init(strapi, config);
|
||||
const actions = provider.init(config);
|
||||
|
||||
// execute delete function of the provider
|
||||
await actions.delete(file);
|
||||
if (file.provider === provider.provider) {
|
||||
await actions.delete(file);
|
||||
}
|
||||
|
||||
// Use Content Manager business logic to handle relation.
|
||||
if (strapi.plugins['content-manager']) {
|
||||
|
||||
@ -34,7 +34,7 @@ const loggerConfig = {
|
||||
|
||||
const pretty = pino.pretty({
|
||||
formatter: (logs, options) => {
|
||||
return `\u001b[90m[${new Date().toISOString()}] ${options.prefix.toLowerCase()} ${options.asColoredText(logs.level, logs.msg)}`;
|
||||
return `${options.asColoredText({ level: 10 }, `[${new Date().toISOString()}]`)} ${options.prefix.toLowerCase()} ${logs.msg}`;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user