Skip to content

Commit 90870dc

Browse files
committed
hello
0 parents  commit 90870dc

File tree

17 files changed

+6962
-0
lines changed

17 files changed

+6962
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
indent_size = 4
9+
indent_style = space
10+
end_of_line = lf
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/.travis.yml export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/.scrutinizer.yml export-ignore
10+
/tests export-ignore
11+
/.editorconfig export-ignore

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
docs/
2+
build/
3+
vendor/
4+
coverage/
5+
node_modules/
6+
resources/dist/app.js.LICENSE.txt
7+
resources/dist/mix-manifest.json
8+
composer.lock

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 1.0.0 - 201X-XX-XX
4+
5+
- Initial release

CONTRIBUTING.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
Please read and understand the contribution guide before creating an issue or pull request.
6+
7+
## Etiquette
8+
9+
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10+
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11+
extremely unfair for them to suffer abuse or anger for their hard work.
12+
13+
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14+
world that developers are civilized and selfless people.
15+
16+
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17+
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
18+
19+
## Viability
20+
21+
When requesting or submitting new features, first consider whether it might be useful to others. Open
22+
source projects are used by many developers, who may have entirely different needs to your own. Think about
23+
whether or not your feature is likely to be used by other users of the project.
24+
25+
## Procedure
26+
27+
Before filing an issue:
28+
29+
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30+
- Check to make sure your feature suggestion isn't already present within the project.
31+
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32+
- Check the pull requests tab to ensure that the feature isn't already in progress.
33+
34+
Before submitting a pull request:
35+
36+
- Check the codebase to ensure that your feature doesn't already exist.
37+
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38+
39+
## Requirements
40+
41+
If the project maintainer has any additional requirements, you will find them listed here.
42+
43+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
44+
45+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
46+
47+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
48+
49+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
50+
51+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
52+
53+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
54+
55+
**Happy coding**!

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Danilo Polani
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Nop for Filament
2+
3+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/nop-app/filament.svg?style=flat-square)](https://packagist.org/packages/nop-app/filament)
4+
[![Total Downloads](https://img.shields.io/packagist/dt/nop-app/filament.svg?style=flat-square)](https://packagist.org/packages/nop-app/filament)
5+
6+
Integrate Nop with [Filament](https://filamentadmin.com). The package will enable Nop on all the edit pages of your Filament admin dashboard, e.g. `/admin/resources/projects/<id>/edit`, preventing multiple users to access the same page simultaneously.
7+
8+
## Installation
9+
10+
Install the package via composer:
11+
12+
```bash
13+
composer require nop-app/filament
14+
```
15+
16+
Then publish the package config file and assets as well:
17+
18+
```bash
19+
php artisan vendor:publish --tag=nop-config
20+
php artisan vendor:publish --tag=nop-assets
21+
```
22+
23+
### Upgrade
24+
When upgrading, you may want to republish the assets:
25+
26+
```bash
27+
php artisan vendor:publish --tag=nop-assets --force
28+
```
29+
30+
## Configuration
31+
32+
There are a few notable configuration options for the package.
33+
34+
Key | Type | Description
35+
------------ | ------------- | -------------
36+
`token` | String | Your Nop token. If you don't have a project yet, create one for free at https://nop.is/account/projects/create.
37+
`enabled_routes` | Array | List of routes (RegExp) where Nop should be enabled. By default it will be enabled in every "resource" edit page.
38+
`user_name_field` | String\|Null | The field corresponding to current authenticated user "name".
39+
`settings` | Array | Additional Nop settings. You can take a look to the [official Docs](https://docs.nop.is/usage/settings.html) to find out more.
40+
41+
### Advanced user name
42+
43+
If you need advanced logic for the user "name" field, you can set `user_name_field` to `null` in your `config/nop.php` file and then, although it's not defined in the values, set the `nop.name` config.
44+
For example in a middleware you can do:
45+
46+
```php
47+
// app/Http/Middleware/NopUser.php
48+
49+
<?php
50+
51+
namespace App\Http\Middleware;
52+
53+
use Closure;
54+
use Illuminate\Support\Facades\Config;
55+
56+
class NopUser
57+
{
58+
/**
59+
* Handle an incoming request.
60+
*
61+
* @param \Illuminate\Http\Request $request
62+
* @param \Closure $next
63+
* @return mixed
64+
*/
65+
public function handle($request, Closure $next)
66+
{
67+
if (Auth::check()) {
68+
Config::set('nop.user', $userName);
69+
}
70+
71+
return $next($request);
72+
}
73+
}
74+
```
75+
76+
## Contributing
77+
78+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
79+
80+
### Security
81+
82+
If you discover any security related issues, please email danilo.polani@gmail.com instead of using the issue tracker.
83+
84+
## Credits
85+
86+
- [Danilo Polani](https://github.com/danilopolani)
87+
- [All Contributors](../../contributors)
88+
89+
## License
90+
91+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
92+
93+
## Laravel Package Boilerplate
94+
95+
This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

composer.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"name": "nop-app/filament",
3+
"description": "Nop integration for Filament admin dashboard",
4+
"keywords": [
5+
"nop",
6+
"filament",
7+
"filament-admin"
8+
],
9+
"homepage": "https://github.com/nop-app/filament",
10+
"license": "MIT",
11+
"type": "library",
12+
"authors": [
13+
{
14+
"name": "Danilo Polani",
15+
"email": "danilo.polani@gmail.com",
16+
"role": "Developer"
17+
}
18+
],
19+
"require": {
20+
"php": "^7.4|^8.0",
21+
"filament/filament": "^1.6",
22+
"illuminate/support": "^8.0",
23+
"spatie/laravel-package-tools": "^1.5"
24+
},
25+
"require-dev": {
26+
"orchestra/testbench": "^6.0",
27+
"phpunit/phpunit": "^9.0"
28+
},
29+
"autoload": {
30+
"psr-4": {
31+
"Nop\\Filament\\": "src"
32+
}
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"Nop\\Filament\\Tests\\": "tests"
37+
}
38+
},
39+
"scripts": {
40+
"test": "vendor/bin/phpunit",
41+
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
42+
43+
},
44+
"config": {
45+
"sort-packages": true
46+
},
47+
"extra": {
48+
"laravel": {
49+
"providers": [
50+
"Nop\\Filament\\NopServiceProvider"
51+
]
52+
}
53+
}
54+
}

config/nop.php

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Enabled
7+
|--------------------------------------------------------------------------
8+
|
9+
| Define if Nop should be enabled or not.
10+
|
11+
*/
12+
'enabled' => env('NOP_ENABLED', true),
13+
14+
/*
15+
|--------------------------------------------------------------------------
16+
| Nop token
17+
|--------------------------------------------------------------------------
18+
|
19+
| Token of the Nop project.
20+
| If you don't have a project yet, create one for free at
21+
| https://nop.is/account/projects/create.
22+
|
23+
*/
24+
25+
'token' => env('NOP_TOKEN'),
26+
27+
/*
28+
|--------------------------------------------------------------------------
29+
| Enabled routes
30+
|--------------------------------------------------------------------------
31+
|
32+
| Routes where Nop should be enabled.
33+
|
34+
*/
35+
'enabled_routes' => [
36+
// This route enables all resources of your admin
37+
// E.g. /admin/resources/<resource name>/<id or uuid>/edit
38+
'admin/resources/[a-z-_]+/[0-9a-z-]+/edit',
39+
],
40+
41+
42+
/*
43+
|--------------------------------------------------------------------------
44+
| User name field
45+
|--------------------------------------------------------------------------
46+
|
47+
| Choose the user name field shown in the Nop modals.
48+
| E.g. "name" will be fetched as Auth::user()->name.
49+
| Set this to `null` to disable it.
50+
|
51+
*/
52+
'user_name_field' => 'name',
53+
54+
'settings' => [
55+
56+
/*
57+
|--------------------------------------------------------------------------
58+
| Nop locale
59+
|--------------------------------------------------------------------------
60+
|
61+
| Set the locale for Nop. Can be a locale or an array of translations.
62+
| See more: https://docs.nop.is/usage/settings.html#locale
63+
|
64+
*/
65+
'locale' => 'en-US',
66+
67+
/*
68+
|--------------------------------------------------------------------------
69+
| Redirect on cancel
70+
|--------------------------------------------------------------------------
71+
|
72+
| The URL in which the guest will be redirected when
73+
| canceling an access request.
74+
| See more: https://docs.nop.is/usage/settings.html#redirectoncancel
75+
*/
76+
'redirectOnCancel' => '/',
77+
78+
/*
79+
|--------------------------------------------------------------------------
80+
| Redirect on reject
81+
|--------------------------------------------------------------------------
82+
|
83+
| The URL in which the guest will be redirected when
84+
| his access request has been rejected.
85+
| See more: https://docs.nop.is/usage/settings.html#redirectonreject
86+
*/
87+
'redirectOnReject' => '/',
88+
89+
/*
90+
|--------------------------------------------------------------------------
91+
| Redirect on reject
92+
|--------------------------------------------------------------------------
93+
|
94+
| The URL in which the owner will be redirected when accepting
95+
| an access request and, therefore, his session has been closed.
96+
| See more: https://docs.nop.is/usage/settings.html#redirectonapprove
97+
*/
98+
'redirectOnApprove' => '/',
99+
100+
/*
101+
|--------------------------------------------------------------------------
102+
| Redirect on forced
103+
|--------------------------------------------------------------------------
104+
|
105+
| The URL in which the owner will be redirected whenan access request
106+
| has been forced from a guest and, therefore, his session has been closed.
107+
| See more: https://docs.nop.is/usage/settings.html#redirectonforced
108+
*/
109+
'redirectOnForced' => '/',
110+
111+
],
112+
113+
];

mix-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"/resources/dist/app.js": "/resources/dist/app.js"
3+
}

0 commit comments

Comments
 (0)