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

v2: Update namespace, dependencies. Add PhoneLink & migration task #54

Merged
merged 18 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
client/dist/
client/lang/
client/
chrispenny marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
ci:
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1
12 changes: 0 additions & 12 deletions .scrutinizer.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

57 changes: 32 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,66 @@
# Silverstripe link module

Experimental module looking at how we could implement a link field and a link data object.
This module provides a Link model and CMS interface for managing different types of links. Including:

* Emails
* External links
* Links to pages within the CMS
* Links to assets within the CMS
* Phone numbers

## Installation

Installation via composer.

### Stable version (GraphQL v3)

`composer require silverstripe/linkfield 1.x-dev`

### Experimental version (GraphQL v4)
### GraphQL v4 - Silverstripe 4

`composer require silverstripe/linkfield 2.x-dev`
`composer require silverstripe/linkfield`

### Known issues
### GraphQL v3 - Silverstripe 4

You may need to add the repository URL into your `composer.json` via the `repositories` field (example below).

```json
"repositories": {
"silverstripe/linkfield": {
"type": "git",
"url": "https://github.com/silverstripe/silverstripe-linkfield.git"
}
},
```
`composer require silverstripe/linkfield:^1`

## Sample usage

```php
<?php
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Link\DBLink;
use SilverStripe\Link\Link;
use SilverStripe\Link\LinkField;
use SilverStripe\LinkField\DBLink;
use SilverStripe\LinkField\Link;
use SilverStripe\LinkField\LinkField;

class Page extends SiteTree
{
private static $db = [
private static array $db = [
'DbLink' => DBLink::class
];

private static $has_one = [
private static array $has_one = [
'HasOneLink' => Link::class,
];

public function getCMSFields()
{
$fields = parent::getCMSFields();

$fields->insertBefore('Title', LinkField::create('HasOneLink'));
$fields->insertBefore('Title', LinkField::create('DbLink'));
$fields->addFieldsToTab(
'Root.Main',
[
LinkField::create('HasOneLink'),
LinkField::create('DbLink'),
]
)

return $fields;
}
}
```

## Migrating from Shae Dawson's Linkable module

https://github.com/sheadawson/silverstripe-linkable

Shae Dawson's Linkable module was a much loved, and much used module. It is, unfortunately, no longer maintained. We
have provided some steps and tasks that we hope can be used to migrate your project from Linkable to LinkField.

* [Migraiton docs](docs/en/linkable-migration.md)
8 changes: 4 additions & 4 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ Name: linkfield

SilverStripe\Admin\LeftAndMain:
extensions:
- SilverStripe\Link\Extensions\LeftAndMain
- SilverStripe\LinkField\Extensions\LeftAndMain

SilverStripe\Admin\ModalController:
extensions:
- SilverStripe\Link\Extensions\ModalController
- SilverStripe\LinkField\Extensions\ModalController

SilverStripe\Forms\TreeDropdownField:
extensions:
- SilverStripe\Link\Extensions\AjaxField
- SilverStripe\LinkField\Extensions\AjaxField

SilverStripe\CMS\Forms\AnchorSelectorField:
extensions:
- SilverStripe\Link\Extensions\AjaxField
- SilverStripe\LinkField\Extensions\AjaxField
13 changes: 8 additions & 5 deletions _config/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
Name: linkfield-types
---

SilverStripe\Link\Type\Registry:
SilverStripe\LinkField\Type\Registry:
types:
cms:
classname: SilverStripe\Link\Models\SiteTreeLink
classname: SilverStripe\LinkField\Models\SiteTreeLink
enabled: true
external:
classname: SilverStripe\Link\Models\ExternalLink
classname: SilverStripe\LinkField\Models\ExternalLink
enabled: true
file:
classname: SilverStripe\Link\Models\FileLink
classname: SilverStripe\LinkField\Models\FileLink
enabled: true
email:
classname: SilverStripe\Link\Models\EmailLink
classname: SilverStripe\LinkField\Models\EmailLink
enabled: true
phone:
classname: SilverStripe\LinkField\Models\PhoneLink
enabled: true
4 changes: 2 additions & 2 deletions _graphql/queries.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'readLinkDescription(dataStr: String!)':
type: LinkDescription
resolver: ['SilverStripe\Link\GraphQL\LinkDescriptionResolver', 'resolve']
resolver: ['SilverStripe\LinkField\GraphQL\LinkDescriptionResolver', 'resolve']
'readLinkTypes(keys: [ID])':
type: '[LinkType]'
resolver: ['SilverStripe\Link\GraphQL\LinkTypeResolver', 'resolve']
resolver: ['SilverStripe\LinkField\GraphQL\LinkTypeResolver', 'resolve']
Loading