mirror of
https://github.com/strapi/strapi.git
synced 2025-10-27 08:02:56 +00:00
add deprecation warnings where we use axiosInstance
This commit is contained in:
parent
8161eb9bf8
commit
2bd1a06e9c
@ -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) {
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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`
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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 = {
|
||||
|
||||
@ -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 };
|
||||
|
||||
@ -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}`);
|
||||
},
|
||||
{
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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 });
|
||||
};
|
||||
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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, {
|
||||
|
||||
@ -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],
|
||||
});
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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 });
|
||||
};
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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;
|
||||
})
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -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',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user