Skip to content

Commit

Permalink
Merge pull request #13499 from strapi/features/ML-folder
Browse files Browse the repository at this point in the history
Media Library: Enable asset organization through folders
  • Loading branch information
gu-stav committed Jul 27, 2022
2 parents b18253f + 608c4e6 commit 46fdad0
Show file tree
Hide file tree
Showing 268 changed files with 20,866 additions and 3,788 deletions.
61 changes: 61 additions & 0 deletions examples/admin-development/.babelrc.json
@@ -0,0 +1,61 @@
{
"sourceType": "unambiguous",
"presets": [
[
"@babel/preset-env",
{
"shippedProposals": true,
"loose": true
}
],
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-transform-shorthand-properties",
"@babel/plugin-transform-block-scoping",
[
"@babel/plugin-proposal-decorators",
{
"legacy": true
}
],
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
],
[
"@babel/plugin-proposal-private-methods",
{
"loose": true
}
],
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-syntax-dynamic-import",
[
"@babel/plugin-proposal-object-rest-spread",
{
"loose": true,
"useBuiltIns": true
}
],
"@babel/plugin-transform-classes",
"@babel/plugin-transform-arrow-functions",
"@babel/plugin-transform-parameters",
"@babel/plugin-transform-destructuring",
"@babel/plugin-transform-spread",
"@babel/plugin-transform-for-of",
"babel-plugin-macros",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator",
[
"babel-plugin-polyfill-corejs3",
{
"method": "usage-global",
"absoluteImports": "core-js",
"version": "3.21.1"
}
]
]
}
15 changes: 15 additions & 0 deletions examples/admin-development/.storybook/main.js
@@ -0,0 +1,15 @@
module.exports = {
stories: [
'../*.stories.mdx',
'../../../packages/core/**/admin/src/**/*.stories.mdx',
'../../../packages/core/**/admin/src/**/*.stories.@(js|jsx|ts|tsx)',
'../../../packages/plugins/**/admin/src/**/*.stories.mdx',
'../../../packages/plugins/**/admin/src/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
framework: '@storybook/react',
};
27 changes: 27 additions & 0 deletions examples/admin-development/.storybook/preview.js
@@ -0,0 +1,27 @@
import { ThemeProvider, lightTheme } from '@strapi/design-system';
import { IntlProvider } from 'react-intl';
import { MemoryRouter } from 'react-router-dom';

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};

export const decorators = [
Story => (
<MemoryRouter>
<ThemeProvider theme={lightTheme}>
<IntlProvider messages={{}} textComponent="span" locale="en">
<main>
<Story />
</main>
</IntlProvider>
</ThemeProvider>
</MemoryRouter>
),
];
9 changes: 9 additions & 0 deletions examples/admin-development/Introduction.stories.mdx
@@ -0,0 +1,9 @@
import { Meta } from '@storybook/addon-docs';

<Meta title="Introduction" />

# Welcome to the documentation

Use this app to develop local components in plugins.

