Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Rewrite Neos.Neos:Shortcut to pure fusion #3372

Merged
merged 10 commits into from
Nov 1, 2023
87 changes: 84 additions & 3 deletions Neos.Neos/Resources/Private/Fusion/Prototypes/Shortcut.fusion
Original file line number Diff line number Diff line change
@@ -1,15 +1,96 @@
# Neos.Neos.Shortcut is given a representation for editing purposes
#
prototype(Neos.Neos:Shortcut) < prototype(Neos.Fusion:Template) {
templatePath = 'resource://Neos.Neos/Private/Templates/FusionObjects/Shortcut.html'
prototype(Neos.Neos:Shortcut) < prototype(Neos.Neos:Page) {
head.stylesheets {
shortcut = afx`
<link rel="stylesheet" href={StaticResource.uri('Neos.Neos', 'Public/Styles/Shortcut.css')} />
`
}

body = afx`
<div id="neos-shortcut">
<p>
<Neos.Neos:Shortcut.Link />
</p>
</div>
`
}

/** @internal */
prototype(Neos.Neos:Shortcut.Link) < prototype(Neos.Fusion:Component) {
targetMode = ${q(node).property('targetMode')}
firstChildNode = ${q(node).children('[instanceof Neos.Neos:Document]').get(0)}
target = ${q(node).property('target')}
targetConverted = ${Neos.Link.hasSupportedScheme(this.target) ? Neos.Link.convertUriToObject(this.target, node) : null}
targetSchema = ${Neos.Link.getScheme(this.target)}

node = ${node}
i18n = ${I18n.id(null).package('Neos.Neos').source('Main').locale(Neos.Backend.interfaceLanguage())}

renderer = Neos.Fusion:Match {
@subject = ${props.targetMode}

selectedTarget = Neos.Fusion:Join {
@glue = '<br/>'
mainMessage = ${props.i18n.id('shortcut.toSpecificTarget').translate()}
targetSelected = Neos.Fusion:Match {
@if.isTarget = ${props.target}

@subject = ${props.targetSchema}

node = Neos.Fusion:Value {
targetUriTag = Neos.Neos:NodeLink {
node = ${props.targetConverted}
}
value = ${props.i18n.id('shortcut.clickToContinueToPage').arguments([this.targetUriTag]).translate()}
}

asset = Neos.Fusion:Value {
targetUriTag = Neos.Fusion:Tag {
tagName = 'a'
attributes {
target = '_blank'
href = Neos.Fusion:ResourceUri {
resource = ${props.targetConverted.resource}
}
}
content = ${props.targetConverted.label}
}
value = ${props.i18n.id('shortcut.clickToContinueToAsset').arguments([this.targetUriTag]).translate()}
}

@default = Neos.Fusion:Value {
targetUriTag = afx`
<a href={props.target} target='_blank'>{props.target}</a>
`
value = ${props.i18n.id('shortcut.clickToContinueToExternalUrl').arguments([this.targetUriTag]).translate()}
}
}

noTargetSelected = ${props.i18n.id('shortcut.noTargetSelected').translate()}
noTargetSelected.@if.isNotTarget = ${!props.target}
}

firstChildNode = Neos.Fusion:Value {
targetUriTag = Neos.Neos:NodeLink {
node = ${props.firstChildNode}
}
value = ${props.i18n.id('shortcut.clickToContinueToFirstChildNode').arguments([this.targetUriTag]).translate()}
}

parentNode = Neos.Fusion:Value {
targetUriTag = Neos.Neos:NodeLink {
node = ${q(node).parent().get(0)}
}
value = ${props.i18n.id('shortcut.clickToContinueToParentNode').arguments([this.targetUriTag]).translate()}
}
}

@cache {
mhsdesign marked this conversation as resolved.
Show resolved Hide resolved
mode = "uncached"
context {
0 = "node"
}
}

@exceptionHandler = 'Neos\\Neos\\Fusion\\ExceptionHandlers\\NodeWrappingHandler'
}
8 changes: 3 additions & 5 deletions Neos.Neos/Resources/Private/Fusion/RootCase.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
root = Neos.Fusion:Case
root {
shortcut {
prototype(Neos.Neos:Page) {
body = Neos.Neos:Shortcut
}

# this code path will only be taken for backend views, as the node controller
# will take care of resolving the shortcut in the frontend
@position = 'start'
condition = ${q(node).is('[instanceof Neos.Neos:Shortcut]')}
type = 'Neos.Neos:Page'
renderer = Neos.Neos:Shortcut
}

editPreviewMode {
Expand Down
mhsdesign marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
32 changes: 32 additions & 0 deletions Neos.Neos/Resources/Private/Styles/Shortcut.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#neos-shortcut {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $grayMedium;
z-index: 9999;
@include font;

p {
position: relative;
margin: 0 auto;
width: 500px;
height: 60px;
top: 50%;
margin-top: -30px;
color: #fff;
font-size: 22px;
line-height: 1.4;
text-align: center;

a {
color: $blue;
text-decoration: none;

&:hover {
color: $blueLight;
}
}
}
}
33 changes: 0 additions & 33 deletions Neos.Neos/Resources/Private/Styles/_Global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,3 @@
.neos-rendering-exception {
word-wrap: break-word;
}

#neos-shortcut {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $grayMedium;
z-index: 9999;
@include font;

p {
position: relative;
margin: 0 auto;
width: 500px;
height: 60px;
top: 50%;
margin-top: -30px;
color: #fff;
font-size: 22px;
line-height: 1.4;
text-align: center;

a {
color: $blue;
text-decoration: none;

&:hover {
color: $blueLight;
}
}
}
}
44 changes: 0 additions & 44 deletions Neos.Neos/Resources/Private/Templates/FusionObjects/Shortcut.html

This file was deleted.

1 change: 1 addition & 0 deletions Neos.Neos/Resources/Public/Styles/Shortcut.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Neos.Neos/webpack.styles.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ const stylesConfig = {
context: __dirname,
devtool: "source-map",
entry: {
Main: ["./Resources/Private/Styles/Neos.scss"],
Main: ["./Resources/Private/Styles/Main.scss"],
Lite: ["./Resources/Private/Styles/Lite.scss"],
Minimal: ["./Resources/Private/Styles/Minimal.scss"],
Login: ["./Resources/Private/Styles/Login.scss"],
Error: ["./Resources/Private/Styles/Error.scss"],
RawContentMode: ["./Resources/Private/Styles/RawContentMode.scss"],
Welcome: ["./Resources/Private/Styles/Welcome.scss"],
Shortcut: ["./Resources/Private/Styles/Shortcut.scss"],
},
output: {
path: __dirname + "/Resources/Public/Styles",
Expand Down
Loading