Skip to content

Commit

Permalink
FEATURE: Add role that disables simplified publish button and allows …
Browse files Browse the repository at this point in the history
…workspace selection to editor
  • Loading branch information
gradinarufelix committed Mar 11, 2024
1 parent 62b42ab commit b30f1f4
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 50 deletions.
5 changes: 5 additions & 0 deletions Configuration/Policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ roles:
# - privilegeTarget: 'CodeQ.AdvancedPublish:Publication.canViewOwn'
# permission: GRANT

'CodeQ.AdvancedPublish:SuperEditor':
abstract: true
description: >-
Can access the normal publish dropdown and use different workspaces
privileged: []

'Neos.Neos:Administrator':
privileges:
Expand Down
1 change: 1 addition & 0 deletions Configuration/Settings.NeosUserInterface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Neos:
'CodeQ.AdvancedPublish':
enabled: '${Configuration.setting("CodeQ.AdvancedPublish.enabled")}'
iframeUri: '/neos/advancedpublish/new?inEmbedMode=true'
isSuperEditor: '${Security.hasRole("CodeQ.AdvancedPublish:SuperEditor")}'
97 changes: 51 additions & 46 deletions Resources/Private/NeosUserInterface/src/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,64 +11,69 @@ import {useSelector, useDispatch} from 'react-redux';
import PublishDropDown from './neos-ui/PublishDropDown'

const Modal = (({iframeUri}) => {
const isOpen = useSelector(selectors.advancedPublishDialogOpen);
const iframeRef = React.useRef(null);
const dispatch = useDispatch();
const isOpen = useSelector(selectors.advancedPublishDialogOpen);
const iframeRef = React.useRef(null);
const dispatch = useDispatch();

const setExit = React.useCallback(() => {
const iframeWindow = iframeRef.current?.contentWindow;
if (!iframeWindow) {
return;
}
const setExit = React.useCallback(() => {
const iframeWindow = iframeRef.current?.contentWindow;
if (!iframeWindow) {
return;
}
window.addEventListener('message', (event) => {
if (event.data === 'closePublicationPopup') {
dispatch(actions.toggleAdvancedPublishDialog({open: false}));
}
})
}, [])
}, [])

if (!isOpen) {
return "";
}
if (!isOpen) {
return "";
}

return <iframe
ref={iframeRef}
onLoad={setExit}
style={{
width: "100%",
height: "100%",
position: "absolute",
zIndex: "999999",
top: "0",
background: "#000",
border: "0"
}}
src={iframeUri}
/>;
return <iframe
ref={iframeRef}
onLoad={setExit}
style={{
width: "100%",
height: "100%",
position: "absolute",
zIndex: "999999",
top: "0",
background: "#000",
border: "0"
}}
src={iframeUri}
/>;
})

manifest("CodeQ.AdvancedPublish", {}, (globalRegistry, {frontendConfiguration}) => {
if (!frontendConfiguration["CodeQ.AdvancedPublish"].enabled) {
return
}
const frontendConfigurationElement: {
enabled: boolean,
isSuperEditor: boolean,
iframeUri: string
} = frontendConfiguration["CodeQ.AdvancedPublish"];
if (!frontendConfigurationElement.enabled || frontendConfigurationElement.isSuperEditor === true) {
return
}

function* afterPublish() {
yield takeLatest(actionTypes.CR.Workspaces.PUBLISH, function* () {
const {payload} = yield take(actionTypes.ServerFeedback.HANDLE_SERVER_FEEDBACK)
if (!payload.feedbackEnvelope.feedbacks.some((feedback) => feedback.type === "Neos.Neos.Ui:Success")) {
console.warn(`CodeQ.AdvancedPublish :: Publishing doesnt seem to have been successful. Aborting.`)
return;
}
yield put(actions.toggleAdvancedPublishDialog())
})
}
function* afterPublish() {
yield takeLatest(actionTypes.CR.Workspaces.PUBLISH, function* () {
const {payload} = yield take(actionTypes.ServerFeedback.HANDLE_SERVER_FEEDBACK)
if (!payload.feedbackEnvelope.feedbacks.some((feedback) => feedback.type === "Neos.Neos.Ui:Success")) {
console.warn(`CodeQ.AdvancedPublish :: Publishing doesnt seem to have been successful. Aborting.`)
return;
}
yield put(actions.toggleAdvancedPublishDialog())
})
}

globalRegistry.get('containers').set('Modals/CodeQ.AdvancedPublish', () => ReactDOM.createPortal(
<Modal iframeUri={frontendConfiguration["CodeQ.AdvancedPublish"].iframeUri}/>,
document.body
));
globalRegistry.get('sagas').set('CodeQ.AdvancedPublish/afterPublish', { saga: afterPublish });
globalRegistry.get('reducers').set('CodeQ.AdvancedPublish', { reducer });
globalRegistry.get('containers').set('Modals/CodeQ.AdvancedPublish', () => ReactDOM.createPortal(
<Modal iframeUri={frontendConfigurationElement.iframeUri}/>,
document.body
));
globalRegistry.get('sagas').set('CodeQ.AdvancedPublish/afterPublish', {saga: afterPublish});
globalRegistry.get('reducers').set('CodeQ.AdvancedPublish', {reducer});

globalRegistry.get('containers').set('PrimaryToolbar/Right/PublishDropDown', PublishDropDown);
globalRegistry.get('containers').set('PrimaryToolbar/Right/PublishDropDown', PublishDropDown);
});
Loading

0 comments on commit b30f1f4

Please sign in to comment.