Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentBean committed Jul 3, 2024
0 parents commit eafbd53
Show file tree
Hide file tree
Showing 16 changed files with 674 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

Please read and understand the contribution guide before creating an issue or pull request.

## Etiquette

This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.

Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.

It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
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.

## Viability

When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.

## Procedure

Before filing an issue:

- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.

Before submitting a pull request:

- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

## Requirements

If the project maintainer has any additional requirements, you will find them listed here.

- **[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).

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **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.

**Happy coding**!
3 changes: 3 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Security Policy

If you discover any security related issues, please email security@justbetter.nl instead of using the issue tracker.
29 changes: 29 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Update Changelog"

on:
release:
types: [ published, edited ]

jobs:
update:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.target_commitish }}

- name: Generate changelog
uses: justbetter/generate-changelogs-action@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
repository: ${{ github.repository }}

- name: Commit CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: ${{ github.event.release.target_commitish }}
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor
composer.lock
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Laravel Magento Async Nova

This package is the Laravel Nova integration for `justbetter/laravel-magento-async`.

## Installation

Install the package.

```shell
composer require justbetter/laravel-magento-async-nova
```

## Versioning

Our major version corresponds to the major Nova version.

| Package version | Nova version |
|-----------------|--------------|
| `^4.0` | `^4.0` |


## Contributing

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

## Security Vulnerabilities

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

## Credits

- [Vincent Boon](https://github.com/VincentBean)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE) for more information.
58 changes: 58 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "just-better/laravel-magento-async-nova",
"description": "Nova integration for just-better/laravel-magento-async",
"type": "package",
"license": "MIT",
"authors": [
{
"name": "Vincent Boon",
"email": "vincent@justbetter.nl",
"role": "Developer"
}
],
"require": {
"php": "^8.2",
"laravel/nova": "^4.0",
"just-better/laravel-magento-async": "^1.0"
},
"autoload": {
"psr-4": {
"JustBetter\\MagentoAsyncNova\\": "src"
}
},
"config": {
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
"JustBetter\\MagentoAsyncNova\\ServiceProvider"
]
}
},
"scripts": {
"style": "pint --test",
"analyse": "phpstan --memory-limit='1G'",
"quality": [
"@style",
"@analyse"
]
},
"minimum-stability": "stable",
"prefer-stable": true,
"repositories": [
{
"type": "composer",
"url": "https://nova.laravel.com"
},
{
"type": "composer",
"url": "https://repo.justbetter.nl"
}
],
"require-dev": {
"larastan/larastan": "^2.9",
"laravel/pint": "^1.16",
"orchestra/testbench": "^9.0"
}
}
8 changes: 8 additions & 0 deletions config/magento-async-nova.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'resources' => [
'bulk_request' => \JustBetter\MagentoAsyncNova\Nova\BulkRequestResource::class,
'bulk_operation' => \JustBetter\MagentoAsyncNova\Nova\BulkOperationResource::class,
],
];
10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
includes:
- ./vendor/larastan/larastan/extension.neon

parameters:
paths:
- src
level: 8
ignoreErrors:
- identifier: missingType.iterableValue
- identifier: missingType.generics
112 changes: 112 additions & 0 deletions src/Nova/BulkOperationResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

namespace JustBetter\MagentoAsyncNova\Nova;

use Illuminate\Http\Request;
use JustBetter\MagentoAsync\Enums\OperationStatus;
use JustBetter\MagentoAsync\Models\BulkOperation;
use Laravel\Nova\Fields\Badge;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Code;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\MorphTo;
use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Resource;

class BulkOperationResource extends Resource
{
public static string $model = BulkOperation::class;

public static $title = 'path';

public static $group = 'Magento Async';

public static $search = [
'subject_type',
'subject_id',
];

public static $globallySearchable = false;

public static function label(): string
{
return __('Operations');
}

public static function uriKey(): string
{
return 'magento-async-bulk-operations';
}

public function fields(NovaRequest $request): array
{
return [
BelongsTo::make(__('Request'), 'request', BulkRequestResource::class),

Number::make(__('Operation #'), 'operation_id')
->sortable(),

Badge::make(__('Status'), 'status')
->map([
OperationStatus::Complete->value => 'success',
OperationStatus::RetriablyFailed->value => 'danger',
OperationStatus::NotRetriablyFailed->value => 'danger',
OperationStatus::Open->value => 'warning',
OperationStatus::Rejected->value => 'danger',
null => 'info',
])
->labels([
OperationStatus::Complete->value => 'Finished',
OperationStatus::RetriablyFailed->value => 'Failed with retries',
OperationStatus::NotRetriablyFailed->value => 'Failed without retries',
OperationStatus::Open->value => 'Pending',
OperationStatus::Rejected->value => 'Rejected',
null => 'Unknown',
]),

MorphTo::make(__('Subject'), 'subject'),

Text::make(__('Error Code'), 'response->error_code')
->sortable(),

Text::make(__('Result Message'), 'response->result_message')
->sortable(),

Code::make(__('Response'), 'response')
->json(),

DateTime::make(__('Created At'), 'created_at')
->hideFromIndex(),

DateTime::make(__('Updated At'), 'updated_at')
->hideFromIndex(),
];
}

public function cards(NovaRequest $request): array
{
return [
Metrics\PendingCount::make(),
Metrics\FinishedCount::make(),
Metrics\FailedCount::make(),
Metrics\RejectedCount::make(),
];
}

public static function authorizedToCreate(Request $request): bool
{
return false;
}

public function authorizedToUpdate(Request $request): bool
{
return false;
}

public function authorizedToReplicate(Request $request): bool
{
return false;
}
}
Loading

0 comments on commit eafbd53

Please sign in to comment.