Add small changes to improve context

This commit is contained in:
Christian Capeans 2023-01-30 17:59:37 +01:00
parent c7f048918e
commit 6f2e86e562
3 changed files with 9 additions and 7 deletions

View File

@ -101,19 +101,20 @@ module.exports = {
const numberOfAllContentTypes = _.size(strapi.contentTypes);
const numberOfComponents = _.size(strapi.components);
const getNumberOfDynamicZones = () =>
pipe(
const getNumberOfDynamicZones = () => {
return pipe(
map('attributes'),
flatMap(values),
sumBy(propEq('type', 'dynamiczone'))
)(strapi.contentTypes);
};
return {
data: {
useTypescriptOnServer,
useTypescriptOnAdmin,
isHostedOnStrapiCloud,
numberOfAllContentTypes, // TODO: Rename this in Strapi v5
numberOfAllContentTypes, // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.
numberOfComponents,
numberOfDynamicZones: getNumberOfDynamicZones(),
},

View File

@ -43,12 +43,13 @@ module.exports = (strapi) => {
const serverRootPath = strapi.dirs.app.root;
const adminRootPath = path.join(strapi.dirs.app.root, 'src', 'admin');
const getNumberOfDynamicZones = () =>
pipe(
const getNumberOfDynamicZones = () => {
return pipe(
map('attributes'),
flatMap(values),
sumBy(propEq('type', 'dynamiczone'))
)(strapi.contentTypes);
};
const anonymousUserProperties = {
environment: strapi.config.environment,
@ -68,7 +69,7 @@ module.exports = (strapi) => {
useTypescriptOnAdmin: isUsingTypeScriptSync(adminRootPath),
projectId: uuid,
isHostedOnStrapiCloud: env('STRAPI_HOSTING', null) === 'strapi.cloud',
numberOfAllContentTypes: _.size(strapi.contentTypes), // TODO: Rename this in Strapi v5
numberOfAllContentTypes: _.size(strapi.contentTypes), // TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.
numberOfComponents: _.size(strapi.components),
numberOfDynamicZones: getNumberOfDynamicZones(),
};

View File

@ -6,7 +6,7 @@ const { getService } = require('../utils');
const sendDidInitializeEvent = async () => {
const { isLocalizedContentType } = getService('content-types');
// TODO: Rename this in Strapi v5
// TODO: V5: This event should be renamed numberOfContentTypes in V5 as the name is already taken to describe the number of content types using i18n.
const numberOfContentTypes = reduce(
(sum, contentType) => (isLocalizedContentType(contentType) ? sum + 1 : sum),
0