Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/1.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
breart committed Jan 3, 2018
2 parents 62459b2 + 2a956bb commit d8eec46
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 36 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.2.1] - 2018-01-03

### Fixed
- Register the listeners in the subscriber instead of putting to the **EventServiceProvider**
- Fixed and improved README

## [1.2.0] - 2017-09-24

### Added
Expand Down Expand Up @@ -39,7 +45,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
- Package keywords at composer.json

[Unreleased]: https://github.com/brezzhnev/atlassian-connect-core/compare/v1.2.0...HEAD
[Unreleased]: https://github.com/brezzhnev/atlassian-connect-core/compare/v1.2.1...HEAD
[1.2.1]: https://github.com/brezzhnev/atlassian-connect-core/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/brezzhnev/atlassian-connect-core/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/brezzhnev/atlassian-connect-core/compare/v1.0.2...v1.1.0
[1.0.2]: https://github.com/brezzhnev/atlassian-connect-core/compare/v1.0.1...v1.0.2
Expand Down
99 changes: 64 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ Install dependency via Composer
$ composer require brezzhnev/atlassian-connect-core
```

Register **route middleware** `jwt` by adding to the `app\Http\Kernel.php` following line
Register **route middleware** `jwt` by adding to `app\Http\Kernel.php` the following line:

``` php
'jwt' => \AtlassianConnectCore\Http\Middleware\JWTAuth::class
```

Set authentication driver to `jwt` in `config/auth.php`
Set authentication driver to `jwt` in `config/auth.php`:

``` php
'guards' => [
Expand All @@ -40,7 +40,7 @@ Set authentication driver to `jwt` in `config/auth.php`
...
```

Set model class in `config/auth.php` **providers** section
Set model class in `config/auth.php` **providers** section:

``` php
'providers' => [
Expand All @@ -51,22 +51,9 @@ Set model class in `config/auth.php` **providers** section
...
```

Register plugin events by adding to the `app/Providers/EventServiceProvider.php` to the `listen` property value following
Register the subscriber in the `app/Providers/EventServiceProvider.php`:

``` php
\AtlassianConnectCore\Events\Installed::class => [
\AtlassianConnectCore\Listeners\CreateOrUpdateTenant::class
],
\AtlassianConnectCore\Events\Uninstalled::class => [
\AtlassianConnectCore\Listeners\DeleteTenant::class
]
```

> You can use any add-on events to register your own listeners
Register subscriber in the same file:

```
/**
* The subscriber classes to register.
*
Expand All @@ -77,32 +64,34 @@ protected $subscribe = [
];
```

Configure database and run
Configure database and run the following:

```
php artisan migrate
php artisan plugin:install
```

Command `php artisan plugin:install` will publish config, views and resources that you can change whatever you want.
The command `php artisan plugin:install` will publish config, views and resources that you can change for your needs.

Also, it will create "dummy" tenant needed for local testing and development
without the need of installing the add-on in real JIRA or Confluence instance.

### Get it working

If your application returns the add-on descriptor on the request
to URL `http://localhost:8000/atlassian-connect.json` it means you are close to getting it working and you can
to URL `http://localhost:8000/atlassian-connect.json` it means you are close to happiness and you can
install the add-on.

Firstly, you need to enable development options.
Go to the "Manage add-ons" page. You'll see the link "Settings" at bottom of page.
Firstly, you need to enable the development options.
Go to the "Manage add-ons" page. You'll see the link "Settings" at bottom of the page.
After clicking you'll see two checkboxes that must be selected. Apply your changes.

For installing the add-on in the instance it should see your server.
If you working locally the easiest way is use [ngrok](https://ngrok.com/).
For installing the add-on in the instance, the last one should see your server.
If you are working locally the easiest way is to use [ngrok](https://ngrok.com/).

After you are visible for the JIRA or Atlassian instance you should put your actual website URL to environment variable `PLUGIN_URL`. Also, you need to configure your add-on by editing the file `config/plugin.php`. Most values may be overwritten using env vars.
After you are visible in the worldwide you should put your actual website URL to environment variable `PLUGIN_URL`.
Also, you need to configure your add-on by editing the file `config/plugin.php`.
Most values may be overwritten using env vars.

Then you need to upload the add-on. Click "Upload add-on" and paste your public URL with descriptor path,
eg. `https://d1ea31ce.ngrok.io/atlassian-connect.json` or `https://yourplugindomain.com/atlassian-connect.json`
Expand All @@ -112,32 +101,33 @@ eg. `https://d1ea31ce.ngrok.io/atlassian-connect.json` or `https://yourplugindom
After successfully installing you can see "Your add-on" top menu item (in case of JIRA).
You also can go to the add-on general page by direct link `:product_base_url/plugins/servlet/ac/sample-plugin/hello-page`

Instead `:product_base_url` you should put your JIRA or Cofluence instance URL (eg. `https://google-dev.atlassian.net`).
> Instead `:product_base_url` you should put your JIRA or Cofluence instance URL (eg. `https://google-dev.atlassian.net`).
If you see page working, the application configured and add-on installed correctly.

### Publish resources

Instead of using `plugin:install` you can perform actions manually.

To copy all publishes you should use following commands:
To copy all the publishes you should use the following command:

```
artisan vendor:publish --provider="AtlassianConnectCore\ServiceProvider"
php artisan vendor:publish --provider="AtlassianConnectCore\ServiceProvider"
```

To copy only specific publish you must call this command with option `--tag`.
Value can be `public` (to copy assets), `views` and `config`.
The value can be `public` (to copy assets), `views` and `config`.

## Workflow

### Add-On Configuration

After copying publishes you can see the file `config/plugin.php` in your application. Please, use this configuration file to change add-on properties.
After copying publishes you can see the file `config/plugin.php` in your application.
Please, use this configuration file to change add-on properties.

### Default routes

The following routes registered by default
The following routes are registered by default:

* `GET /atlassian-connect.json` descriptor contents
* `POST /installed` add-on installed callback
Expand All @@ -146,7 +136,7 @@ The following routes registered by default
* `POST /disabled` add-on disabled callback
* `GET /hello` sample page to persuade all working correctly

You can disable it by setting to `false` config value `plugin.loadRoutes`.
You can disable them by setting to `false` config value `plugin.loadRoutes`.

### Descriptor

Expand All @@ -170,10 +160,11 @@ Descriptor::base() // base descriptor contents
### Performing requests

In most of cases in development add-on for Atlassian Product you need to perform requests to the instance.
In most cases of add-on development for Atlassian Product you need to perform requests to the instance.

For this case you can use `JWTClient`. It uses [GuzzleHttp](https://github.com/guzzle/guzzle) as HTTP client.

For this case you should use `JWTClient`. It uses [GuzzleHttp](https://github.com/guzzle/guzzle) as HTTP client and
if you want to have custom handling (middlewares etc.) you can pass client instance to the constructor.
> If you want to have custom handling (middlewares etc.) you can pass client instance to the constructor.
#### Pagination

Expand All @@ -187,6 +178,44 @@ There are two paginators:

Of course you can extend `Paginator` class and create your own.

#### Examples

**Get a Confluence page content**

``` php
use AtlassianConnectCore\Http\Clients\JWTClient;

...


public function pageContent(int $id): array
{
$client = new JWTClient($this->tenant); // or Auth::user() if you performing a request from the instance

return $client->get('rest/api/content/ . $id', [
'query' => [
'expand' => 'body.storage'
]
]);
}
```

**Get a JIRA issue**

``` php
use AtlassianConnectCore\Http\Clients\JWTClient;

...


public function viewIssue(string $key): array
{
$client = new JWTClient($this->tenant);

return $client->get('rest/api/2/issue/ . $key');
}
```

### Console commands

* `plugin:install` is a helper command that creates "dummy" tenant with fake data and publishes package resources (config, views, assets)
Expand Down
3 changes: 3 additions & 0 deletions src/Listeners/PluginEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class PluginEventSubscriber
*/
public function subscribe($events)
{
$events->listen(\AtlassianConnectCore\Events\Installed::class, CreateOrUpdateTenant::class);
$events->listen(\AtlassianConnectCore\Events\Uninstalled::class, DeleteTenant::class);

$events->listen([
\AtlassianConnectCore\Events\Installed::class,
\AtlassianConnectCore\Events\Uninstalled::class,
Expand Down

0 comments on commit d8eec46

Please sign in to comment.