Skip to content

Commit aaae58f

Browse files
committed
fix: fix the env-label issue
1 parent ff9137e commit aaae58f

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

packages/strapi-plugin-env-label/admin/src/components/StatusBadge/index.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { StatusBadgeProps as UtrechtStatusBadgeProps } from '@utrecht/compo
44
import { forwardRef } from 'react';
55
import type { ForwardedRef, PropsWithChildren } from 'react';
66
import { useIntl } from 'react-intl';
7+
import styled from 'styled-components';
78

89
import usePluginConfig from '../../hooks/use-plugin-config';
910
import { getTranslation } from '../../utils/getTranslation';
@@ -12,6 +13,11 @@ interface StatusBadgeProps extends UtrechtStatusBadgeProps {
1213
gap?: boolean;
1314
}
1415

16+
const StyledStatusBadge = styled(UtrechtStatusBadge)`
17+
max-inline-size: 100%;
18+
inline-size: 100%;
19+
`;
20+
1521
export const StatusBadge = forwardRef(
1622
({ gap, ...resProps }: PropsWithChildren<StatusBadgeProps>, ref: ForwardedRef<HTMLSpanElement>) => {
1723
const { formatMessage } = useIntl();
@@ -22,12 +28,20 @@ export const StatusBadge = forwardRef(
2228
if (!config?.env_label || !regex.test(config.env_label)) return null;
2329

2430
return (
25-
<Box className="utrecht-theme" marginTop={gap ? 5 : undefined} marginBottom={gap ? 5 : undefined}>
26-
<UtrechtStatusBadge ref={ref} status="warning" {...resProps}>
31+
<Box
32+
display="flex"
33+
width="100%"
34+
textAlign="center"
35+
className="utrecht-theme test"
36+
marginTop={gap ? 5 : undefined}
37+
marginBottom={gap ? 5 : undefined}
38+
>
39+
<StyledStatusBadge ref={ref} status="warning" {...resProps}>
2740
{formatMessage({
2841
id: getTranslation(`${config?.env_label}-env-label-message`),
42+
defaultMessage: `${config?.env_label}`,
2943
})}
30-
</UtrechtStatusBadge>
44+
</StyledStatusBadge>
3145
</Box>
3246
);
3347
},

packages/strapi-plugin-env-label/admin/src/hooks/use-plugin-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const usePluginConfig = () => {
2424
const fetchData = async () => {
2525
try {
2626
const endpoint = `/${PLUGIN_ID}/config`;
27-
const data = await client.get(endpoint, {
27+
const { data } = await client.get(endpoint, {
2828
signal: abortController.signal,
2929
});
3030

packages/strapi-plugin-env-label/admin/src/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,13 @@ export default {
3232
name: 'env-label',
3333
Component: StatusBadge,
3434
});
35-
app.getPlugin('content-manager').injectComponent('editView', 'informations', {
36-
name: 'env-label',
37-
Component: StatusBadge,
38-
});
39-
app.getPlugin('content-manager').injectComponent('listView', 'deleteModalAdditionalInfos', {
35+
app.getPlugin('content-manager').injectComponent('editView', 'right-links', {
4036
name: 'env-label',
4137
Component: StatusBadge,
4238
});
4339
},
4440

45-
async registerTranslation({ locales }: { locales: string[] }) {
41+
async registerTrads({ locales }: { locales: string[] }) {
4642
const importedTranslations = await Promise.all(
4743
locales.map((locale: any) => {
4844
return import(`./translations/${locale}.json`)

packages/strapi-plugin-env-label/server/controllers/env-label.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({
99
const config = await strapi.plugin(PLUGIN_ID).service('plugin').getConfig();
1010
ctx.body = config;
1111
} catch (error) {
12-
strapi.log.error('Error fetching Preview button config:', error);
13-
ctx.badRequest('Something went wrong with the Preview button config');
12+
strapi.log.error('Error fetching environment label config:', error);
13+
ctx.badRequest('Something went wrong with the environment label config');
1414
}
1515
},
1616
});

0 commit comments

Comments
 (0)