Skip to content

Commit

Permalink
Merge branch 'main' into fix/content-manager-crash-on-nonstring-dynam…
Browse files Browse the repository at this point in the history
…icfield
  • Loading branch information
gitstart committed Dec 23, 2022
2 parents 791612b + 05be584 commit c078ac2
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 49 deletions.
6 changes: 0 additions & 6 deletions packages/core/admin/admin/src/components/GlobalStyle/index.js
@@ -1,11 +1,5 @@
import { createGlobalStyle } from 'styled-components';

const loadCss = async () => {
await import(/* webpackChunkName: "cropper-css" */ 'cropperjs/dist/cropper.css');
};

loadCss();

const GlobalStyle = createGlobalStyle`
body {
background: ${({ theme }) => theme.colors.neutral100};
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/package.json
Expand Up @@ -53,7 +53,7 @@
"@strapi/permissions": "4.5.4",
"@strapi/typescript-utils": "4.5.4",
"@strapi/utils": "4.5.4",
"axios": "0.27.2",
"axios": "1.2.1",
"babel-loader": "8.2.5",
"babel-plugin-styled-components": "2.0.2",
"bcryptjs": "2.4.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/helper-plugin/package.json
Expand Up @@ -39,7 +39,7 @@
"watch": "yarn create:index && cross-env NODE_ENV=development webpack-cli -w"
},
"dependencies": {
"axios": "0.27.2",
"axios": "1.2.1",
"date-fns": "2.29.3",
"formik": "^2.2.6",
"immer": "9.0.6",
Expand Down
5 changes: 5 additions & 0 deletions packages/core/strapi/lib/types/core/strapi/index.d.ts
Expand Up @@ -372,6 +372,11 @@ export interface Strapi {
*/
telemetry: any;

/**
* Used to access ctx from anywhere within the Strapi application
*/
requestContext: any;

/**
* Strapi DB layer instance
*/
Expand Down
Expand Up @@ -250,11 +250,11 @@ describe('BrowseStep', () => {
it('should render the table headers', () => {
usePersistentState.mockReturnValueOnce([viewOptions.LIST]);

const { getByText } = setup();
expect(getByText('preview')).toBeInTheDocument();
const { getByText, getByRole } = setup();
expect(getByRole('gridcell', { name: 'preview' })).toBeInTheDocument();
expect(getByText('name')).toBeInTheDocument();
expect(getByText('extension')).toBeInTheDocument();
expect(getByText('size')).toBeInTheDocument();
expect(getByRole('gridcell', { name: 'extension' })).toBeInTheDocument();
expect(getByRole('gridcell', { name: 'size' })).toBeInTheDocument();
expect(getByText('created')).toBeInTheDocument();
expect(getByText('last update')).toBeInTheDocument();
});
Expand Down
Expand Up @@ -27,6 +27,8 @@ import { AssetType, AssetDefinition } from '../../../constants';
import { AssetPreview } from './AssetPreview';
import { createAssetUrl } from '../../../utils';

import 'cropperjs/dist/cropper.css';

export const PreviewBox = ({
asset,
canUpdate,
Expand Down
16 changes: 8 additions & 8 deletions packages/core/upload/admin/src/components/TableList/index.js
Expand Up @@ -80,8 +80,8 @@ export const TableList = ({
}
key={key}
>
{isSortable ? (
<Tooltip label={sortLabel}>
<Tooltip label={isSortable ? sortLabel : tableHeaderLabel}>
{isSortable ? (
<Typography
onClick={() => handleClickSort(isSorted, name)}
as={isSorted ? 'span' : 'button'}
Expand All @@ -91,12 +91,12 @@ export const TableList = ({
>
{tableHeaderLabel}
</Typography>
</Tooltip>
) : (
<Typography textColor="neutral600" variant="sigma">
{tableHeaderLabel}
</Typography>
)}
) : (
<Typography textColor="neutral600" variant="sigma">
{tableHeaderLabel}
</Typography>
)}
</Tooltip>
</Th>
);
})}
Expand Down
Expand Up @@ -61,13 +61,13 @@ const ComponentFixture = (props) => {
const setup = (props) => render(<ComponentFixture {...props} />);

describe('TableList', () => {
it('should render table headers labels', () => {
const { getByText } = setup();
it.only('should render table headers labels', () => {
const { getByText, getByRole } = setup();

expect(getByText('preview')).toBeInTheDocument();
expect(getByRole('gridcell', { name: 'preview' })).toBeInTheDocument();
expect(getByText('name')).toBeInTheDocument();
expect(getByText('extension')).toBeInTheDocument();
expect(getByText('size')).toBeInTheDocument();
expect(getByRole('gridcell', { name: 'extension' })).toBeInTheDocument();
expect(getByRole('gridcell', { name: 'size' })).toBeInTheDocument();
expect(getByText('created')).toBeInTheDocument();
expect(getByText('last update')).toBeInTheDocument();
});
Expand Down
21 changes: 11 additions & 10 deletions packages/core/upload/admin/src/hooks/useUpload.js
Expand Up @@ -24,16 +24,17 @@ const uploadAsset = (asset, folderId, cancelToken, onProgress) => {
})
);

return axiosInstance({
method: 'post',
url: endpoint,
headers: {},
data: formData,
cancelToken: cancelToken.token,
onUploadProgress({ total, loaded }) {
onProgress((loaded / total) * 100);
},
}).then((res) => res.data);
return axiosInstance
.post(endpoint, formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
cancelToken: cancelToken.token,
onUploadProgress({ total, loaded }) {
onProgress((loaded / total) * 100);
},
})
.then((res) => res.data);
};

export const useUpload = () => {
Expand Down
Expand Up @@ -136,6 +136,7 @@ export const MediaLibrary = () => {
assetsData?.results?.map((asset) => ({ ...asset, type: 'asset', isSelectable: canUpdate })) ||
[];
const assetCount = assets?.length ?? 0;
const totalAssetCount = assetsData?.pagination?.total;

const isLoading = isCurrentFolderLoading || foldersLoading || permissionsLoading || assetsLoading;
const [showUploadAssetDialog, setShowUploadAssetDialog] = useState(false);
Expand Down Expand Up @@ -458,7 +459,7 @@ export const MediaLibrary = () => {
id: getTrad('list.assets.title'),
defaultMessage: 'Assets ({count})',
},
{ count: assetCount }
{ count: totalAssetCount }
)) ||
''
}
Expand Down
Expand Up @@ -559,11 +559,11 @@ describe('Media library homepage', () => {
it('should render the table headers', () => {
usePersistentState.mockReturnValueOnce([viewOptions.LIST]);

const { getByText } = renderML();
expect(getByText('preview')).toBeInTheDocument();
const { getByText, getByRole } = renderML();
expect(getByRole('gridcell', { name: 'preview' })).toBeInTheDocument();
expect(getByText('name')).toBeInTheDocument();
expect(getByText('extension')).toBeInTheDocument();
expect(getByText('size')).toBeInTheDocument();
expect(getByRole('gridcell', { name: 'extension' })).toBeInTheDocument();
expect(getByRole('gridcell', { name: 'size' })).toBeInTheDocument();
expect(getByText('created')).toBeInTheDocument();
expect(getByText('last update')).toBeInTheDocument();
});
Expand Down
6 changes: 4 additions & 2 deletions packages/core/upload/admin/src/utils/axiosInstance.js
Expand Up @@ -3,14 +3,16 @@ import { auth } from '@strapi/helper-plugin';

const instance = axios.create({
baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
});

instance.interceptors.request.use(
async (config) => {
config.headers = {
Authorization: `Bearer ${auth.getToken()}`,
Accept: 'application/json',
'Content-Type': 'application/json',
};

return config;
Expand Down
20 changes: 13 additions & 7 deletions yarn.lock
Expand Up @@ -7875,13 +7875,14 @@ axe-core@^4.4.3:
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.4.3.tgz#11c74d23d5013c0fa5d183796729bc3482bd2f6f"
integrity sha512-32+ub6kkdhhWick/UjvEwRchgoetXqTK14INLqbGm5U2TzBkBNF3nQtLYm8ovxSkQWArjEQvftCKryjZaATu3w==

axios@0.27.2:
version "0.27.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
axios@1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.2.1.tgz#44cf04a3c9f0c2252ebd85975361c026cb9f864a"
integrity sha512-I88cFiGu9ryt/tfVEi4kX2SITsvDddTajXTOFmt2uK1ZVA8LytjtdeyefdQWEf5PU8w+4SSJDoYnggflB5tW4A==
dependencies:
follow-redirects "^1.14.9"
follow-redirects "^1.15.0"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axios@^0.26.0:
version "0.26.1"
Expand Down Expand Up @@ -12012,11 +12013,16 @@ fn.name@1.x.x:
resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc"
integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==

follow-redirects@^1.0.0, follow-redirects@^1.14.8, follow-redirects@^1.14.9:
follow-redirects@^1.0.0, follow-redirects@^1.14.8:
version "1.15.1"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5"
integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==

follow-redirects@^1.15.0:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==

for-each@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
Expand Down Expand Up @@ -18881,7 +18887,7 @@ proxy-agent@^5.0.0:
proxy-from-env "^1.0.0"
socks-proxy-agent "^5.0.0"

proxy-from-env@^1.0.0:
proxy-from-env@^1.0.0, proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==
Expand Down

0 comments on commit c078ac2

Please sign in to comment.