mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
Merge branch 'develop' into fix/cannot-create-component-from-dz
This commit is contained in:
commit
23d22ae5fc
@ -7,7 +7,7 @@ As of September 2024 (and until this document is updated), only the v4.x.x and v
|
||||
**Note**: The v4.x.x LTS version will only receive high/critical severity fixes until April 2026. Any Medium/Low severity issues will not be fixed unless specific exceptions are made.
|
||||
|
||||
| Version | Release Tag | Support Starts | Support Ends | Security Updates Until | Notes |
|
||||
|---------|-------------|----------------|----------------|------------------------|--------------------------------|
|
||||
| ------- | ----------- | -------------- | -------------- | ---------------------- | ------------------------------ |
|
||||
| 5.x.x | GA / Stable | September 2024 | Further Notice | Further Notice | LTS |
|
||||
| 5.x.x | RC | N/A | September 2024 | N/A | Not Supported |
|
||||
| 5.x.x | Beta | N/A | N/A | N/A | Not Supported |
|
||||
|
||||
@ -148,7 +148,7 @@
|
||||
"stream-chain": "2.2.5",
|
||||
"stream-json": "1.8.0",
|
||||
"supertest": "6.3.3",
|
||||
"tar": "6.1.13",
|
||||
"tar": "6.2.1",
|
||||
"ts-jest": "29.1.0",
|
||||
"typescript": "5.3.2",
|
||||
"yalc": "1.0.0-pre.53",
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
"open": "8.4.0",
|
||||
"ora": "5.4.1",
|
||||
"pkg-up": "3.1.0",
|
||||
"tar": "6.1.13",
|
||||
"tar": "6.2.1",
|
||||
"xdg-app-paths": "8.3.0",
|
||||
"yup": "0.32.9"
|
||||
},
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
"semver": "7.5.4",
|
||||
"stream-chain": "2.2.5",
|
||||
"stream-json": "1.8.0",
|
||||
"tar": "6.1.13",
|
||||
"tar": "6.2.1",
|
||||
"tar-stream": "2.2.0",
|
||||
"ws": "8.17.1"
|
||||
},
|
||||
|
||||
12
packages/core/upload/admin/.eslintrc
Normal file
12
packages/core/upload/admin/.eslintrc
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"root": true,
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["**/*.js", "**/*.jsx"],
|
||||
"extends": ["custom/front"],
|
||||
"rules": {
|
||||
"import/extensions": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,8 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import { useQueryParams } from '@strapi/admin/strapi-admin';
|
||||
import { Loader } from '@strapi/design-system';
|
||||
import { CrumbSimpleMenu, MenuItem } from '@strapi/design-system';
|
||||
import { CrumbSimpleMenu, Loader, MenuItem } from '@strapi/design-system';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { NavLink, useLocation } from 'react-router-dom';
|
||||
|
||||
@ -19,7 +19,7 @@ const ComponentFixture = ({ to, ...props }) => {
|
||||
<FolderCard
|
||||
id={ID_FIXTURE}
|
||||
ariaLabel="Folder 1"
|
||||
startAction={<></>}
|
||||
startAction={null}
|
||||
onClick={() => {}}
|
||||
to={to}
|
||||
{...props}
|
||||
|
||||
@ -5,7 +5,12 @@ import set from 'lodash/set';
|
||||
import { ON_CHANGE, SET_LOADED } from './actionTypes';
|
||||
import { init, initialState } from './init';
|
||||
|
||||
const reducer = (state = initialState, action) =>
|
||||
const reducer = (
|
||||
state = initialState,
|
||||
action = {
|
||||
type: '',
|
||||
}
|
||||
) =>
|
||||
// eslint-disable-next-line consistent-return
|
||||
produce(state, (draftState) => {
|
||||
switch (action.type) {
|
||||
|
||||
@ -6,6 +6,7 @@ import getTrad from './getTrad';
|
||||
export const urlSchema = yup.object().shape({
|
||||
urls: yup.string().test({
|
||||
name: 'isUrlValid',
|
||||
// eslint-disable-next-line no-template-curly-in-string
|
||||
message: '${path}',
|
||||
test(values = '') {
|
||||
const urls = values.split(/\r?\n/);
|
||||
|
||||
@ -1,6 +1,13 @@
|
||||
import { rest } from 'msw';
|
||||
import qs from 'qs';
|
||||
|
||||
// Define the expected structure of your query parameters
|
||||
interface CustomQuery extends qs.ParsedQs {
|
||||
filters?: {
|
||||
$and?: Array<{ parent: { id: string } }>;
|
||||
};
|
||||
}
|
||||
|
||||
const handlers = [
|
||||
rest.get('/upload/configuration', async (req, res, ctx) => {
|
||||
return res(
|
||||
@ -48,7 +55,7 @@ const handlers = [
|
||||
);
|
||||
}),
|
||||
rest.get('/upload/folders', async (req, res, ctx) => {
|
||||
const query = qs.parse(req.url.search.slice(1));
|
||||
const query: CustomQuery = qs.parse(req.url.search.slice(1));
|
||||
|
||||
if (query._q) {
|
||||
return res(
|
||||
@ -183,13 +190,13 @@ const handlers = [
|
||||
}),
|
||||
|
||||
rest.get('*/an-image.png', (req, res, ctx) =>
|
||||
res(ctx.set('Content-Type', 'image/png'), ctx.body())
|
||||
res(ctx.set('Content-Type', 'image/png'), ctx.body('Successful response'))
|
||||
),
|
||||
rest.get('*/a-pdf.pdf', (req, res, ctx) =>
|
||||
res(ctx.set('Content-Type', 'application/pdf'), ctx.body())
|
||||
res(ctx.set('Content-Type', 'application/pdf'), ctx.body('Successful response'))
|
||||
),
|
||||
rest.get('*/a-video.mp4', (req, res, ctx) =>
|
||||
res(ctx.set('Content-Type', 'video/mp4'), ctx.body())
|
||||
res(ctx.set('Content-Type', 'video/mp4'), ctx.body('Successful response'))
|
||||
),
|
||||
rest.get('*/not-working-like-cors.lutin', (req, res, ctx) => res(ctx.json({}))),
|
||||
rest.get('*/some-where-not-existing.jpg', (req, res) => res.networkError('Failed to fetch')),
|
||||
10
packages/core/upload/admin/tsconfig.build.json
Normal file
10
packages/core/upload/admin/tsconfig.build.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "tsconfig/client.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "../",
|
||||
"baseUrl": ".",
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": ["./src", "../shared", "../package.json"],
|
||||
"exclude": ["**/__mocks__", "./src/**/tests", "**/*.test.*"]
|
||||
}
|
||||
11
packages/core/upload/admin/tsconfig.json
Normal file
11
packages/core/upload/admin/tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "tsconfig/client.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "../",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@tests/*": ["./tests/*"]
|
||||
}
|
||||
},
|
||||
"include": ["../package.json", "./src", "../shared", "./tests"]
|
||||
}
|
||||
@ -6,5 +6,5 @@ module.exports = {
|
||||
moduleNameMapper: {
|
||||
'^@tests/(.*)$': '<rootDir>/admin/tests/$1',
|
||||
},
|
||||
setupFilesAfterEnv: ['./admin/tests/setup.js'],
|
||||
setupFilesAfterEnv: ['./admin/tests/setup.ts'],
|
||||
};
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@tests/*": ["./admin/tests/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,11 +17,19 @@
|
||||
],
|
||||
"exports": {
|
||||
"./strapi-admin": {
|
||||
"types": "./dist/admin/src/index.d.ts",
|
||||
"source": "./admin/src/index.js",
|
||||
"import": "./dist/admin/index.mjs",
|
||||
"require": "./dist/admin/index.js",
|
||||
"default": "./dist/admin/index.js"
|
||||
},
|
||||
"./_internal/shared": {
|
||||
"types": "./dist/shared/index.d.ts",
|
||||
"source": "./shared/index.ts",
|
||||
"import": "./dist/shared/index.mjs",
|
||||
"require": "./dist/shared/index.js",
|
||||
"default": "./dist/shared/index.js"
|
||||
},
|
||||
"./strapi-server": {
|
||||
"types": "./dist/server/src/index.d.ts",
|
||||
"source": "./server/src/index.ts",
|
||||
@ -41,6 +49,9 @@
|
||||
"lint": "run -T eslint .",
|
||||
"test:front": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js",
|
||||
"test:unit": "run -T jest",
|
||||
"test:ts:back": "run -T tsc --noEmit -p server/tsconfig.json",
|
||||
"test:ts:front": "run -T tsc -p admin/tsconfig.json",
|
||||
"test:front:watch": "run -T cross-env IS_EE=true jest --config ./jest.config.front.js --watch",
|
||||
"test:unit:watch": "run -T jest --watch",
|
||||
"watch": "pack-up watch"
|
||||
},
|
||||
|
||||
@ -3,9 +3,11 @@ import { Config, defineConfig } from '@strapi/pack-up';
|
||||
const config: Config = defineConfig({
|
||||
bundles: [
|
||||
{
|
||||
source: './admin/src/index.js',
|
||||
types: './dist/admin/src/index.d.ts',
|
||||
source: './admin/src/index.js', // TODO: change it with the .ts file
|
||||
import: './dist/admin/index.mjs',
|
||||
require: './dist/admin/index.js',
|
||||
tsconfig: './admin/tsconfig.build.json',
|
||||
runtime: 'web',
|
||||
},
|
||||
{
|
||||
|
||||
@ -25,6 +25,7 @@ export async function bootstrap({ strapi }: { strapi: Core.Strapi }) {
|
||||
config &&
|
||||
Object.keys(defaultValue).every((key) => Object.prototype.hasOwnProperty.call(config, key))
|
||||
) {
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ const validateStructureMoveManyFoldersFilesSchema = yup
|
||||
|
||||
const validateDuplicatesMoveManyFoldersFilesSchema = yup
|
||||
.object()
|
||||
.test('are-folders-unique', 'some folders already exist', async function (value) {
|
||||
.test('are-folders-unique', 'some folders already exist', async function areFoldersUnique(value) {
|
||||
const { folderIds, destinationFolderId } = value;
|
||||
if (isEmpty(folderIds)) return true;
|
||||
|
||||
@ -58,7 +58,7 @@ const validateMoveFoldersNotInsideThemselvesSchema = yup
|
||||
.test(
|
||||
'dont-move-inside-self',
|
||||
'folders cannot be moved inside themselves or one of its children',
|
||||
async function (value) {
|
||||
async function validateMoveFoldersNotInsideThemselves(value) {
|
||||
const { folderIds, destinationFolderId } = value;
|
||||
if (destinationFolderId === null || isEmpty(folderIds)) return true;
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ const getFileData = (filePath: string) => ({
|
||||
alternativeText: 'image.png',
|
||||
caption: 'image.png',
|
||||
ext: '.png',
|
||||
folder: null,
|
||||
folder: undefined,
|
||||
folderPath: '/',
|
||||
filepath: filePath,
|
||||
getStream: () => fs.createReadStream(filePath),
|
||||
@ -56,6 +56,7 @@ const getFileData = (filePath: string) => ({
|
||||
size: 4,
|
||||
width: 1500,
|
||||
tmpWorkingDirectory,
|
||||
name: 'image.png',
|
||||
});
|
||||
|
||||
describe('Upload image', () => {
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import type { UID } from '@strapi/types';
|
||||
import { signEntityMedia } from '../utils';
|
||||
import { getService } from '../../../utils';
|
||||
|
||||
jest.mock('../../../utils');
|
||||
|
||||
describe('Upload | extensions | entity-manager', () => {
|
||||
const modelUID = 'model';
|
||||
const modelUID = 'model' as UID.Schema;
|
||||
const componentUID = 'component';
|
||||
|
||||
const models = {
|
||||
@ -71,6 +72,18 @@ describe('Upload | extensions | entity-manager', () => {
|
||||
spySignFileUrls = jest.fn();
|
||||
jest.mocked(getService).mockImplementation(() => ({
|
||||
signFileUrls: spySignFileUrls,
|
||||
getFolderPath: jest.fn(),
|
||||
deleteByIds: jest.fn(),
|
||||
computeMetrics: jest.fn().mockResolvedValue({
|
||||
assetNumber: 0,
|
||||
folderNumber: 0,
|
||||
averageDepth: 0,
|
||||
maxDepth: 0,
|
||||
averageDeviationDepth: 0,
|
||||
}),
|
||||
sendMetrics: jest.fn().mockResolvedValue(undefined),
|
||||
ensureWeeklyStoredCronSchedule: jest.fn().mockResolvedValue(undefined),
|
||||
registerCron: jest.fn().mockResolvedValue(undefined),
|
||||
}));
|
||||
|
||||
global.strapi = {
|
||||
|
||||
@ -5,6 +5,11 @@ const { factory } = require('typescript');
|
||||
const { models } = require('../common');
|
||||
const { emitDefinitions, format, generateSharedExtensionDefinition } = require('../utils');
|
||||
|
||||
const NO_COMPONENT_PLACEHOLDER_COMMENT = `/*
|
||||
* The app doesn't have any components yet.
|
||||
*/
|
||||
`;
|
||||
|
||||
/**
|
||||
* Generate type definitions for Strapi Components
|
||||
*
|
||||
@ -23,6 +28,12 @@ const generateComponentsDefinitions = async (options = {}) => {
|
||||
definition: models.schema.generateSchemaDefinition(contentType),
|
||||
}));
|
||||
|
||||
options.logger.debug(`Found ${componentsDefinitions.length} components.`);
|
||||
|
||||
if (componentsDefinitions.length === 0) {
|
||||
return { output: NO_COMPONENT_PLACEHOLDER_COMMENT, stats: {} };
|
||||
}
|
||||
|
||||
const formattedSchemasDefinitions = componentsDefinitions.reduce((acc, def) => {
|
||||
acc.push(
|
||||
// Definition
|
||||
|
||||
@ -5,6 +5,11 @@ const { factory } = require('typescript');
|
||||
const { models } = require('../common');
|
||||
const { emitDefinitions, format, generateSharedExtensionDefinition } = require('../utils');
|
||||
|
||||
const NO_CONTENT_TYPE_PLACEHOLDER_COMMENT = `/*
|
||||
* The app doesn't have any content-types yet.
|
||||
*/
|
||||
`;
|
||||
|
||||
/**
|
||||
* Generate type definitions for Strapi Content-Types
|
||||
*
|
||||
@ -23,6 +28,12 @@ const generateContentTypesDefinitions = async (options = {}) => {
|
||||
definition: models.schema.generateSchemaDefinition(contentType),
|
||||
}));
|
||||
|
||||
options.logger.debug(`Found ${contentTypesDefinitions.length} content-types.`);
|
||||
|
||||
if (contentTypesDefinitions.length === 0) {
|
||||
return { output: NO_CONTENT_TYPE_PLACEHOLDER_COMMENT, stats: {} };
|
||||
}
|
||||
|
||||
const formattedSchemasDefinitions = contentTypesDefinitions.reduce((acc, def) => {
|
||||
acc.push(
|
||||
// Definition
|
||||
|
||||
16
yarn.lock
16
yarn.lock
@ -8471,7 +8471,7 @@ __metadata:
|
||||
open: "npm:8.4.0"
|
||||
ora: "npm:5.4.1"
|
||||
pkg-up: "npm:3.1.0"
|
||||
tar: "npm:6.1.13"
|
||||
tar: "npm:6.2.1"
|
||||
tsconfig: "workspace:*"
|
||||
xdg-app-paths: "npm:8.3.0"
|
||||
yup: "npm:0.32.9"
|
||||
@ -8745,7 +8745,7 @@ __metadata:
|
||||
semver: "npm:7.5.4"
|
||||
stream-chain: "npm:2.2.5"
|
||||
stream-json: "npm:1.8.0"
|
||||
tar: "npm:6.1.13"
|
||||
tar: "npm:6.2.1"
|
||||
tar-stream: "npm:2.2.0"
|
||||
typescript: "npm:5.3.2"
|
||||
ws: "npm:8.17.1"
|
||||
@ -29830,7 +29830,7 @@ __metadata:
|
||||
stream-chain: "npm:2.2.5"
|
||||
stream-json: "npm:1.8.0"
|
||||
supertest: "npm:6.3.3"
|
||||
tar: "npm:6.1.13"
|
||||
tar: "npm:6.2.1"
|
||||
ts-jest: "npm:29.1.0"
|
||||
typescript: "npm:5.3.2"
|
||||
yalc: "npm:1.0.0-pre.53"
|
||||
@ -30481,17 +30481,17 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tar@npm:6.1.13":
|
||||
version: 6.1.13
|
||||
resolution: "tar@npm:6.1.13"
|
||||
"tar@npm:6.2.1":
|
||||
version: 6.2.1
|
||||
resolution: "tar@npm:6.2.1"
|
||||
dependencies:
|
||||
chownr: "npm:^2.0.0"
|
||||
fs-minipass: "npm:^2.0.0"
|
||||
minipass: "npm:^4.0.0"
|
||||
minipass: "npm:^5.0.0"
|
||||
minizlib: "npm:^2.1.1"
|
||||
mkdirp: "npm:^1.0.3"
|
||||
yallist: "npm:^4.0.0"
|
||||
checksum: 10c0/eee5f264f3f3c27cd8d4934f80c568470f92811c416144ab671bb36b45a8ed55fbfbbd31f0146f3eddaca91fd564c9a7ec4d2086940968b836f4a2c54146c060
|
||||
checksum: 10c0/a5eca3eb50bc11552d453488344e6507156b9193efd7635e98e867fab275d527af53d8866e2370cd09dfe74378a18111622ace35af6a608e5223a7d27fe99537
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user