Merge remote-tracking branch 'origin/develop'

Signed-off-by: snipe <snipe@snipe.net>

# Conflicts:
#	public/css/dist/all.css
#	public/css/dist/bootstrap-table.css
#	public/js/dist/bootstrap-table.js
#	public/mix-manifest.json
This commit is contained in:
snipe 2023-08-09 10:54:49 +01:00
commit 7df3be3a54
10 changed files with 275 additions and 88 deletions

View file

@ -20,10 +20,8 @@ on:
pipeline:
- name: Setup
cmd: |
cp -v .env.example .env
# This is simply to allow passing the guard in TestCase@setUp()
# https://chipperci.com/docs/builds/env
touch .env.testing
cp -v .env.testing.example .env
cp -v .env.testing.example .env.testing
composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Generate Key
@ -36,15 +34,15 @@ pipeline:
- name: Run Migrations
cmd: |
# php artisan migrate --force
php artisan migrate --force
- name: PHPUnit Unit Tests
cmd: |
# php artisan test --testsuite Unit
php artisan test --testsuite Unit
- name: PHPUnit Feature Tests
cmd: |
# php artisan test --testsuite Feature
php artisan test --testsuite Feature
# - name: Browser Tests
# cmd: |

View file

@ -0,0 +1,67 @@
<?php
namespace App\Http\Livewire;
use Livewire\Component;
class CategoryEditForm extends Component
{
public $defaultEulaText;
public $eulaText;
public $originalSendCheckInEmailValue;
public $requireAcceptance;
public $sendCheckInEmail;
public $useDefaultEula;
public function mount()
{
$this->originalSendCheckInEmailValue = $this->sendCheckInEmail;
if ($this->eulaText || $this->useDefaultEula) {
$this->sendCheckInEmail = 1;
}
}
public function render()
{
return view('livewire.category-edit-form');
}
public function updated($property, $value)
{
if (! in_array($property, ['eulaText', 'useDefaultEula'])) {
return;
}
$this->sendCheckInEmail = $this->eulaText || $this->useDefaultEula ? 1 : $this->originalSendCheckInEmailValue;
}
public function getShouldDisplayEmailMessageProperty(): bool
{
return $this->eulaText || $this->useDefaultEula;
}
public function getEmailMessageProperty(): string
{
if ($this->useDefaultEula) {
return trans('admin/categories/general.email_will_be_sent_due_to_global_eula');
}
return trans('admin/categories/general.email_will_be_sent_due_to_category_eula');
}
public function getEulaTextDisabledProperty()
{
return (bool)$this->useDefaultEula;
}
public function getSendCheckInEmailDisabledProperty()
{
return $this->eulaText || $this->useDefaultEula;
}
}

46
package-lock.json generated
View file