To do so just create a story in your plugins `./admin/src` folder
42 changes: 42 additions & 0 deletions examples/admin-development/package.json
@@ -0,0 +1,42 @@
{
"name": "admin-development",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.16.7",
"@babel/plugin-proposal-class-properties": "7.16.7",
"@babel/plugin-proposal-decorators": "7.16.7",
"@babel/plugin-proposal-export-default-from": "7.16.7",
"@babel/plugin-proposal-nullish-coalescing-operator": "7.16.7",
"@babel/plugin-proposal-object-rest-spread": "7.16.7",
"@babel/plugin-proposal-optional-chaining": "7.16.7",
"@babel/plugin-proposal-private-methods": "7.16.7",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/plugin-transform-arrow-functions": "7.16.7",
"@babel/plugin-transform-block-scoping": "7.16.7",
"@babel/plugin-transform-classes": "7.16.7",
"@babel/plugin-transform-destructuring": "7.17.7",
"@babel/plugin-transform-for-of": "7.16.7",
"@babel/plugin-transform-parameters": "7.16.7",
"@babel/plugin-transform-shorthand-properties": "7.16.7",
"@babel/plugin-transform-spread": "7.16.7",
"@babel/preset-env": "7.16.11",
"@babel/preset-typescript": "7.16.7",
"@storybook/addon-actions": "6.4.10",
"@storybook/addon-essentials": "6.4.10",
"@storybook/addon-interactions": "6.4.10",
"@storybook/addon-links": "6.4.10",
"@storybook/react": "^6.3.7",
"@storybook/testing-library": "^0.0.9",
"babel-loader": "^8.2.4",
"babel-plugin-macros": "3.1.0",
"babel-plugin-polyfill-corejs3": "0.5.2",
"core-js": "3.21.1"
},
"dependencies": {},
"scripts": {
"storybook": "start-storybook -p 6007",
"build-storybook": "build-storybook"
}
}
2 changes: 1 addition & 1 deletion examples/getstarted/config/src/cron-tasks.js
Expand Up @@ -17,7 +17,7 @@ module.exports = {
*/
// '0 0 1 * * 1': async function({ strapi }) {
// // Add your own logic here (e.g. send a queue of email, create a database backup, etc.).
// }
// },
// 'myJob': {
// task: ({ strapi }) => { /* Add your own logic here */ },
// options: {
Expand Down
Expand Up @@ -38,23 +38,6 @@
"localized": true
}
}
},
"description": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "string",
"maxLength": 3
},
"time": {
"pluginOptions": {
"i18n": {
"localized": true
}
},
"type": "time"
}
}
}
Expand Up @@ -15,12 +15,12 @@ import {
useOverlayBlocker,
useTracking,
getYupInnerErrors,
getAPIInnerErrors,
} from '@strapi/helper-plugin';

import { getTrad, removeKeyInObject } from '../../utils';
import reducer, { initialState } from './reducer';
import { cleanData, createYupSchema } from './utils';
import { getAPIInnerError } from './utils/getAPIInnerError';

