Skip to content

Commit a2a9f51

Browse files
committed
Add abstract handling
1 parent f151b38 commit a2a9f51

6 files changed

Lines changed: 14 additions & 10 deletions

File tree

976 Bytes
Loading
616 Bytes
Loading

__tests__/html2/part-grouping/status.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
}
147147
};
148148

149-
const withModifiers = (activity, { position, status, abstract, howToStatus }) => ({
149+
const withModifiers = (activity, { position, status, abstract, howToStatus, howToAbstract }) => ({
150150
...activity,
151151
entities: activity.entities.map(entity => ({
152152
...entity,
@@ -155,7 +155,8 @@
155155
creativeWorkStatus: status,
156156
isPartOf: {
157157
...entity.isPartOf,
158-
...(typeof howToStatus !== 'undefined' ? { creativeWorkStatus: howToStatus } : {})
158+
...(typeof howToStatus !== 'undefined' ? { creativeWorkStatus: howToStatus } : {}),
159+
...(typeof howToAbstract !== 'undefined' ? { abstract: howToAbstract } : {})
159160
}
160161
}))
161162
});
@@ -260,15 +261,15 @@
260261

261262
// Test Case 8: HowTo-level status takes precedence
262263
// When: setting the HowTo entity's creativeWorkStatus to 'Incomplete' while messages have 'Published'
263-
directLine.emulateIncomingActivity(withModifiers(activities.at(0), { status: 'Published', abstract: 'one done', howToStatus: 'Incomplete' }));
264+
directLine.emulateIncomingActivity(withModifiers(activities.at(0), { status: 'Published', abstract: 'one done', howToStatus: 'Incomplete', howToAbstract: 'HowTo in progress' }));
264265

265266
// Then: the group header should show 'Incomplete' because the HowTo status takes precedence over derived message status
266267
await pageConditions.numActivitiesShown(6);
267268
await host.snapshot('local');
268269

269270
// Test Case 9: HowTo-level status set to 'Published' overrides message-derived status
270271
// When: a message is 'Incomplete' but the HowTo entity is explicitly 'Published'
271-
directLine.emulateIncomingActivity(withModifiers(activities.at(3), { status: 'Incomplete', abstract: 'four in progress again', howToStatus: 'Published' }));
272+
directLine.emulateIncomingActivity(withModifiers(activities.at(3), { status: 'Incomplete', abstract: 'four in progress again', howToStatus: 'Published', howToAbstract: 'HowTo completed' }));
272273

273274
// Then: the group header should show 'Published' from the HowTo, not 'Incomplete' from the message
274275
await pageConditions.numActivitiesShown(6);
1.29 KB
Loading
1.03 KB
Loading

packages/component/src/Middleware/ActivityGrouping/ui/PartGrouping/private/PartGroupingActivity.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,13 @@ function PartGroupingActivity(props: PartGroupingActivityProps) {
181181

182182
const topAlignedCallout = isZeroOrPositive(bubbleNubOffset);
183183

184-
// The HowTo entity (the group root) may carry an explicit `creativeWorkStatus`.
184+
// The HowTo entity (the group root) may carry an explicit `creativeWorkStatus` and `abstract`.
185185
// When present, it takes precedence over status derived from individual messages.
186-
const howToStatus = useMemo(
187-
() => messages.find(message => message.isPartOf?.creativeWorkStatus)?.isPartOf?.creativeWorkStatus,
186+
const [howToStatus, howToAbstract] = useMemo(
187+
() => [
188+
messages.find(message => message.isPartOf?.creativeWorkStatus)?.isPartOf?.creativeWorkStatus,
189+
messages.find(message => message.isPartOf?.creativeWorkStatus)?.isPartOf?.abstract
190+
],
188191
[messages]
189192
);
190193

@@ -218,13 +221,13 @@ function PartGroupingActivity(props: PartGroupingActivityProps) {
218221
/>
219222
)}
220223
<CollapsibleGroupingTitle>
221-
{currentGroupStatus === 'Incomplete'
222-
? currentMessage?.abstract || localize('COLLAPSIBLE_GROUPING_TITLE')
224+
{currentGroupStatus === 'Incomplete' || howToAbstract
225+
? howToAbstract || currentMessage?.abstract || localize('COLLAPSIBLE_GROUPING_TITLE')
223226
: localize('COLLAPSIBLE_GROUPING_TITLE')}
224227
</CollapsibleGroupingTitle>
225228
</Fragment>
226229
),
227-
[classNames, currentGroupStatus, currentMessage?.abstract, defaultWorkStatus, howToStatus, localize]
230+
[classNames, currentGroupStatus, currentMessage?.abstract, defaultWorkStatus, howToAbstract, howToStatus, localize]
228231
);
229232

230233
return (

0 commit comments

Comments
 (0)