@ -1565,9 +1565,9 @@
}
},
"@types/eslint": {
"version": "8.44.0",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.44.0.tgz",
"integrity": "sha512-gsF+c/0XOguWgaOgvFs+xnnRqt9GwgTvIks36WpE6ueeI4KCEHHd8K/CKHqhOqrJKsYH8m27kRzQEvWXAwXUTw==",
"version": "8.44.2",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.44.2.tgz",
"integrity": "sha512-sdPRb9K6iL5XZOmBubg8yiFp5yS/JdUDQsq5e6h95km91MCYMuvp7mh1fjPEYUhvHepKpZOjnEaMBR4PxjWDzg==",
"requires": {
"@types/estree": "*",
"@types/json-schema": "*"
@ -15962,9 +15962,9 @@
}
},
"jspdf-autotable": {
"version": "3.5.25",
"resolved": "https://registry.npmjs.org/jspdf-autotable/-/jspdf-autotable-3.5.25.tgz",
"integrity": "sha512-BIbDd/cilRbVm5PmR+ZonolSqRtm0AvZDpTz+rrWed7BnFj5mqF7x7lkxDAMzPudLapktHUk6cxipcvUzal8cg=="
"version": "3.5.31",
"resolved": "https://registry.npmjs.org/jspdf-autotable/-/jspdf-autotable-3.5.31.tgz",
"integrity": "sha512-Lc1KuLGDQWW/5t57Z/+c2E94XQV3jV2QVU3xMRiwvcm/nMx79aCkpPCsxLzJZVFneZvz4XoA8+egQR1QajYiWw=="
},
"junk": {
"version": "3.1.0",
@ -19705,9 +19705,9 @@
}
},
"webpack": {
"version": "5.88.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.88.1.tgz",
"integrity": "sha512-FROX3TxQnC/ox4N+3xQoWZzvGXSuscxR32rbzjpXgEzWudJFEJBpdlkkob2ylrv5yzzufD1zph1OoFsLtm6stQ==",
"version": "5.88.2",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.88.2.tgz",
"integrity": "sha512-JmcgNZ1iKj+aiR0OvTYtWQqJwq37Pf683dY9bVORwVbUrDhLhdn/PlO2sHsFHPkj7sHNQF3JwaAkp49V+Sq1tQ==",
"requires": {
"@types/eslint-scope": "^3.7.3",
"@types/estree": "^1.0.0",
@ -19736,22 +19736,22 @@
},
"dependencies": {
"@jridgewell/resolve-uri": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz",
"integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w=="
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
"integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA=="
},
"@jridgewell/sourcemap-codec": {
"version": "1.4.14",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz",
"integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw=="
"version": "1.4.15",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
"integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg=="
},
"@jridgewell/trace-mapping": {
"version": "0.3.18",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz",
"integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==",
"version": "0.3.19",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz",
"integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==",
"requires": {
"@jridgewell/resolve-uri": "3.1.0",
"@jridgewell/sourcemap-codec": "1.4.14"
"@jridgewell/resolve-uri": "^3.1.0",
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"@types/json-schema": {
@ -19788,9 +19788,9 @@
}
},
"terser": {
"version": "5.18.2",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.18.2.tgz",
"integrity": "sha512-Ah19JS86ypbJzTzvUCX7KOsEIhDaRONungA4aYBjEP3JZRf4ocuDzTg4QWZnPn9DEMiMYGJPiSOy7aykoCc70w==",
"version": "5.19.2",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.19.2.tgz",
"integrity": "sha512-qC5+dmecKJA4cpYxRa5aVkKehYsQKc+AHeKl0Oe62aYjBL8ZA33tTljktDHJSaxxMnbI5ZYw+o/S2DxxLu8OfA==",
"requires": {
"@jridgewell/source-map": "^0.3.3",
"acorn": "^8.8.2",

View file

@ -44,7 +44,7 @@
"jquery-ui": "^1.13.2",
"jquery-ui-bundle": "^1.12.1",
"jquery.iframe-transport": "^1.0.0",
"jspdf-autotable": "^3.5.24",
"jspdf-autotable": "^3.5.30",
"less": "^4.1.2",
"less-loader": "^5.0",
"list.js": "^1.5.0",
@ -54,6 +54,6 @@
"tableexport.jquery.plugin": "1.28.0",
"tether": "^1.4.0",
"vue-resource": "^1.5.2",
"webpack": "^5.87.0"
"webpack": "^5.88.2"
}
}

Binary file not shown.

View file

@ -18,7 +18,7 @@
"/css/dist/skins/skin-green.css": "/css/dist/skins/skin-green.css?id=b48f4d8af0e1ca5621c161e93951109f",
"/css/dist/skins/skin-contrast.css": "/css/dist/skins/skin-contrast.css?id=f0fbbb0ac729ea092578fb05ca615460",
"/css/dist/skins/skin-red.css": "/css/dist/skins/skin-red.css?id=b9a74ec0cd68f83e7480d5ae39919beb",
"/css/dist/all.css": "/css/dist/all.css?id=254bea040c8f82f0000528f9e3d659c8",
"/css/dist/all.css": "/css/dist/all.css?id=906fd29150e5c5a1187b050dc7efdf98",
"/css/dist/signature-pad.css": "/css/dist/signature-pad.css?id=6a89d3cd901305e66ced1cf5f13147f7",
"/css/dist/signature-pad.min.css": "/css/dist/signature-pad.min.css?id=6a89d3cd901305e66ced1cf5f13147f7",
"/css/webfonts/fa-brands-400.ttf": "/css/webfonts/fa-brands-400.ttf?id=e2e2b1797606a266ed55549f5bb5a179",
@ -29,9 +29,9 @@
"/css/webfonts/fa-solid-900.woff2": "/css/webfonts/fa-solid-900.woff2?id=eea38615e7b5dbbaf88c263f2230cc32",
"/css/webfonts/fa-v4compatibility.ttf": "/css/webfonts/fa-v4compatibility.ttf?id=6ebbf5afc34f54463abc2b81ca637364",
"/css/webfonts/fa-v4compatibility.woff2": "/css/webfonts/fa-v4compatibility.woff2?id=67b8a78b7e80e805cfa4ee0421895ba4",
"/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=f5935cf8eaf9c1f71da0c9245d730471",
"/css/dist/bootstrap-table.css": "/css/dist/bootstrap-table.css?id=281bcfe26549412d128f695234961081",
"/js/build/vendor.js": "/js/build/vendor.js?id=3592e07ae9a6d1805a4ea3bd3c034aef",
"/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=40e2dc8b5b29e244bb545f78e2a3242b",
"/js/dist/bootstrap-table.js": "/js/dist/bootstrap-table.js?id=df78f0c4cc93c29c02a41144590f6350",
"/js/dist/all.js": "/js/dist/all.js?id=fc2a78ab0c9ec6ce0961990388a1b23f",
"/css/dist/skins/skin-green.min.css": "/css/dist/skins/skin-green.min.css?id=b48f4d8af0e1ca5621c161e93951109f",
"/css/dist/skins/skin-green-dark.min.css": "/css/dist/skins/skin-green-dark.min.css?id=44f9320d0739f419c9246f7f39395b02",

View file

@ -8,6 +8,8 @@ return array(
'clone' => 'Clone Category',
'create' => 'Create Category',
'edit' => 'Edit Category',
'email_will_be_sent_due_to_global_eula' => 'An email will be sent to the user because the global EULA is being used.',
'email_will_be_sent_due_to_category_eula' => 'An email will be sent to the user because a EULA is set for this category.',
'eula_text' => 'Category EULA',
'eula_text_help' => 'This field allows you to customize your EULAs for specific types of assets. If you only have one EULA for all of your assets, you can check the box below to use the primary default.',
'name' => 'Category Name',

View file

@ -23,59 +23,13 @@
</div>
</div>
<!-- EULA text -->
<div class="form-group {{ $errors->has('eula_text') ? 'error' : '' }}">
<label for="eula_text" class="col-md-3 control-label">{{ trans('admin/categories/general.eula_text') }}</label>
<div class="col-md-7">
{{ Form::textarea('eula_text', old('eula_text', $item->eula_text), array('class' => 'form-control', 'aria-label'=>'eula_text')) }}
<p class="help-block">{!! trans('admin/categories/general.eula_text_help') !!} </p>
<p class="help-block">{!! trans('admin/settings/general.eula_markdown') !!} </p>
{!! $errors->first('eula_text', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
<!-- Use default checkbox -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
@if ($snipeSettings->default_eula_text!='')
<label class="form-control">
{{ Form::checkbox('use_default_eula', '1', old('use_default_eula', $item->use_default_eula), ['aria-label'=>'use_default_eula']) }}
<span>{!! trans('admin/categories/general.use_default_eula') !!}</span>
</label>
@else
<label class="form-control form-control--disabled">
{{ Form::checkbox('use_default_eula', '0', old('use_default_eula'), ['class'=>'disabled','disabled' => 'disabled', 'aria-label'=>'use_default_eula']) }}
<span>{!! trans('admin/categories/general.use_default_eula_disabled') !!}</span>
</label>
@endif
</div>
</div>
<!-- Require Acceptance -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('require_acceptance', '1', old('require_acceptance', $item->require_acceptance), ['aria-label'=>'require_acceptance']) }}
{{ trans('admin/categories/general.require_acceptance') }}
</label>
</div>
</div>
<!-- Email on Checkin -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('checkin_email', '1', old('checkin_email', $item->checkin_email), ['aria-label'=>'checkin_email']) }}
{{ trans('admin/categories/general.checkin_email') }}
</label>
</div>
</div>
<livewire:category-edit-form
:default-eula-text="$snipeSettings->default_eula_text"
:eula-text="old('eula_text', $item->eula_text)"
:require-acceptance="old('require_acceptance', $item->require_acceptance)"
:send-check-in-email="old('checkin_email', $item->checkin_email)"
:use-default-eula="old('use_default_eula', $item->use_default_eula)"
/>
@include ('partials.forms.edit.image-upload', ['image_path' => app('categories_upload_path')])

View file

@ -0,0 +1,61 @@
<div>
<!-- EULA text -->
<div class="form-group {{ $errors->has('eula_text') ? 'error' : '' }}">
<label for="eula_text" class="col-md-3 control-label">{{ trans('admin/categories/general.eula_text') }}</label>
<div class="col-md-7">
{{ Form::textarea('eula_text', null, ['wire:model' => 'eulaText', 'class' => 'form-control', 'aria-label'=>'eula_text', 'disabled' => $this->eulaTextDisabled]) }}
<p class="help-block">{!! trans('admin/categories/general.eula_text_help') !!} </p>
<p class="help-block">{!! trans('admin/settings/general.eula_markdown') !!} </p>
{!! $errors->first('eula_text', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
@if ($this->eulaTextDisabled)
<input type="hidden" name="eula_text" wire:model="eulaText" />
@endif
</div>
<!-- Use default checkbox -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
@if ($defaultEulaText!='')
<label class="form-control">
{{ Form::checkbox('use_default_eula', '1', null, ['wire:model' => 'useDefaultEula', 'aria-label'=>'use_default_eula']) }}
<span>{!! trans('admin/categories/general.use_default_eula') !!}</span>
</label>
@else
<label class="form-control form-control--disabled">
{{ Form::checkbox('use_default_eula', '0', null, ['wire:model' => 'useDefaultEula', 'class'=>'disabled','disabled' => 'disabled', 'aria-label'=>'use_default_eula']) }}
<span>{!! trans('admin/categories/general.use_default_eula_disabled') !!}</span>
</label>
@endif
</div>
</div>
<!-- Require Acceptance -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('require_acceptance', '1', null, ['wire:model' => 'requireAcceptance', 'aria-label'=>'require_acceptance']) }}
{{ trans('admin/categories/general.require_acceptance') }}
</label>
</div>
</div>
<!-- Email on Checkin -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('checkin_email', '1', null, ['wire:model' => 'sendCheckInEmail', 'aria-label'=>'checkin_email', 'disabled' => $this->sendCheckInEmailDisabled]) }}
{{ trans('admin/categories/general.checkin_email') }}
</label>
@if ($this->shouldDisplayEmailMessage)
<div class="callout callout-info">
<i class="far fa-envelope"></i>
<span>{{ $this->emailMessage }}</span>
</div>
@endif
@if ($this->sendCheckInEmailDisabled)
<input type="hidden" name="checkin_email" wire:model="sendCheckInEmail" />
@endif
</div>
</div>
</div>

