-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from punktDeForks/FEATURE/Create_Custom_Link
Add new link type CustomLink to be used as escape hatch if the other link types are insufficient for a desired use case.
- Loading branch information
Showing
10 changed files
with
194 additions
and
6 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
Neos.Ui/core/src/application/LinkTypes/CustomLink/CustomLink.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import * as React from 'react'; | ||
|
||
import {useI18n} from "@sitegeist/archaeopteryx-neos-bridge"; | ||
|
||
import {TextInput} from '@neos-project/react-ui-components'; | ||
|
||
import {ILink, makeLinkType} from "../../../domain"; | ||
import {Process, Field} from '../../../framework'; | ||
import {IconCard, IconLabel} from "../../../presentation"; | ||
import {Nullable} from 'ts-toolbelt/out/Union/Nullable'; | ||
|
||
type CustomLinkModel = { | ||
customLink: string, | ||
} | ||
|
||
export const CustomLink = makeLinkType<CustomLinkModel>('Sitegeist.Archaeopteryx:CustomLink', ({createError}) => ({ | ||
isSuitableFor: (link: ILink) => !link.href.startsWith('asset://') && !link.href.startsWith('mailto:') | ||
&& !link.href.startsWith('node://') && !link.href.startsWith('tel:') | ||
&& !link.href.startsWith('http://') && !link.href.startsWith('https://'), | ||
|
||
useResolvedModel: (link: ILink) => { | ||
return Process.success({ | ||
customLink: link.href, | ||
}); | ||
}, | ||
|
||
convertModelToLink: (model: CustomLinkModel) => { | ||
return {href: `${model.customLink}`}; | ||
}, | ||
|
||
TabHeader: () => { | ||
const i18n = useI18n(); | ||
|
||
return ( | ||
<IconLabel icon=""> | ||
{i18n('Sitegeist.Archaeopteryx:LinkTypes.CustomLink:title')} | ||
</IconLabel> | ||
); | ||
}, | ||
|
||
Preview: ({model}: { model: CustomLinkModel }) => { | ||
return ( | ||
<IconCard | ||
icon="" | ||
title={`<a href="${model.customLink}">...</a>`} | ||
/> | ||
) | ||
}, | ||
|
||
Editor: ({model}: { model: Nullable<CustomLinkModel> }) => { | ||
const i18n = useI18n(); | ||
|
||
return ( | ||
<div> | ||
<label> | ||
{i18n('Sitegeist.Archaeopteryx:LinkTypes.CustomLink:customLink.label')} | ||
</label> | ||
<div style={{display: 'grid', gridTemplateColumns: '400px 1fr', minWidth: '600px'}}> | ||
<Field<string> | ||
name="customLink" | ||
initialValue={model?.customLink} | ||
validate={ | ||
(value) => { | ||
if (!value) { | ||
return i18n('Sitegeist.Archaeopteryx:LinkTypes.CustomLink:validation.required'); | ||
} | ||
} | ||
} | ||
>{({input}) => ( | ||
<TextInput | ||
id={input.name} | ||
type="text" | ||
placeHolder={i18n('Sitegeist.Archaeopteryx:LinkTypes.CustomLink:customLink.placeholder')} | ||
{...input} | ||
/> | ||
)}</Field> | ||
</div> | ||
</div> | ||
); | ||
} | ||
})); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { CustomLink } from './CustomLink'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
Resources/Private/Translations/de/LinkTypes/CustomLink.xlf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2"> | ||
<file original="" product-name="Sitegeist.Archaeopteryx" source-language="en" datatype="plaintext" target-language="de"> | ||
<body> | ||
<trans-unit id="title" xml:space="preserve" approved="yes"> | ||
<source>Custom Link</source> | ||
<target>Beliebiger Link</target> | ||
</trans-unit> | ||
<trans-unit id="customLink.label" xml:space="preserve" approved="yes"> | ||
<source>Custom Link:</source> | ||
<target>Beliebiger Link:</target> | ||
</trans-unit> | ||
<trans-unit id="customLink.placeholder" xml:space="preserve" approved="yes"> | ||
<source>Enter your text here</source> | ||
<target>Hier ihren Text eingeben</target> | ||
</trans-unit> | ||
<trans-unit id="validation.required" xml:space="preserve" approved="yes"> | ||
<source>This field is required</source> | ||
<target>Dieses Feld ist erforderlich</target> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
19 changes: 19 additions & 0 deletions
19
Resources/Private/Translations/en/LinkTypes/CustomLink.xlf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2"> | ||
<file original="" product-name="Sitegeist.Archaeopteryx" source-language="en" datatype="plaintext"> | ||
<body> | ||
<trans-unit id="title" xml:space="preserve" approved="yes"> | ||
<source>Custom Link</source> | ||
</trans-unit> | ||
<trans-unit id="customLink.label" xml:space="preserve" approved="yes"> | ||
<source>Custom Link:</source> | ||
</trans-unit> | ||
<trans-unit id="customLink.placeholder" xml:space="preserve" approved="yes"> | ||
<source>Enter your text here</source> | ||
</trans-unit> | ||
<trans-unit id="validation.required" xml:space="preserve" approved="yes"> | ||
<source>This field is required</source> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
23 changes: 23 additions & 0 deletions
23
Resources/Private/Translations/fr/LinkTypes/CustomLink.xlf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2"> | ||
<file original="" product-name="Sitegeist.Archaeopteryx" source-language="en" datatype="plaintext" target-language="fr"> | ||
<body> | ||
<trans-unit id="title" xml:space="preserve" approved="yes"> | ||
<source>Custom Link</source> | ||
<target>Lien personnalisé</target> | ||
</trans-unit> | ||
<trans-unit id="customLink.label" xml:space="preserve" approved="yes"> | ||
<source>Custom Link:</source> | ||
<target>Lien personnalisé:</target> | ||
</trans-unit> | ||
<trans-unit id="customLink.placeholder" xml:space="preserve" approved="yes"> | ||
<source>Enter your text here</source> | ||
<target>Entrez votre texte ici</target> | ||
</trans-unit> | ||
<trans-unit id="validation.required" xml:space="preserve" approved="yes"> | ||
<source>This field is required</source> | ||
<target>Ce champ est nécessaire</target> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
Large diffs are not rendered by default.
Oops, something went wrong.