Skip to content

Commit

Permalink
LPD-22768 Refactor TimelineDropdownMenu so that its link creation log…
Browse files Browse the repository at this point in the history
…ic can be without the component
  • Loading branch information
ctang3 authored and brianchandotcom committed Oct 1, 2024
1 parent 9c062f8 commit a78a295
Showing 1 changed file with 85 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,75 @@ import {
WORKFLOW_STATUS_EXPIRED,
} from './WorkflowStatusLabel';

const createMVCRenderCommandURL = (
ctCollectionId,
mvcRenderCommandName,
namespace,
additionalParams = {}
) => {
return createPortletURL(themeDisplay.getLayoutRelativeControlPanelURL(), {
ctCollectionId,
mvcRenderCommandName,
p_p_id: getPortletId(namespace),
...additionalParams,
}).toString();
};

export function createDiscardURL(
ctCollectionId,
namespace,
timelineClassNameId,
timelineClassPK
) {
return createMVCRenderCommandURL(
ctCollectionId,
'/change_tracking/view_discard',
namespace,
{
modelClassNameId: timelineClassNameId,
modelClassPK: timelineClassPK,
}
);
}

export function createEditURL(ctCollectionId, timelineEditURL) {
return createPortletURL(timelineEditURL, {
ctCollectionId,
}).toString();
}

export function createMoveURL(
ctCollectionId,
namespace,
timelineClassNameId,
timelineClassPK
) {
return createMVCRenderCommandURL(
ctCollectionId,
'/change_tracking/view_move_changes',
namespace,
{
modelClassNameId: timelineClassNameId,
modelClassPK: timelineClassPK,
}
);
}

export function createViewURL(
ctCollectionId,
namespace,
timelineItemCtEntryId
) {
return createMVCRenderCommandURL(
ctCollectionId,
'/change_tracking/view_change',
namespace,
{
ctEntryId: timelineItemCtEntryId,
}
);
}

export default function TimelineDropdownMenu({
deleteURL,
editURL,
Expand All @@ -33,45 +102,26 @@ export default function TimelineDropdownMenu({
if (Liferay.FeatureFlags['LPD-20556']) {
const ctCollectionId = timelineItem.id;

const createMVCRenderCommandURL = (
mvcRenderCommandName,
additionalParams = {}
) => {
return createPortletURL(
themeDisplay.getLayoutRelativeControlPanelURL(),
{
ctCollectionId,
mvcRenderCommandName,
p_p_id: getPortletId(namespace),
...additionalParams,
}
).toString();
};

const discardURL = createMVCRenderCommandURL(
'/change_tracking/view_discard',
{
modelClassNameId: timelineClassNameId,
modelClassPK: timelineClassPK,
}
const discardURL = createDiscardURL(
ctCollectionId,
namespace,
timelineClassNameId,
timelineClassPK
);

const checkoutURL = createPortletURL(timelineEditURL, {
ctCollectionId,
}).toString();
const checkoutURL = createEditURL(ctCollectionId, timelineEditURL);

const moveURL = createMVCRenderCommandURL(
'/change_tracking/view_move_changes',
{
modelClassNameId: timelineClassNameId,
modelClassPK: timelineClassPK,
}
const moveURL = createMoveURL(
ctCollectionId,
namespace,
timelineClassNameId,
timelineClassPK
);
const viewURL = createMVCRenderCommandURL(
'/change_tracking/view_change',
{
ctEntryId: timelineItem.ctEntryId,
}

const viewURL = createViewURL(
ctCollectionId,
namespace,
timelineItem.ctEntryId
);

if (
Expand Down

0 comments on commit a78a295

Please sign in to comment.