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

SS4 compatibility #11

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
18 changes: 3 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,12 @@ jobs:

working_directory: ~/var/www

branches:
only:
- master
- develop
- /feature.*/

steps:
# Install additional requirements

- run: composer create-project silverstripe/installer:~3 ~/var/www -n
- run: composer require firesphere/stripeslack:dev-master
- run: composer update -n --prefer-dist
- run: rm phpunit.xml.dist
- run: cp stripeslack/phpunit.xml.dist .
- run: cp stripeslack/.env.php ~/var/www/_ss_environment.php
- run: framework/sake dev/build
- run: composer create-project firesphere/stripeslack:ss4-dev -n -s dev ~/var/www
- run: vendor/silverstripe/framework/sake dev/build

# run tests!
- run: vendor/bin/phpunit -d memory_limit=1G --coverage-clover=coverage.xml stripeslack/tests/unit
- run: vendor/bin/phpunit -d memory_limit=1G --coverage-clover=coverage.xml tests
- run: bash <(curl -s https://codecov.io/bash) -f coverage.xml

16 changes: 16 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
engines:
duplication:
enabled: true
config:
languages:
- php
fixme:
enabled: true
phpmd:
enabled: true
ratings:
paths:
- "**.php"
exclude_paths:
- tests/*
17 changes: 17 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
checks:
php: true

build:
nodes:
analysis:
tests:
override: [php-scrutinizer-run]

filter:
paths: ["src/*", "tests/*"]
excluded_paths:
- "tests/mock/"
- "src/actions"
- "src/admins"
- "src/extensions"
- "src/pages"
5 changes: 4 additions & 1 deletion _config.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?php

ShortcodeParser::get()->register('stripeslack', ['StripeSlackShortcodeParser', 'stripeslackHandler']);
use Firesphere\StripeSlack\Parsers\StripeSlackShortcodeParser;
use SilverStripe\View\Parsers\ShortcodeParser;

ShortcodeParser::get()->register('stripeslack', [StripeSlackShortcodeParser::class, 'handle_shortcode']);
8 changes: 4 additions & 4 deletions _config/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SiteConfig:
SilverStripe\SiteConfig\SiteConfig:
extensions:
- StripeSlackSiteConfigExtension
ContentController:
- Firesphere\StripeSlack\Extension\SiteConfigExtension
SilverStripe\CMS\Controllers\ContentController:
extensions:
- SlackControllerExtension
- Firesphere\StripeSlack\Extension\ControllerExtension
5 changes: 3 additions & 2 deletions _config/routes.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
Name: stripeslackroutes
---
Director:
SilverStripe\Control\Director:
rules:
'SlackAuthorization': SlackAuthController
'SlackAuthorization': Firesphere\StripeSlack\Controller\SlackAuthController
'SlackStatus//$Action/$ID/$OtherID': Firesphere\StripeSlack\Controller\SlackStatusController
11 changes: 0 additions & 11 deletions code/shortcodes/StripeSlackShortcodeParser.php

This file was deleted.

11 changes: 5 additions & 6 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
fixes:
- "stripeslack/code::code"
ignore: # Ignoring irrelevant code. Default SS stuff should not be called out by Codecoverage
- "code/actions"
- "code/admins"
- "code/extensions"
- "code/forms"
- "src/actions"
- "src/admins"
- "src/extensions"
- "src/forms"
- "src/models"
25 changes: 16 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "firesphere/stripeslack",
"description": "Easy invite new users to your slack group",
"type": "silverstripe-module",
"type": "silverstripe-vendormodule",
"keywords": [
"silverstripe",
"slack",
Expand All @@ -17,18 +17,25 @@
}
],
"require": {
"silverstripe/framework": "~3.1",
"silverstripe/cms": "~3.1"
"silverstripe/recipe-cms": "1.x-dev",
"guzzlehttp/guzzle": "~6.0"
},
"require-dev": {
"phpunit/PHPUnit": "^5.7",
"scriptfusion/phpunit-immediate-exception-printer": "^2.0"
},
"extra": {
"installer-name": "stripeslack",
"branch-alias": {
"dev-master": "1.x-dev"
"autoload": {
"psr-4": {
"Firesphere\\StripeSlack\\Form\\": "src/forms",
"Firesphere\\StripeSlack\\Page\\": "src/pages",
"Firesphere\\StripeSlack\\Admin\\": "src/admins",
"Firesphere\\StripeSlack\\Parser\\": "src/shortcodes",
"Firesphere\\StripeSlack\\Extension\\": "src/extensions",
"Firesphere\\StripeSlack\\Controller\\": "src/controllers"
}
},
"target-dir": "stripeslack"
"extra": {
"installer-name": "stripeslack"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing expose here for your image directory

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good one, should be fixed by now :)

},
"minimum-stability": "dev",
"prefer-stable": true
}
9 changes: 7 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<phpunit printerClass="ScriptFUSION\PHPUnitImmediateExceptionPrinter\ImmediateExceptionPrinter"
bootstrap="framework/tests/bootstrap.php"
bootstrap="vendor/silverstripe/framework/tests/bootstrap.php"
colors="true">

<testsuite name="Default">
<directory>stripeslack/tests</directory>
<directory>tests</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<groups>
<exclude>
Expand Down
7 changes: 7 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Badger Badger Badger, Mushroom Mushroom!
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Firesphere/silverstripe-stripeslack/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Firesphere/silverstripe-stripeslack/?branch=master)
[![codecov](https://codecov.io/gh/Firesphere/silverstripe-stripeslack/branch/master/graph/badge.svg)](https://codecov.io/gh/Firesphere/silverstripe-stripeslack)
[![CircleCI](https://circleci.com/gh/Firesphere/silverstripe-stripeslack/tree/master.svg?style=svg)](https://circleci.com/gh/Firesphere/silverstripe-stripeslack/tree/master)
[![Maintainability](https://api.codeclimate.com/v1/badges/0cb79fe7bfa3c2bc39f0/maintainability)](https://codeclimate.com/github/Firesphere/silverstripe-stripeslack/maintainability)


# StripeSlack

Inviting users to your public Slack channel is pretty hard to automate.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
<?php

namespace Firesphere\StripeSlack\Actions;

use SilverStripe\Control\Controller;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridField_ActionProvider;
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
use SilverStripe\Forms\GridField\GridField_FormAction;
use SilverStripe\ORM\FieldType\DBHTMLText;
use SilverStripe\SiteConfig\SiteConfig;
use Firesphere\StripeSlack\Model\SlackInvite;
use SilverStripe\ORM\ValidationException;

/**
* class GridfieldInviteResendAction adds the resend button to the CMS for easy re-inviting
*/
Expand Down Expand Up @@ -47,34 +59,29 @@ public function getColumnsHandled($gridField)
* @param GridField $gridField
* @param SlackInvite $record
* @param string $columnName
* @return HTMLText
* @return DBHTMLText
*/
public function getColumnContent($gridField, $record, $columnName)
{
$config = SiteConfig::current_site_config();
// No point in showing the re-send button, if there's no token
if ($config->SlackToken) {
$field = $this->getGridField($gridField, $record);

if (!$record->Invited) {
$field = GridField_FormAction::create(
$gridField, 'Retry' . $record->ID, false, 'resend', ['RecordID' => $record->ID]
)
->addExtraClass('gridfield-button-resend')
$field
->setAttribute('title', 'Retry invite')
->setAttribute('data-icon', 'arrow-circle-135-left')
->setDescription(_t('GridfieldInviteResendAction.Resend', 'Retry failed invitation'));
} else {
$field = GridField_FormAction::create(
$gridField, 'Resend', false, 'resend', ['RecordID' => $record->ID]
)
->addExtraClass('gridfield-button-resend')
$field
->setAttribute('title', 'Resend invite')
->setAttribute('data-icon', 'arrow-circle-double')
->setDescription('Resend invite');
}

return $field->Field();
}

}

/**
Expand All @@ -90,7 +97,7 @@ public function getActions($gridField)
* @param $actionName
* @param $arguments
* @param $data
* @throws \ValidationException
* @throws ValidationException
*/
public function handleAction(GridField $gridField, $actionName, $arguments, $data)
{
Expand All @@ -102,7 +109,7 @@ public function handleAction(GridField $gridField, $actionName, $arguments, $dat
}

$result = $item->resendInvite();
if ($result === true) {
if ($result) {
Controller::curr()->getResponse()->setStatusCode(
200,
'User successfully invited.'
Expand All @@ -116,4 +123,21 @@ public function handleAction(GridField $gridField, $actionName, $arguments, $dat
}
}

/**
* @param $gridField
* @param $record
* @return GridField_FormAction
*/
private function getGridField($gridField, $record)
{
$field = GridField_FormAction::create(
$gridField,
'Resend' . $record->ID,
false,
'resend',
['RecordID' => $record->ID]
)->addExtraClass('gridfield-button-resend');

return $field;
}
}
12 changes: 8 additions & 4 deletions code/admins/SlackAdmin.php → src/admins/SlackAdmin.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
<?php

namespace Firesphere\StripeSlack\Admin;

use Firesphere\StripeSlack\Actions\GridfieldInviteResendAction;
use Firesphere\StripeSlack\Model\SlackInvite;
use SilverStripe\Admin\ModelAdmin;

/**
* Class SlackAdmin
*
*/
class SlackAdmin extends ModelAdmin
{

private static $managed_models = [
'SlackInvite'
SlackInvite::class
];

private static $url_segment = 'SlackInvite';

private static $menu_title = 'Slack Invites';

private static $menu_icon = '/stripeslack/img/slack_logo.png';
private static $menu_icon = 'stripeslack/img/slack_logo.png';


public function getEditForm($id = null, $fields = null)
Expand All @@ -35,4 +39,4 @@ public function getEditForm($id = null, $fields = null)

return $form;
}
}
}
Loading