const EditViewDataManagerProvider = ({
allLayoutData,
Expand Down Expand Up @@ -311,7 +311,7 @@ const EditViewDataManagerProvider = ({
} catch (err) {
errors = {
...errors,
...getAPIInnerError(err),
...getAPIInnerErrors(err, { getTrad }),
};
}

Expand Down Expand Up @@ -347,7 +347,7 @@ const EditViewDataManagerProvider = ({
} catch (err) {
errors = {
...errors,
...getAPIInnerError(err),
...getAPIInnerErrors(err, { getTrad }),
};
}

Expand Down
Expand Up @@ -2,7 +2,8 @@ import React, { memo } from 'react';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import isEmpty from 'lodash/isEmpty';
import Select, { createFilter } from 'react-select';
import { createFilter } from 'react-select';
import { ReactSelect as Select } from '@strapi/helper-plugin';
import { Box } from '@strapi/design-system/Box';
import { Stack } from '@strapi/design-system/Stack';
import { Typography } from '@strapi/design-system/Typography';
Expand All @@ -24,7 +25,6 @@ function SelectMany({
options,
placeholder,
searchToPersist,
styles,
targetModel,
value,
description,
Expand Down Expand Up @@ -72,7 +72,6 @@ function SelectMany({
placeholder={formatMessage(
placeholder || { id: 'global.select', defaultMessage: 'Select...' }
)}
styles={styles}
value={[]}
/>
<Box paddingTop={3} style={{ overflow: 'auto' }}>
Expand Down Expand Up @@ -138,7 +137,6 @@ SelectMany.propTypes = {
defaultMessage: PropTypes.string.isRequired,
}),
searchToPersist: PropTypes.string,
styles: PropTypes.object.isRequired,
targetModel: PropTypes.string.isRequired,
value: PropTypes.array,
description: PropTypes.string,
Expand Down
Expand Up @@ -2,7 +2,7 @@ import React, { useCallback, useState, useEffect, useMemo, memo } from 'react';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import { useLocation } from 'react-router-dom';
import { useTheme } from 'styled-components';
import { Stack } from '@strapi/design-system/Stack';
import findIndex from 'lodash/findIndex';
import get from 'lodash/get';
import isArray from 'lodash/isArray';
Expand All @@ -16,18 +16,13 @@ import {
} from '@strapi/helper-plugin';
import { stringify } from 'qs';
import axios from 'axios';
import { Stack } from '@strapi/design-system/Stack';
import { axiosInstance } from '../../../core/utils';
import { getTrad } from '../../utils';
import Label from './Label';
import SelectOne from '../SelectOne';
import SelectMany from '../SelectMany';
import ClearIndicator from './ClearIndicator';
import DropdownIndicator from './DropdownIndicator';
import IndicatorSeparator from './IndicatorSeparator';
import Option from './Option';
import { connect, select } from './utils';
import getSelectStyles from './utils/getSelectStyles';

const initialPaginationState = {
contains: '',
Expand Down Expand Up @@ -77,7 +72,6 @@ function SelectWrapper({
onRemoveRelation,
} = useCMEditViewDataManager();
const { pathname } = useLocation();
const theme = useTheme();

const value = get(modifiedData, name, null);
const [state, setState] = useState(initialPaginationState);
Expand Down Expand Up @@ -278,8 +272,6 @@ function SelectWrapper({
return <NotAllowedInput intlLabel={intlLabel} labelAction={labelAction} />;
}

const styles = getSelectStyles(theme);

return (
<Stack spacing={1}>
<Label
Expand All @@ -293,9 +285,6 @@ function SelectWrapper({
<Component
addRelation={handleAddRelation}
components={{
ClearIndicator,
DropdownIndicator,
IndicatorSeparator,
Option,
}}
displayNavigationLink={shouldDisplayRelationLink}
Expand All @@ -315,7 +304,6 @@ function SelectWrapper({
onRemove={onRemoveRelation}
placeholder={placeholder}
searchToPersist={searchToPersist}
styles={styles}
targetModel={targetModel}
value={value}
description={description}
Expand Down
1 change: 1 addition & 0 deletions packages/core/admin/admin/src/translations/en.json
Expand Up @@ -758,6 +758,7 @@
"notification.success.title": "Success:",
"notification.version.update.message": "A new version of Strapi is available!",
"notification.warning.title": "Warning:",
"notification.warning.404": "404 - Not found",
"or": "OR",
"request.error.model.unknown": "This model doesn't exist",
"skipToContent": "Skip to content",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/package.json
Expand Up @@ -113,7 +113,7 @@
"react-error-boundary": "3.1.1",
"react-fast-compare": "^3.2.0",
"react-helmet": "^6.1.0",
"react-intl": "6.0.5",
"react-intl": "5.20.2",
"react-query": "3.24.3",
"react-redux": "7.2.8",
"react-refresh": "0.11.0",
Expand Down
Expand Up @@ -22,7 +22,7 @@ module.exports = {

const permissionQuery = permissionChecker.buildReadQuery(query);

const { results, pagination } = await entityManager.findWithRelationCounts(
const { results, pagination } = await entityManager.findWithRelationCountsPage(
permissionQuery,
model
);
Expand Down
Expand Up @@ -2,7 +2,7 @@ interface EntityManager {
assocCreatorRoles(): any;
find(): any;
findPage(): any;
findWithRelationCounts(): any;
findWithRelationCountsPage(): any;
count(): any;
findOne(): any;
findOneWithCreatorRoles(): any;
Expand Down
Expand Up @@ -143,11 +143,11 @@ module.exports = ({ strapi }) => ({
return strapi.entityService.findPage(uid, params);
},

findWithRelationCounts(opts, uid, populate) {
findWithRelationCountsPage(opts, uid, populate) {
const counterPopulate = addCreatedByRolesPopulate(getCounterPopulate(uid, populate));
const params = { ...opts, populate: counterPopulate };

return strapi.entityService.findWithRelationCounts(uid, params);
return strapi.entityService.findWithRelationCountsPage(uid, params);
},

async findOne(id, uid, populate) {
Expand Down
Expand Up @@ -92,17 +92,20 @@ describe('Test type date', () => {
});

test('Updating entry sets the right value and format JSON', async () => {
const now = '2018-08-05';

const res = await rq.post('/content-manager/collection-types/api::withdate.withdate', {
body: {
field: '2018-06-05',
field: now,
},
});

const newDate = '2017-11-23';
const updateRes = await rq.put(
`/content-manager/collection-types/api::withdate.withdate/${res.body.id}`,
{
body: {
field: '2017-11-23',
field: newDate,
},
}
);
Expand Down

0 comments on commit 46fdad0

Please sign in to comment.