add deprecation warnings where we use axiosInstance

This commit is contained in:
Simone Taeggi 2022-11-04 12:07:21 +01:00
parent 8161eb9bf8
commit 2bd1a06e9c
48 changed files with 283 additions and 23 deletions

View File

@ -39,6 +39,9 @@ const fetchStrapiLatestRelease = async (toggleNotification) => {
const fetchAppInfo = async () => {
try {
const { data, headers } = await axiosInstance.get('/admin/information');
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
if (!headers['content-type'].includes('application/json')) {
throw new Error('Not found');
@ -53,6 +56,9 @@ const fetchAppInfo = async () => {
const fetchCurrentUserPermissions = async () => {
try {
const { data, headers } = await axiosInstance.get('/admin/users/me/permissions');
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
if (!headers['content-type'].includes('application/json')) {
throw new Error('Not found');
@ -71,6 +77,9 @@ const fetchUserRoles = async () => {
data: { roles },
},
} = await axiosInstance.get('/admin/users/me');
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return roles;
} catch (err) {

View File

@ -138,6 +138,9 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
try {
const { data } = await axiosInstance.get(requestURL, { cancelToken: source.token });
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
dispatch(getDataSucceeded(cleanReceivedData(cleanClonedData(data))));
} catch (err) {
@ -222,6 +225,9 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
const { data } = await axiosInstance.delete(
getRequestUrl(`collection-types/${slug}/${id}`)
);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function deleteClient'
);
toggleNotification({
type: 'success',
@ -253,6 +259,9 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
dispatch(setStatus('submit-pending'));
const { data } = await axiosInstance.post(endPoint, body);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
trackUsageRef.current('didCreateEntry', trackerProperty);
toggleNotification({
@ -304,6 +313,9 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
dispatch(setStatus('draft-relation-check-pending'));
const numberOfDraftRelations = await axiosInstance.get(endPoint);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
trackUsageRef.current('didCheckDraftRelations');
dispatch(setStatus('resolved'));
@ -325,6 +337,9 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
dispatch(setStatus('publish-pending'));
const { data } = await axiosInstance.post(endPoint);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
trackUsageRef.current('didPublishEntry');
@ -355,6 +370,9 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
dispatch(setStatus('submit-pending'));
const { data } = await axiosInstance.put(endPoint, body);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
trackUsageRef.current('didEditEntry', { trackerProperty });
toggleNotification({
@ -391,6 +409,9 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, slug, id, origin }
trackUsageRef.current('willUnpublishEntry');
const { data } = await axiosInstance.post(endPoint);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
trackUsageRef.current('didUnpublishEntry');
toggleNotification({

View File

@ -22,6 +22,9 @@ const fetchRelation = async (endPoint, notifyStatus) => {
const {
data: { results, pagination },
} = await axiosInstance.get(endPoint);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
notifyStatus();

View File

@ -79,6 +79,9 @@ const InputUID = ({
field: name,
data: modifiedData,
});
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
onChange({ target: { name, value: data, type: 'text' } }, shouldSetInitialValue);
setIsLoading(false);
} catch (err) {
@ -101,6 +104,9 @@ const InputUID = ({
field: name,
value: value ? value.trim() : '',
});
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
setAvailability(data);

View File

@ -106,6 +106,9 @@ const SingleTypeFormWrapper = ({ allLayoutData, children, slug }) => {
const { data } = await axiosInstance(getRequestUrl(`${slug}${searchToSend}`), {
cancelToken: source.token,
});
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
dispatch(getDataSucceeded(cleanReceivedData(data)));
@ -161,6 +164,9 @@ const SingleTypeFormWrapper = ({ allLayoutData, children, slug }) => {
trackUsageRef.current('willDeleteEntry', trackerProperty);
const { data } = await axiosInstance.delete(getRequestUrl(`${slug}${searchToSend}`));
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function deleteClient'
);
toggleNotification({
type: 'success',
@ -195,6 +201,9 @@ const SingleTypeFormWrapper = ({ allLayoutData, children, slug }) => {
dispatch(setStatus('submit-pending'));
const { data } = await axiosInstance.put(endPoint, body);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
trackUsageRef.current('didCreateEntry', trackerProperty);
toggleNotification({
@ -243,6 +252,9 @@ const SingleTypeFormWrapper = ({ allLayoutData, children, slug }) => {
dispatch(setStatus('draft-relation-check-pending'));
const numberOfDraftRelations = await axiosInstance.get(endPoint);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
trackUsageRef.current('didCheckDraftRelations');
dispatch(setStatus('resolved'));
@ -264,6 +276,9 @@ const SingleTypeFormWrapper = ({ allLayoutData, children, slug }) => {
dispatch(setStatus('publish-pending'));
const { data } = await axiosInstance.post(endPoint);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
trackUsageRef.current('didPublishEntry');
toggleNotification({
@ -295,6 +310,9 @@ const SingleTypeFormWrapper = ({ allLayoutData, children, slug }) => {
dispatch(setStatus('submit-pending'));
const { data } = await axiosInstance.put(endPoint, body);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
toggleNotification({
type: 'success',
@ -334,6 +352,9 @@ const SingleTypeFormWrapper = ({ allLayoutData, children, slug }) => {
trackUsageRef.current('willUnpublishEntry');
const { data } = await axiosInstance.post(endPoint);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
trackUsageRef.current('didUnpublishEntry');
toggleNotification({

View File

@ -28,6 +28,9 @@ const useFetchContentTypeLayout = (contentTypeUID) => {
const {
data: { data },
} = await axiosInstance.get(endPoint, { cancelToken: source.token });
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
dispatch({
type: 'GET_DATA_SUCCEEDED',

View File

@ -19,6 +19,9 @@ export const useRelation = (cacheKey, { name, relation, search }) => {
page: pageParam,
},
});
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
setCurrentPage(pageParam);
@ -37,6 +40,9 @@ export const useRelation = (cacheKey, { name, relation, search }) => {
page: pageParam,
},
});
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return data;
} catch (err) {

View File

@ -39,6 +39,9 @@ const useModels = () => {
axiosInstance.get(getRequestUrl(endPoint), { cancelToken: source.token })
)
);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
notifyStatus(
formatMessage({

View File

@ -8,6 +8,9 @@ const getContentTypeLinks = async (models, userPermissions, toggleNotification)
const {
data: { data: contentTypeConfigurations },
} = await axiosInstance.get(getRequestUrl('content-types-settings'));
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
const { collectionTypesSectionLinks, singleTypesSectionLinks } = generateModelsLinks(
models,

View File

@ -32,6 +32,9 @@ const ComponentSettingsView = () => {
} = await axiosInstance.get(getRequestUrl(`components/${uid}/configuration`), {
cancelToken: source.token,
});
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
dispatch(getDataSucceeded(mergeMetasWithSchema(data, schemas, 'component')));
} catch (err) {

View File

@ -2,6 +2,10 @@ import { axiosInstance } from '../../../../core/utils';
import { getRequestUrl } from '../../../utils';
const putCMSettingsEV = (body, slug, isContentTypeView) => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
return axiosInstance.put(
getRequestUrl(
isContentTypeView ? `content-types/${slug}/configuration` : `components/${slug}/configuration`

View File

@ -2,6 +2,10 @@ import { axiosInstance } from '../../../../core/utils';
import { getRequestUrl } from '../../../utils';
const putCMSettingsLV = (body, slug) => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
return axiosInstance.put(getRequestUrl(`content-types/${slug}/configuration`), body);
};

View File

@ -113,6 +113,9 @@ function ListView({
const {
data: { results, pagination: paginationResult },
} = await axiosInstance.get(endPoint, opts);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
notifyStatus(
formatMessage(
@ -160,6 +163,9 @@ function ListView({
const handleConfirmDeleteAllData = useCallback(
async (ids) => {
try {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
await axiosInstance.post(getRequestUrl(`collection-types/${slug}/actions/bulkDelete`), {
ids,
});
@ -181,6 +187,9 @@ function ListView({
async (idToDelete) => {
try {
await axiosInstance.delete(getRequestUrl(`collection-types/${slug}/${idToDelete}`));
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function deleteClient'
);
const requestUrl = getRequestUrl(`collection-types/${slug}${params}`);
fetchData(requestUrl);

View File

@ -2,6 +2,9 @@ import { axiosInstance } from '../../../core/utils';
const fetchEnabledPlugins = async () => {
const { data } = await axiosInstance.get('/admin/plugins');
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return data;
};

View File

@ -14,6 +14,9 @@ const useRegenerate = (id, onRegenerate) => {
data: { accessKey },
},
} = await axiosInstance.post(`/admin/api-tokens/${id}/regenerate`);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
setIsLoadingConfirmation(false);
onRegenerate(accessKey);
} catch (error) {

View File

@ -27,6 +27,9 @@ const useRolesList = (shouldFetchData = true) => {
const {
data: { data },
} = await axiosInstance.get('/admin/roles');
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
dispatch({
type: 'GET_DATA_SUCCEEDED',

View File

@ -34,6 +34,9 @@ const run = async () => {
data: { isEE, features },
},
} = await axiosInstance.get('/admin/project-type');
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
window.strapi.isEE = isEE;
window.strapi.features = {

View File

@ -2,6 +2,9 @@ import omit from 'lodash/omit';
import { axiosInstance } from '../../../core/utils';
const fetchUser = async () => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
const { data } = await axiosInstance.get('/admin/users/me');
return data.data;
@ -9,6 +12,9 @@ const fetchUser = async () => {
const putUser = async (body) => {
const dataToSend = omit(body, ['confirmPassword', 'currentTheme']);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
const { data } = await axiosInstance.put('/admin/users/me', dataToSend);
return { ...data.data, currentTheme: body.currentTheme };

View File

@ -68,6 +68,9 @@ const ApiTokenListView = () => {
const {
data: { data },
} = await axiosInstance.get(`/admin/api-tokens`);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
trackUsage('didAccessTokenList', { number: data.length });
@ -90,6 +93,9 @@ const ApiTokenListView = () => {
const deleteMutation = useMutation(
async (id) => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function deleteClient'
);
await axiosInstance.delete(`/admin/api-tokens/${id}`);
},
{

View File

@ -3,12 +3,18 @@ import prefixAllUrls from './prefixAllUrls';
const fetchProjectSettings = async () => {
const { data } = await axiosInstance.get('/admin/project-settings');
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return prefixAllUrls(data);
};
const postProjectSettings = async (body) => {
const { data } = await axiosInstance.post('/admin/project-settings', body);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
return prefixAllUrls(data);
};

View File

@ -2,12 +2,18 @@ import { axiosInstance } from '../../../../../../core/utils';
const fetchUser = async (id) => {
const { data } = await axiosInstance.get(`/admin/users/${id}`);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return data.data;
};
const putUser = async (id, body) => {
const { data } = await axiosInstance.put(`/admin/users/${id}`, body);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
return data.data;
};

View File

@ -34,27 +34,36 @@ const ModalForm = ({ queryName, onToggle }) => {
const { formatMessage } = useIntl();
const toggleNotification = useNotification();
const { lockApp, unlockApp } = useOverlayBlocker();
const postMutation = useMutation((body) => axiosInstance.post('/admin/users', body), {
async onSuccess({ data }) {
setRegistrationToken(data.data.registrationToken);
await queryClient.invalidateQueries(queryName);
goNext();
setIsSubmitting(false);
},
onError(err) {
setIsSubmitting(false);
const postMutation = useMutation(
(body) => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
toggleNotification({
type: 'warning',
message: { id: 'notification.error', defaultMessage: 'An error occured' },
});
return axiosInstance.post('/admin/users', body);
},
{
async onSuccess({ data }) {
setRegistrationToken(data.data.registrationToken);
await queryClient.invalidateQueries(queryName);
goNext();
setIsSubmitting(false);
},
onError(err) {
setIsSubmitting(false);
throw err;
},
onSettled() {
unlockApp();
},
});
toggleNotification({
type: 'warning',
message: { id: 'notification.error', defaultMessage: 'An error occured' },
});
throw err;
},
onSettled() {
unlockApp();
},
}
);
const headerTitle = formatMessage({
id: 'Settings.permissions.users.create',

View File

@ -4,6 +4,9 @@ const fetchData = async (search, notify) => {
const {
data: { data },
} = await axiosInstance.get(`/admin/users${search}`);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
notify();
@ -11,6 +14,10 @@ const fetchData = async (search, notify) => {
};
const deleteData = async (ids) => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
await axiosInstance.post('/admin/users/batch-delete', { ids });
};

View File

@ -28,6 +28,9 @@ const Loader = () => (
const fetchData = async () => {
const { data } = await axiosInstance.get('/admin/roles');
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return data.data;
};

View File

@ -64,7 +64,13 @@ const EditView = () => {
data: triggerResponse,
isIdle: isTriggerIdle,
mutate,
} = useMutation(() => axiosInstance.post(`/admin/webhooks/${id}/trigger`));
} = useMutation(() => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
return axiosInstance.post(`/admin/webhooks/${id}/trigger`);
});
const triggerWebhook = () =>
mutate(null, {

View File

@ -78,6 +78,9 @@ const useRoleActions = ({ getData, canCreate, canDelete, canUpdate }) => {
type: 'ON_REMOVE_ROLES',
});
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
await axiosInstance.post('/admin/roles/batch-delete', {
ids: [roleToDelete],
});

View File

@ -108,6 +108,10 @@ const DataManagerProvider = ({
{ data: reservedNames },
] = await Promise.all(
['components', 'content-types', 'reserved-names'].map((endPoint) => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return axiosInstance.get(endPoint);
})
);
@ -315,7 +319,9 @@ const DataManagerProvider = ({
}
lockAppWithAutoreload();
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function deleteClient'
);
await axiosInstance.delete(requestURL);
// Make sure the server has restarted
@ -349,6 +355,9 @@ const DataManagerProvider = ({
lockAppWithAutoreload();
// Update the category
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
await axiosInstance({ url: requestURL, method: 'PUT', data: body });
// Make sure the server has restarted
@ -507,6 +516,10 @@ const DataManagerProvider = ({
// Lock the app
lockAppWithAutoreload();
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient or the putClient'
);
await axiosInstance({
url: requestURL,
method,

View File

@ -1,12 +1,18 @@
import axiosInstance from '../../../utils/axiosInstance';
const fetchEmailSettings = async () => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
const { data } = await axiosInstance.get('/email/settings');
return data.config;
};
const postEmailTest = async (body) => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
await axiosInstance.post('/email/test', body);
};

View File

@ -47,6 +47,9 @@ export const useAssets = ({ skipWhen = false, query = {} } = {}) => {
addQueryPrefix: true,
})}`
);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
notifyStatus(
formatMessage({

View File

@ -22,6 +22,9 @@ export const useBulkMove = () => {
return acc;
}, {});
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
return axiosInstance.post(url, { ...payload, destinationFolderId });
};

View File

@ -22,6 +22,9 @@ export const useBulkRemove = () => {
return acc;
}, {});
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
return axiosInstance.post(url, payload);
};

View File

@ -26,6 +26,10 @@ const editAssetRequest = (asset, file, cancelToken, onProgress) => {
})
);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
return axiosInstance({
method: 'post',
url: endpoint,

View File

@ -8,6 +8,10 @@ const editFolderRequest = ({ attrs, id }) => {
const method = isEditing ? 'put' : 'post';
const url = getRequestUrl(`folders/${id ?? ''}`);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient or the postClient'
);
return axiosInstance[method](url, attrs).then((res) => res.data);
};

View File

@ -13,6 +13,9 @@ export const useFolder = (id, { enabled = true }) => {
const { data } = await axiosInstance.get(
`${dataRequestURL}/${id}?populate[parent][populate][parent]=*`
);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return data.data;
} catch (err) {

View File

@ -18,6 +18,9 @@ export const useFolderStructure = ({ enabled = true } = {}) => {
const {
data: { data },
} = await axiosInstance.get(dataRequestURL);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
const children = data.map((f) => recursiveRenameKeys(f, (key) => FIELD_MAPPING?.[key] ?? key));

View File

@ -50,6 +50,9 @@ export const useFolders = ({ enabled = true, query = {} }) => {
const { data } = await axiosInstance.get(
`${dataRequestURL}?${stringify(params, { encode: false })}`
);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
notifyStatus(
formatMessage({

View File

@ -24,6 +24,10 @@ const uploadAsset = (asset, folderId, cancelToken, onProgress) => {
})
);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
return axiosInstance({
method: 'post',
url: endpoint,

View File

@ -50,6 +50,9 @@ export const SettingsPage = () => {
} = await axiosInstance.get(getRequestUrl('settings'), {
cancelToken: source.token,
});
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
dispatch({
type: 'GET_DATA_SUCCEEDED',
@ -86,6 +89,9 @@ export const SettingsPage = () => {
try {
await axiosInstance.put(getRequestUrl('settings'), modifiedData);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
dispatch({
type: 'SUBMIT_SUCCEEDED',

View File

@ -4,5 +4,9 @@ import getRequestUrl from './getRequestUrl';
export const deleteRequest = (type, id) => {
const url = getRequestUrl(`/${type}/${id}`);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function deleteClient'
);
return axiosInstance.delete(url);
};

View File

@ -62,6 +62,9 @@ const Content = ({ appLocales, currentLocale, localizations, readPermissions })
setIsLoading(true);
try {
const { data: response } = await axiosInstance.get(requestURL);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
const cleanedData = cleanData(response, allLayoutData, localizations);
['createdBy', 'updatedBy', 'publishedAt', 'id', 'createdAt'].forEach((key) => {

View File

@ -1,7 +1,7 @@
import { useCallback, useReducer, useEffect, useRef } from 'react';
import { useNotification } from '@strapi/helper-plugin';
import reducer, { initialState } from './reducer';
import axiosIntance from '../../utils/axiosInstance';
import axiosInstance from '../../utils/axiosInstance';
import pluginId from '../../pluginId';
const useFetchRole = (id) => {
@ -29,7 +29,10 @@ const useFetchRole = (id) => {
try {
const {
data: { role },
} = await axiosIntance.get(`/${pluginId}/roles/${roleId}`);
} = await axiosInstance.get(`/${pluginId}/roles/${roleId}`);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
// Prevent updating state on an unmounted component
if (isMounted.current) {

View File

@ -22,6 +22,9 @@ const usePlugins = (shouldFetchData = true) => {
const [{ permissions }, { routes }] = await Promise.all(
[`/${pluginId}/permissions`, `/${pluginId}/routes`].map(async (endpoint) => {
const res = await axiosInstance.get(endpoint);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return res.data;
})

View File

@ -1,12 +1,19 @@
import { axiosInstance, getRequestURL } from '../../../utils';
const fetchData = async () => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
const { data } = await axiosInstance.get(getRequestURL('advanced'));
return data;
};
const putAdvancedSettings = (body) => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
return axiosInstance.put(getRequestURL('advanced'), body);
};

View File

@ -2,11 +2,18 @@ import { axiosInstance, getRequestURL } from '../../../utils';
const fetchData = async () => {
const { data } = await axiosInstance.get(getRequestURL('email-templates'));
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return data;
};
const putEmailTemplate = (body) => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
return axiosInstance.put(getRequestURL('email-templates'), body);
};

View File

@ -4,6 +4,9 @@ import { getRequestURL, axiosInstance } from '../../../utils';
export const fetchData = async (toggleNotification) => {
try {
const { data } = await axiosInstance.get(getRequestURL('providers'));
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
return data;
} catch (err) {
@ -17,5 +20,9 @@ export const fetchData = async (toggleNotification) => {
};
export const putProvider = (body) => {
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
return axiosInstance.put(getRequestURL('providers'), body);
};

View File

@ -44,6 +44,9 @@ const EditPage = () => {
const permissions = permissionsRef.current.getPermissions();
// Update role in Strapi
await axiosInstance.post(`/${pluginId}/roles`, { ...data, ...permissions, users: [] });
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function postClient'
);
// Notify success
trackUsage('didCreateRole');
toggleNotification({

View File

@ -48,6 +48,9 @@ const EditPage = () => {
const permissions = permissionsRef.current.getPermissions();
// Update role in Strapi
await axiosInstance.put(`/${pluginId}/roles/${id}`, { ...data, ...permissions, users: [] });
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function putClient'
);
// Notify success
onSubmitSucceeded({ name: data.name, description: data.description });
toggleNotification({

View File

@ -3,6 +3,9 @@ import { getRequestURL, axiosInstance } from '../../../../utils';
export const fetchData = async (toggleNotification, notifyStatus) => {
try {
const { data } = await axiosInstance.get(getRequestURL('roles'));
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function getClient'
);
notifyStatus('The roles have loaded successfully');
return data;
@ -19,6 +22,9 @@ export const fetchData = async (toggleNotification, notifyStatus) => {
export const deleteData = async (id, toggleNotification) => {
try {
await axiosInstance.delete(`${getRequestURL('roles')}/${id}`);
console.warn(
'Deprecation warning: Usage of "axiosInstance" utility is deprecated. This is discouraged and will be removed in the next major release. Please use instead the useFetchClient hook inside the helper plugin and its function deleteClient'
);
} catch (error) {
toggleNotification({
type: 'warning',