View file

@ -0,0 +1,105 @@
<?php
namespace Tests\Feature\Livewire;
use App\Http\Livewire\CategoryEditForm;
use Livewire\Livewire;
use Tests\TestCase;
class CategoryEditFormTest extends TestCase
{
public function testTheComponentCanRender()
{
Livewire::test(CategoryEditForm::class)->assertStatus(200);
}
public function testSendEmailCheckboxIsCheckedOnLoadWhenSendEmailIsExistingSetting()
{
Livewire::test(CategoryEditForm::class, [
'sendCheckInEmail' => true,
'eulaText' => '',
'useDefaultEula' => false,
])->assertSet('sendCheckInEmail', true);
}
public function testSendEmailCheckboxIsCheckedOnLoadWhenCategoryEulaSet()
{
Livewire::test(CategoryEditForm::class, [
'sendCheckInEmail' => false,
'eulaText' => 'Some Content',
'useDefaultEula' => false,
])->assertSet('sendCheckInEmail', true);
}
public function testSendEmailCheckboxIsCheckedOnLoadWhenUsingDefaultEula()
{
Livewire::test(CategoryEditForm::class, [
'sendCheckInEmail' => false,
'eulaText' => '',
'useDefaultEula' => true,
])->assertSet('sendCheckInEmail', true);
}
public function testSendEmailCheckBoxIsUncheckedOnLoadWhenSendEmailIsFalseNoCategoryEulaSetAndNotUsingDefaultEula()
{
Livewire::test(CategoryEditForm::class, [
'sendCheckInEmail' => false,
'eulaText' => '',
'useDefaultEula' => false,
])->assertSet('sendCheckInEmail', false);
}
public function testSendEmailCheckboxIsCheckedWhenCategoryEulaEntered()
{
Livewire::test(CategoryEditForm::class, [
'sendCheckInEmail' => false,
'useDefaultEula' => false,
])->assertSet('sendCheckInEmail', false)
->set('eulaText', 'Some Content')
->assertSet('sendCheckInEmail', true);
}
public function testSendEmailCheckboxCheckedAndDisabledAndEulaTextDisabledWhenUseDefaultEulaSelected()
{
Livewire::test(CategoryEditForm::class, [
'sendCheckInEmail' => false,
'useDefaultEula' => false,
])->assertSet('sendCheckInEmail', false)
->set('useDefaultEula', true)
->assertSet('sendCheckInEmail', true)
->assertSet('eulaTextDisabled', true)
->assertSet('sendCheckInEmailDisabled', true);
}
public function testSendEmailCheckboxEnabledAndSetToOriginalValueWhenNoCategoryEulaAndNotUsingGlobalEula()
{
Livewire::test(CategoryEditForm::class, [
'eulaText' => 'Some Content',
'sendCheckInEmail' => false,
'useDefaultEula' => true,
])
->set('useDefaultEula', false)
->set('eulaText', '')
->assertSet('sendCheckInEmail', false)
->assertSet('sendCheckInEmailDisabled', false);
Livewire::test(CategoryEditForm::class, [
'eulaText' => 'Some Content',
'sendCheckInEmail' => true,
'useDefaultEula' => true,
])
->set('useDefaultEula', false)
->set('eulaText', '')
->assertSet('sendCheckInEmail', true)
->assertSet('sendCheckInEmailDisabled', false);
}
public function testEulaFieldEnabledOnLoadWhenNotUsingDefaultEula()
{
Livewire::test(CategoryEditForm::class, [
'sendCheckInEmail' => false,
'eulaText' => '',
'useDefaultEula' => false,
])->assertSet('eulaTextDisabled', false);
}
}