mirror of
https://github.com/strapi/strapi.git
synced 2025-09-16 20:10:05 +00:00
Merge pull request #13610 from strapi/ML-folder/remove-form-notifications
[ML Folder] Remove error notifications + trad fixes
This commit is contained in:
commit
1ae17aacdf
@ -15,7 +15,7 @@ export const SelectedStep = ({ selectedAssets, onSelectAsset, onReorderAsset })
|
|||||||
<Typography variant="pi" fontWeight="bold" textColor="neutral800">
|
<Typography variant="pi" fontWeight="bold" textColor="neutral800">
|
||||||
{formatMessage(
|
{formatMessage(
|
||||||
{
|
{
|
||||||
id: getTrad('list.assets.selected'),
|
id: getTrad('list.assets.to-upload'),
|
||||||
defaultMessage:
|
defaultMessage:
|
||||||
'{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload',
|
'{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload',
|
||||||
},
|
},
|
||||||
|
@ -110,12 +110,8 @@ export const BulkMoveDialog = ({ onClose, selected }) => {
|
|||||||
name="destination"
|
name="destination"
|
||||||
menuPortalTarget={document.querySelector('body')}
|
menuPortalTarget={document.querySelector('body')}
|
||||||
inputId="folder-destination"
|
inputId="folder-destination"
|
||||||
{...(errors.destination
|
error={errors?.destination}
|
||||||
? {
|
ariaErrorMessage="destination-error"
|
||||||
'aria-errormessage': 'folder-destination-error',
|
|
||||||
'aria-invalid': true,
|
|
||||||
}
|
|
||||||
: {})}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{errors.destination && (
|
{errors.destination && (
|
||||||
|
@ -271,12 +271,8 @@ export const EditAssetDialog = ({
|
|||||||
menuPortalTarget={document.querySelector('body')}
|
menuPortalTarget={document.querySelector('body')}
|
||||||
inputId="asset-folder"
|
inputId="asset-folder"
|
||||||
disabled={formDisabled}
|
disabled={formDisabled}
|
||||||
{...(errors.parent
|
error={errors?.parent}
|
||||||
? {
|
ariaErrorMessage="folder-parent-error"
|
||||||
'aria-errormessage': 'folder-parent-error',
|
|
||||||
'aria-invalid': true,
|
|
||||||
}
|
|
||||||
: {})}
|
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
@ -78,7 +78,7 @@ export const PendingAssetStep = ({
|
|||||||
<Typography variant="pi" fontWeight="bold" textColor="neutral800">
|
<Typography variant="pi" fontWeight="bold" textColor="neutral800">
|
||||||
{formatMessage(
|
{formatMessage(
|
||||||
{
|
{
|
||||||
id: getTrad('list.assets.selected'),
|
id: getTrad('list.assets.to-upload'),
|
||||||
defaultMessage:
|
defaultMessage:
|
||||||
'{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload',
|
'{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload',
|
||||||
},
|
},
|
||||||
|
@ -12,18 +12,27 @@ export const AssetSource = {
|
|||||||
Computer: 'computer',
|
Computer: 'computer',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ParentFolderDefinition = PropTypes.shape({
|
||||||
|
id: PropTypes.number.isRequired,
|
||||||
|
createdAt: PropTypes.string.isRequired,
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
updatedAt: PropTypes.string.isRequired,
|
||||||
|
pathId: PropTypes.number.isRequired,
|
||||||
|
path: PropTypes.string.isRequired,
|
||||||
|
});
|
||||||
|
|
||||||
export const FolderDefinition = PropTypes.shape({
|
export const FolderDefinition = PropTypes.shape({
|
||||||
id: PropTypes.number.isRequired,
|
id: PropTypes.number.isRequired,
|
||||||
children: PropTypes.shape({
|
children: PropTypes.shape({
|
||||||
count: PropTypes.number.isRequired,
|
count: PropTypes.number.isRequired,
|
||||||
}).isRequired,
|
}),
|
||||||
createdAt: PropTypes.string.isRequired,
|
createdAt: PropTypes.string.isRequired,
|
||||||
createdBy: PropTypes.shape(),
|
createdBy: PropTypes.shape(),
|
||||||
files: PropTypes.shape({
|
files: PropTypes.shape({
|
||||||
count: PropTypes.number.isRequired,
|
count: PropTypes.number.isRequired,
|
||||||
}).isRequired,
|
}),
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
parent: PropTypes.number,
|
parent: PropTypes.oneOf([ParentFolderDefinition, PropTypes.number]),
|
||||||
updatedAt: PropTypes.string.isRequired,
|
updatedAt: PropTypes.string.isRequired,
|
||||||
updatedBy: PropTypes.shape(),
|
updatedBy: PropTypes.shape(),
|
||||||
pathId: PropTypes.number.isRequired,
|
pathId: PropTypes.number.isRequired,
|
||||||
|
@ -177,40 +177,4 @@ describe('useEditFolder', () => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('calls toggleNotification in case of an error', async () => {
|
|
||||||
const originalConsoleError = console.error;
|
|
||||||
console.error = jest.fn();
|
|
||||||
|
|
||||||
axiosInstance.put.mockRejectedValue({ message: 'err-test' });
|
|
||||||
|
|
||||||
const toggleNotification = useNotification();
|
|
||||||
const {
|
|
||||||
result: { current },
|
|
||||||
waitFor,
|
|
||||||
} = await setup();
|
|
||||||
const { editFolder } = current;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await act(async () => {
|
|
||||||
await editFolder(
|
|
||||||
{
|
|
||||||
name: FOLDER_EDIT_FIXTURE.name,
|
|
||||||
parent: FOLDER_EDIT_FIXTURE.parent,
|
|
||||||
},
|
|
||||||
FOLDER_EDIT_FIXTURE.id
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
await waitFor(() =>
|
|
||||||
expect(toggleNotification).toHaveBeenCalledWith(
|
|
||||||
expect.objectContaining({ message: 'err-test' })
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
console.error = originalConsoleError;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -49,9 +49,6 @@ export const useBulkMove = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError: error => {
|
|
||||||
toggleNotification({ type: 'warning', message: error.message });
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const move = (destinationFolderId, filesAndFolders) =>
|
const move = (destinationFolderId, filesAndFolders) =>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { useMutation, useQueryClient } from 'react-query';
|
import { useMutation, useQueryClient } from 'react-query';
|
||||||
import { useNotification } from '@strapi/helper-plugin';
|
|
||||||
|
|
||||||
import pluginId from '../pluginId';
|
import pluginId from '../pluginId';
|
||||||
import { axiosInstance, getRequestUrl } from '../utils';
|
import { axiosInstance, getRequestUrl } from '../utils';
|
||||||
@ -13,7 +12,6 @@ const editFolderRequest = ({ attrs, id }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useEditFolder = () => {
|
export const useEditFolder = () => {
|
||||||
const toggleNotification = useNotification();
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const mutation = useMutation((...args) => editFolderRequest(...args), {
|
const mutation = useMutation((...args) => editFolderRequest(...args), {
|
||||||
@ -21,9 +19,6 @@ export const useEditFolder = () => {
|
|||||||
queryClient.refetchQueries([pluginId, 'folders'], { active: true });
|
queryClient.refetchQueries([pluginId, 'folders'], { active: true });
|
||||||
queryClient.refetchQueries([pluginId, 'folder', 'structure'], { active: true });
|
queryClient.refetchQueries([pluginId, 'folder', 'structure'], { active: true });
|
||||||
},
|
},
|
||||||
onError: reason => {
|
|
||||||
toggleNotification({ type: 'warning', message: reason.message });
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const editFolder = (attrs, id) => mutation.mutateAsync({ attrs, id });
|
const editFolder = (attrs, id) => mutation.mutateAsync({ attrs, id });
|
||||||
|
@ -87,7 +87,7 @@ Header.defaultProps = {
|
|||||||
Header.propTypes = {
|
Header.propTypes = {
|
||||||
assetCount: PropTypes.number.isRequired,
|
assetCount: PropTypes.number.isRequired,
|
||||||
canCreate: PropTypes.bool.isRequired,
|
canCreate: PropTypes.bool.isRequired,
|
||||||
folder: PropTypes.shape(FolderDefinition),
|
folder: FolderDefinition,
|
||||||
folderCount: PropTypes.number.isRequired,
|
folderCount: PropTypes.number.isRequired,
|
||||||
onToggleEditFolderDialog: PropTypes.func.isRequired,
|
onToggleEditFolderDialog: PropTypes.func.isRequired,
|
||||||
onToggleUploadAssetDialog: PropTypes.func.isRequired,
|
onToggleUploadAssetDialog: PropTypes.func.isRequired,
|
||||||
|
@ -258,7 +258,7 @@ describe('Media library homepage', () => {
|
|||||||
it('shows the create button if the user has create permissions', () => {
|
it('shows the create button if the user has create permissions', () => {
|
||||||
renderML();
|
renderML();
|
||||||
|
|
||||||
expect(screen.getByText('header.actions.add-folder')).toBeInTheDocument();
|
expect(screen.getByText('Add new folder')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('hides the create button if the user does not have create permissions', () => {
|
it('hides the create button if the user does not have create permissions', () => {
|
||||||
@ -269,7 +269,7 @@ describe('Media library homepage', () => {
|
|||||||
|
|
||||||
renderML();
|
renderML();
|
||||||
|
|
||||||
expect(screen.queryByText('header.actions.add-folder')).not.toBeInTheDocument();
|
expect(screen.queryByText('Add new folder')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
"form.upload-url.error.url.invalid": "One URL is invalid",
|
"form.upload-url.error.url.invalid": "One URL is invalid",
|
||||||
"form.upload-url.error.url.invalids": "{number} URLs are invalids",
|
"form.upload-url.error.url.invalids": "{number} URLs are invalids",
|
||||||
"header.actions.add-assets": "Add new assets",
|
"header.actions.add-assets": "Add new assets",
|
||||||
|
"header.actions.add-folder": "Add new folder",
|
||||||
"header.actions.add-assets.folder": "folder",
|
"header.actions.add-assets.folder": "folder",
|
||||||
"header.actions.upload-assets": "Upload assets",
|
"header.actions.upload-assets": "Upload assets",
|
||||||
"header.actions.upload-new-asset": "Upload new asset",
|
"header.actions.upload-new-asset": "Upload new asset",
|
||||||
@ -46,8 +47,9 @@
|
|||||||
"list.assets.loading-asset": "Loading the preview for the media: {path}",
|
"list.assets.loading-asset": "Loading the preview for the media: {path}",
|
||||||
"list.assets.not-supported-content": "No preview available",
|
"list.assets.not-supported-content": "No preview available",
|
||||||
"list.assets.preview-asset": "Preview for the video at path {path}",
|
"list.assets.preview-asset": "Preview for the video at path {path}",
|
||||||
"list.assets.selected": "{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload",
|
"list.assets.selected": "{numberFolders, plural, one {1 folder} other {# folders}} - {numberAssets, plural, one {1 asset} other {# assets}}",
|
||||||
"list.assets.type-not-allowed": "This type of file is not allowed.",
|
"list.assets.type-not-allowed": "This type of file is not allowed.",
|
||||||
|
"list.assets.to-upload": "{number, plural, =0 {No asset} one {1 asset} other {# assets}} ready to upload",
|
||||||
"list.folder.edit": "Edit folder",
|
"list.folder.edit": "Edit folder",
|
||||||
"list.folder.subtitle": "{folderCount, plural, =0 {# folder} one {# folder} other {# folders}}, {filesCount, plural, =0 {# asset} one {# asset} other {# assets}}",
|
"list.folder.subtitle": "{folderCount, plural, =0 {# folder} one {# folder} other {# folders}}, {filesCount, plural, =0 {# asset} one {# asset} other {# assets}}",
|
||||||
"list.folders.title": "Folders",
|
"list.folders.title": "Folders",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user