Skip to content

Commit

Permalink
const instead of 5 repeats
Browse files Browse the repository at this point in the history
  • Loading branch information
ComLock committed Dec 11, 2024
1 parent 78e58e2 commit 48659ae
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/ComponentRegistry/BasePart.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import type {PartComponent} from '@enonic-types/core';
import type {
ComponentRegistry,
RenderablePartComponent,
Expand All @@ -23,11 +22,13 @@ export function BasePart({
warning,
} = component;

const dataPortalComponentType = mode === 'edit' ? 'part' : undefined;

if (warning && (mode === 'edit' || mode === 'inline')) {
return (
<Message {...{
children: warning,
'data-portal-component-type': mode === 'edit' ? 'part' : undefined,
'data-portal-component-type': dataPortalComponentType,
mode,
}}/>
);
Expand All @@ -41,7 +42,7 @@ export function BasePart({
return (
<Message {...{
children: `Part descriptor:${descriptor} not registered in ComponentRegistry!`,
'data-portal-component-type': mode === 'edit' ? 'part' : undefined,
'data-portal-component-type': dataPortalComponentType,
mode,
}}/>
);
Expand All @@ -52,7 +53,7 @@ export function BasePart({
return (
<Message {...{
children: `No View found for part descriptor:${descriptor} in ComponentRegistry!`,
'data-portal-component-type': mode === 'edit' ? 'part' : undefined,
'data-portal-component-type': dataPortalComponentType,
mode,
}}/>
);
Expand All @@ -62,7 +63,7 @@ export function BasePart({
return (
<Message {...{
children: `Part component missing props: ${descriptor}!`,
'data-portal-component-type': mode === 'edit' ? 'part' : undefined,
'data-portal-component-type': dataPortalComponentType,
mode,
}}/>
);
Expand All @@ -72,7 +73,7 @@ export function BasePart({
<PartView {...{
...props,
componentRegistry,
'data-portal-component-type': mode === 'edit' ? 'part' : undefined
'data-portal-component-type': dataPortalComponentType
}}/>
);
}

0 comments on commit 48659ae

Please sign in to comment.