Skip to content

Commit

Permalink
Shows working copy options for Plone Site
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleybl committed Oct 9, 2024
1 parent 0dcfb58 commit 9974e13
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 119 deletions.
4 changes: 2 additions & 2 deletions packages/volto/cypress/tests/workingCopy/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ describe('Working Copy Tests - Create', () => {
cy.findByText('View working copy');
});

it('Portal root does not have create option', function () {
it('Portal root have create option', function () {
cy.visit('/');
cy.get('#toolbar-more').click();
cy.get('.menu-more').contains('Create working copy').should('not.exist');
cy.get('.menu-more').contains('Create working copy').should('exist');
});
});
1 change: 1 addition & 0 deletions packages/volto/news/5284.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Shows working copy options for Plone Site. @wesleybl
233 changes: 116 additions & 117 deletions packages/volto/src/components/manage/Toolbar/More.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,125 +321,124 @@ const More = (props) => {
</>
)}
</Pluggable>
{config.settings.hasWorkingCopySupport &&
content['@type'] !== 'Plone Site' && (
<>
{!content.working_copy && (
<Plug pluggable="toolbar-more-manage-content" id="workingcopy">
<li>
<button
aria-label={intl.formatMessage(messages.CreateWorkingCopy)}
onClick={() => {
dispatch(createWorkingCopy(path)).then((response) => {
history.push(flattenToAppURL(response['@id']));
props.closeMenu();
});
}}
>
{intl.formatMessage(messages.CreateWorkingCopy)}
{config.settings.hasWorkingCopySupport && (
<>
{!content.working_copy && (
<Plug pluggable="toolbar-more-manage-content" id="workingcopy">
<li>
<button
aria-label={intl.formatMessage(messages.CreateWorkingCopy)}
onClick={() => {
dispatch(createWorkingCopy(path)).then((response) => {
history.push(flattenToAppURL(response['@id']));
props.closeMenu();
});
}}
>
{intl.formatMessage(messages.CreateWorkingCopy)}

<Icon name={rightArrowSVG} size="24px" />
</button>
</li>
</Plug>
)}
{content.working_copy && content.working_copy_of && (
<Plug pluggable="toolbar-more-manage-content" id="workingcopy">
<li>
<button
aria-label={intl.formatMessage(messages.applyWorkingCopy)}
onClick={() => {
dispatch(applyWorkingCopy(path)).then((response) => {
history.push(
flattenToAppURL(content.working_copy_of['@id']),
);
props.closeMenu();
toast.info(
<Toast
info
title={intl.formatMessage(
messages.workingAppliedTitle,
)}
content={intl.formatMessage(
messages.workingCopyAppliedBy,
{
creator: content.working_copy?.creator_name,
date: (
<FormattedDate
date={content.working_copy?.created}
format={dateOptions}
/>
),
},
)}
/>,
{
toastId: 'workingcopyapplyinfo',
autoClose: 10000,
},
);
});
}}
>
{intl.formatMessage(messages.applyWorkingCopy)}
<Icon name={rightArrowSVG} size="24px" />
</button>
</li>
</Plug>
)}
{content.working_copy && content.working_copy_of && (
<Plug pluggable="toolbar-more-manage-content" id="workingcopy">
<li>
<button
aria-label={intl.formatMessage(messages.applyWorkingCopy)}
onClick={() => {
dispatch(applyWorkingCopy(path)).then((response) => {
history.push(
flattenToAppURL(content.working_copy_of['@id']),
);
props.closeMenu();
toast.info(
<Toast
info
title={intl.formatMessage(
messages.workingAppliedTitle,
)}
content={intl.formatMessage(
messages.workingCopyAppliedBy,
{
creator: content.working_copy?.creator_name,
date: (
<FormattedDate
date={content.working_copy?.created}
format={dateOptions}
/>
),
},
)}
/>,
{
toastId: 'workingcopyapplyinfo',
autoClose: 10000,
},
);
});
}}
>
{intl.formatMessage(messages.applyWorkingCopy)}

<Icon
name={applySVG}
size="24px"
title={intl.formatMessage(messages.applyWorkingCopy)}
/>
</button>
</li>
<li>
<button
aria-label={intl.formatMessage(messages.removeWorkingCopy)}
onClick={() => {
dispatch(removeWorkingCopy(path)).then((response) => {
history.push(
flattenToAppURL(content.working_copy_of['@id']),
);
props.closeMenu();
toast.info(
<Toast
info
title={intl.formatMessage(
messages.workingCopyRemovedTitle,
)}
/>,
{
toastId: 'workingcopyremovednotice',
autoClose: 10000,
},
);
});
}}
>
{intl.formatMessage(messages.removeWorkingCopy)}
<Icon
name={removeSVG}
size="24px"
color="#e40166"
title={intl.formatMessage(messages.removeWorkingCopy)}
/>
</button>
</li>
</Plug>
)}
{content.working_copy && !content.working_copy_of && (
<Plug pluggable="toolbar-more-manage-content" id="workingcopy">
<li>
<Link
to={flattenToAppURL(content.working_copy['@id'])}
onClick={() => props.closeMenu()}
>
{intl.formatMessage(messages.viewWorkingCopy)}
<Icon name={rightArrowSVG} size="24px" />
</Link>
</li>
</Plug>
)}
</>
)}
<Icon
name={applySVG}
size="24px"
title={intl.formatMessage(messages.applyWorkingCopy)}
/>
</button>
</li>
<li>
<button
aria-label={intl.formatMessage(messages.removeWorkingCopy)}
onClick={() => {
dispatch(removeWorkingCopy(path)).then((response) => {
history.push(
flattenToAppURL(content.working_copy_of['@id']),
);
props.closeMenu();
toast.info(
<Toast
info
title={intl.formatMessage(
messages.workingCopyRemovedTitle,
)}
/>,
{
toastId: 'workingcopyremovednotice',
autoClose: 10000,
},
);
});
}}
>
{intl.formatMessage(messages.removeWorkingCopy)}
<Icon
name={removeSVG}
size="24px"
color="#e40166"
title={intl.formatMessage(messages.removeWorkingCopy)}
/>
</button>
</li>
</Plug>
)}
{content.working_copy && !content.working_copy_of && (
<Plug pluggable="toolbar-more-manage-content" id="workingcopy">
<li>
<Link
to={flattenToAppURL(content.working_copy['@id'])}
onClick={() => props.closeMenu()}
>
{intl.formatMessage(messages.viewWorkingCopy)}
<Icon name={rightArrowSVG} size="24px" />
</Link>
</li>
</Plug>
)}
</>
)}
{editAction && config.settings.isMultilingual && (
<Plug pluggable="toolbar-more-manage-content" id="multilingual">
<li>
Expand Down

0 comments on commit 9974e13

Please sign in to comment.