Merge pull request #14831 from marcusmoore/chore/sc-23725/livewire3

Updated Livewire to v3
This commit is contained in:
snipe 2024-06-27 13:21:52 +01:00 committed by GitHub
commit 54fb91c03b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 21055 additions and 283 deletions

View file

@ -1,6 +1,6 @@
<?php
namespace App\Http\Livewire;
namespace App\Livewire;
use Livewire\Component;

View file

@ -1,6 +1,6 @@
<?php
namespace App\Http\Livewire;
namespace App\Livewire;
use Livewire\Component;

View file

@ -1,6 +1,6 @@
<?php
namespace App\Http\Livewire;
namespace App\Livewire;
use App\Models\CustomField;
use Livewire\Component;
@ -59,7 +59,7 @@ class Importer extends Component
];
/**
* This is used in resources/views/livewire/importer.blade.php, and we kinda shouldn't need to check for
* This is used in resources/views/livewire.importer.blade.php, and we kinda shouldn't need to check for
* activeFile here, but there's some UI goofiness that allows this to crash out on some imports.
*
* @return string

View file

@ -1,6 +1,6 @@
<?php
namespace App\Http\Livewire;
namespace App\Livewire;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
@ -19,21 +19,11 @@ class OauthClients extends Component
public $authorizationError;
protected $clientRepository;
protected $tokenRepository;
public function __construct()
{
$this->clientRepository = app(ClientRepository::class);
$this->tokenRepository = app(TokenRepository::class);
parent::__construct();
}
public function render()
{
return view('livewire.oauth-clients', [
'clients' => $this->clientRepository->activeForUser(auth()->user()->id),
'authorized_tokens' => $this->tokenRepository->forUser(auth()->user()->id)->where('revoked', false),
'clients' => app(ClientRepository::class)->activeForUser(auth()->user()->id),
'authorized_tokens' => app(TokenRepository::class)->forUser(auth()->user()->id)->where('revoked', false),
]);
}
@ -44,13 +34,13 @@ class OauthClients extends Component
'redirect' => 'required|url|max:255',
]);
$newClient = $this->clientRepository->create(
app(ClientRepository::class)->create(
auth()->user()->id,
$this->name,
$this->redirect,
);
$this->dispatchBrowserEvent('clientCreated');
$this->dispatch('clientCreated');
}
public function deleteClient(Client $clientId): void
@ -58,7 +48,7 @@ class OauthClients extends Component
// test for safety
// ->delete must be of type Client - thus the model binding
if ($clientId->user_id == auth()->user()->id) {
$this->clientRepository->delete($clientId);
app(ClientRepository::class)->delete($clientId);
} else {
Log::warning('User ' . auth()->user()->id . ' attempted to delete client ' . $clientId->id . ' which belongs to user ' . $clientId->user_id);
$this->authorizationError = 'You are not authorized to delete this client.';
@ -67,9 +57,9 @@ class OauthClients extends Component
public function deleteToken($tokenId): void
{
$token = $this->tokenRepository->find($tokenId);
$token = app(TokenRepository::class)->find($tokenId);
if ($token->user_id == auth()->user()->id) {
$this->tokenRepository->revokeAccessToken($tokenId);
app(TokenRepository::class)->revokeAccessToken($tokenId);
} else {
Log::warning('User ' . auth()->user()->id . ' attempted to delete token ' . $tokenId . ' which belongs to user ' . $token->user_id);
$this->authorizationError = 'You are not authorized to delete this token.';
@ -83,7 +73,7 @@ class OauthClients extends Component
$this->editClientId = $editClientId->id;
$this->dispatchBrowserEvent('editClient');
$this->dispatch('editClient');
}
public function updateClient(Client $editClientId): void
@ -93,7 +83,7 @@ class OauthClients extends Component
'editRedirect' => 'required|url|max:255',
]);
$client = $this->clientRepository->find($editClientId->id);
$client = app(ClientRepository::class)->find($editClientId->id);
if ($client->user_id == auth()->user()->id) {
$client->name = $this->editName;
$client->redirect = $this->editRedirect;
@ -103,7 +93,7 @@ class OauthClients extends Component
$this->authorizationError = 'You are not authorized to edit this client.';
}
$this->dispatchBrowserEvent('clientUpdated');
$this->dispatch('clientUpdated');
}
}

View file

@ -1,6 +1,6 @@
<?php
namespace App\Http\Livewire;
namespace App\Livewire;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
@ -17,7 +17,7 @@ class PersonalAccessTokens extends Component
//this is just an annoying thing to make the modal input autofocus
public function autoFocusModalEvent(): void
{
$this->dispatchBrowserEvent('autoFocusModal');
$this->dispatch('autoFocusModal');
}
public function render()
@ -42,7 +42,7 @@ class PersonalAccessTokens extends Component
$this->newTokenString = $newToken->accessToken;
$this->dispatchBrowserEvent('tokenCreated', $newToken->accessToken);
$this->dispatch('tokenCreated', token: $newToken->accessToken);
}
public function deleteToken($tokenId): void

View file

@ -1,6 +1,6 @@
<?php
namespace App\Http\Livewire;
namespace App\Livewire;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Http;
@ -23,15 +23,17 @@ class SlackSettingsForm extends Component
public Setting $setting;
public $save_button;
public $webhook_test;
public $webhook_endpoint_rules;
protected $rules = [
'webhook_endpoint' => 'required_with:webhook_channel|starts_with:http://,https://,ftp://,irc://,https://hooks.slack.com/services/|url|nullable',
'webhook_channel' => 'required_with:webhook_endpoint|starts_with:#|nullable',
'webhook_botname' => 'string|nullable',
];
public function mount() {
$this->webhook_text= [

View file

@ -49,7 +49,7 @@
"laravelcollective/html": "^6.2",
"league/csv": "^9.7",
"league/flysystem-aws-s3-v3": "^3.0",
"livewire/livewire": "^2.4",
"livewire/livewire": "^3.5",
"neitanod/forceutf8": "^2.0",
"nesbot/carbon": "^2.32",
"nunomaduro/collision": "^6.1",

37
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "1cda72f240f69b641adfb69041ebdf17",
"content-hash": "51e716db4ccd70bf942062789f7303ad",
"packages": [
{
"name": "alek13/slack",
@ -4454,34 +4454,37 @@
},
{
"name": "livewire/livewire",
"version": "v2.12.6",
"version": "v3.5.1",
"source": {
"type": "git",
"url": "https://github.com/livewire/livewire.git",
"reference": "7d3a57b3193299cf1a0639a3935c696f4da2cf92"
"reference": "da044261bb5c5449397f18fda3409f14acf47c0a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/livewire/livewire/zipball/7d3a57b3193299cf1a0639a3935c696f4da2cf92",
"reference": "7d3a57b3193299cf1a0639a3935c696f4da2cf92",
"url": "https://api.github.com/repos/livewire/livewire/zipball/da044261bb5c5449397f18fda3409f14acf47c0a",
"reference": "da044261bb5c5449397f18fda3409f14acf47c0a",
"shasum": ""
},
"require": {
"illuminate/database": "^7.0|^8.0|^9.0|^10.0",
"illuminate/support": "^7.0|^8.0|^9.0|^10.0",
"illuminate/validation": "^7.0|^8.0|^9.0|^10.0",
"illuminate/database": "^10.0|^11.0",
"illuminate/routing": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"illuminate/validation": "^10.0|^11.0",
"league/mime-type-detection": "^1.9",
"php": "^7.2.5|^8.0",
"symfony/http-kernel": "^5.0|^6.0"
"php": "^8.1",
"symfony/console": "^6.0|^7.0",
"symfony/http-kernel": "^6.2|^7.0"
},
"require-dev": {
"calebporzio/sushi": "^2.1",
"laravel/framework": "^7.0|^8.0|^9.0|^10.0",
"laravel/framework": "^10.15.0|^11.0",
"laravel/prompts": "^0.1.6",
"mockery/mockery": "^1.3.1",
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0",
"orchestra/testbench-dusk": "^5.2|^6.0|^7.0|^8.0",
"phpunit/phpunit": "^8.4|^9.0",
"psy/psysh": "@stable"
"orchestra/testbench": "^8.21.0|^9.0",
"orchestra/testbench-dusk": "^8.24|^9.1",
"phpunit/phpunit": "^10.4",
"psy/psysh": "^0.11.22|^0.12"
},
"type": "library",
"extra": {
@ -4515,7 +4518,7 @@
"description": "A front-end framework for Laravel.",
"support": {
"issues": "https://github.com/livewire/livewire/issues",
"source": "https://github.com/livewire/livewire/tree/v2.12.6"
"source": "https://github.com/livewire/livewire/tree/v3.5.1"
},
"funding": [
{
@ -4523,7 +4526,7 @@
"type": "github"
}
],
"time": "2023-08-11T04:02:34+00:00"
"time": "2024-06-18T11:10:42+00:00"
},
{
"name": "masterminds/html5",

View file

@ -3,156 +3,158 @@
return [
/*
|--------------------------------------------------------------------------
|---------------------------------------------------------------------------
| Class Namespace
|--------------------------------------------------------------------------
|---------------------------------------------------------------------------
|
| This value sets the root namespace for Livewire component classes in
| your application. This value affects component auto-discovery and
| any Livewire file helper commands, like `artisan make:livewire`.
|
| After changing this item, run: `php artisan livewire:discover`.
| This value sets the root class namespace for Livewire component classes in
| your application. This value will change where component auto-discovery
| finds components. It's also referenced by the file creation commands.
|
*/
'class_namespace' => 'App\\Http\\Livewire',
'class_namespace' => 'App\\Livewire',
/*
|--------------------------------------------------------------------------
|---------------------------------------------------------------------------
| View Path
|--------------------------------------------------------------------------
|---------------------------------------------------------------------------
|
| This value sets the path for Livewire component views. This affects
| file manipulation helper commands like `artisan make:livewire`.
| This value is used to specify where Livewire component Blade templates are
| stored when running file creation commands like `artisan make:livewire`.
| It is also used if you choose to omit a component's render() method.
|
*/
'view_path' => resource_path('views/livewire'),
/*
|--------------------------------------------------------------------------
|---------------------------------------------------------------------------
| Layout
|--------------------------------------------------------------------------
| The default layout view that will be used when rendering a component via
| Route::get('/some-endpoint', SomeComponent::class);. In this case the
| the view returned by SomeComponent will be wrapped in "layouts.app"
|---------------------------------------------------------------------------
| The view that will be used as the layout when rendering a single component
| as an entire page via `Route::get('/post/create', CreatePost::class);`.
| In this case, the view returned by CreatePost will render into $slot.
|
*/
'layout' => 'layouts.app',
'layout' => 'components.layouts.app',
/*
|--------------------------------------------------------------------------
| Livewire Assets URL
|--------------------------------------------------------------------------
|
| This value sets the path to Livewire JavaScript assets, for cases where
| your app's domain root is not the correct path. By default, Livewire
| will load its JavaScript assets from the app's "relative root".
|
| Examples: "/assets", "myurl.com/app".
|---------------------------------------------------------------------------
| Lazy Loading Placeholder
|---------------------------------------------------------------------------
| Livewire allows you to lazy load components that would otherwise slow down
| the initial page load. Every component can have a custom placeholder or
| you can define the default placeholder view for all components below.
|
*/
'asset_url' => env('APP_URL'),
'lazy_placeholder' => null,
/*
|--------------------------------------------------------------------------
| Livewire App URL
|--------------------------------------------------------------------------
|
| This value should be used if livewire assets are served from CDN.
| Livewire will communicate with an app through this url.
|
| Examples: "https://my-app.com", "myurl.com/app".
|
*/
'app_url' => null,
/*
|--------------------------------------------------------------------------
| Livewire Endpoint Middleware Group
|--------------------------------------------------------------------------
|
| This value sets the middleware group that will be applied to the main
| Livewire "message" endpoint (the endpoint that gets hit everytime
| a Livewire component updates). It is set to "web" by default.
|
*/
'middleware_group' => 'web',
/*
|--------------------------------------------------------------------------
| Livewire Temporary File Uploads Endpoint Configuration
|--------------------------------------------------------------------------
|---------------------------------------------------------------------------
| Temporary File Uploads
|---------------------------------------------------------------------------
|
| Livewire handles file uploads by storing uploads in a temporary directory
| before the file is validated and stored permanently. All file uploads
| are directed to a global endpoint for temporary storage. The config
| items below are used for customizing the way the endpoint works.
| before the file is stored permanently. All file uploads are directed to
| a global endpoint for temporary storage. You may configure this below:
|
*/
'temporary_file_upload' => [
'disk' => env('PRIVATE_FILESYSTEM_DISK', 'local'), // Example: 'local', 's3' Default: 'default'
'rules' => null, // Example: ['file', 'mimes:png,jpg'] Default: ['required', 'file', 'max:12288'] (12MB)
'directory' => null, // Example: 'tmp' Default 'livewire-tmp'
'middleware' => null, // Example: 'throttle:5,1' Default: 'throttle:60,1'
'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs.
'rules' => null, // Example: ['file', 'mimes:png,jpg'] | Default: ['required', 'file', 'max:12288'] (12MB)
'directory' => null, // Example: 'tmp' | Default: 'livewire-tmp'
'middleware' => null, // Example: 'throttle:5,1' | Default: 'throttle:60,1'
'preview_mimes' => [ // Supported file types for temporary pre-signed file URLs...
'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
'mov', 'avi', 'wmv', 'mp3', 'm4a',
'jpg', 'jpeg', 'mpga', 'webp', 'wma',
],
'max_upload_time' => 5, // Max duration (in minutes) before an upload gets invalidated.
'max_upload_time' => 5, // Max duration (in minutes) before an upload is invalidated...
'cleanup' => true, // Should cleanup temporary uploads older than 24 hrs...
],
/*
|--------------------------------------------------------------------------
| Manifest File Path
|--------------------------------------------------------------------------
|
| This value sets the path to the Livewire manifest file.
| The default should work for most cases (which is
| "<app_root>/bootstrap/cache/livewire-components.php"), but for specific
| cases like when hosting on Laravel Vapor, it could be set to a different value.
|
| Example: for Laravel Vapor, it would be "/tmp/storage/bootstrap/cache/livewire-components.php".
|
*/
'manifest_path' => null,
/*
|--------------------------------------------------------------------------
| Back Button Cache
|--------------------------------------------------------------------------
|
| This value determines whether the back button cache will be used on pages
| that contain Livewire. By disabling back button cache, it ensures that
| the back button shows the correct state of components, instead of
| potentially stale, cached data.
|
| Setting it to "false" (default) will disable back button cache.
|
*/
'back_button_cache' => false,
/*
|--------------------------------------------------------------------------
|---------------------------------------------------------------------------
| Render On Redirect
|--------------------------------------------------------------------------
|---------------------------------------------------------------------------
|
| This value determines whether Livewire will render before it's redirected
| or not. Setting it to "false" (default) will mean the render method is
| skipped when redirecting. And "true" will mean the render method is
| run before redirecting. Browsers bfcache can store a potentially
| stale view if render is skipped on redirect.
| This value determines if Livewire will run a component's `render()` method
| after a redirect has been triggered using something like `redirect(...)`
| Setting this to true will render the view once more before redirecting
|
*/
'render_on_redirect' => false,
/*
|---------------------------------------------------------------------------
| Eloquent Model Binding
|---------------------------------------------------------------------------
|
| Previous versions of Livewire supported binding directly to eloquent model
| properties using wire:model by default. However, this behavior has been
| deemed too "magical" and has therefore been put under a feature flag.
|
*/
'legacy_model_binding' => true,
/*
|---------------------------------------------------------------------------
| Auto-inject Frontend Assets
|---------------------------------------------------------------------------
|
| By default, Livewire automatically injects its JavaScript and CSS into the
| <head> and <body> of pages containing Livewire components. By disabling
| this behavior, you need to use @livewireStyles and @livewireScripts.
|
*/
'inject_assets' => true,
/*
|---------------------------------------------------------------------------
| Navigate (SPA mode)
|---------------------------------------------------------------------------
|
| By adding `wire:navigate` to links in your Livewire application, Livewire
| will prevent the default link handling and instead request those pages
| via AJAX, creating an SPA-like effect. Configure this behavior here.
|
*/
'navigate' => [
'show_progress_bar' => true,
'progress_bar_color' => '#2299dd',
],
/*
|---------------------------------------------------------------------------
| HTML Morph Markers
|---------------------------------------------------------------------------
|
| Livewire intelligently "morphs" existing HTML into the newly rendered HTML
| after each update. To make this process more reliable, Livewire injects
| "markers" into the rendered Blade surrounding @if, @class & @foreach.
|
*/
'inject_morph_markers' => true,
/*
|---------------------------------------------------------------------------
| Pagination Theme
|---------------------------------------------------------------------------
|
| When enabling Livewire's pagination feature by using the `WithPagination`
| trait, Livewire will use Tailwind templates to render pagination views
| on the page. If you want Bootstrap CSS, you can specify: "bootstrap"
|
*/
'pagination_theme' => 'tailwind',
];

20
package-lock.json generated
View file

@ -10,7 +10,6 @@
"acorn-import-assertions": "^1.9.0",
"admin-lte": "^2.4.18",
"ajv": "^6.12.6",
"alpinejs": "^3.13.10",
"blueimp-file-upload": "^9.34.0",
"bootstrap": "^3.4.1",
"bootstrap-colorpicker": "^2.5.3",
@ -2312,17 +2311,6 @@
"@types/node": "*"
}
},
"node_modules/@vue/reactivity": {
"version": "3.1.5",
"license": "MIT",
"dependencies": {
"@vue/shared": "3.1.5"
}
},
"node_modules/@vue/shared": {
"version": "3.1.5",
"license": "MIT"
},
"node_modules/@webassemblyjs/ast": {
"version": "1.12.1",
"license": "MIT",
@ -2662,14 +2650,6 @@
"prettier": "^2"
}
},
"node_modules/alpinejs": {
"version": "3.13.10",
"resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-3.13.10.tgz",
"integrity": "sha512-86RB307VWICex0vG15Eq0x058cNNsvS57ohrjN6n/TJAVSFV+zXOK/E34nNHDHc6Poq+yTNCLqEzPqEkRBTMRQ==",
"dependencies": {
"@vue/reactivity": "~3.1.1"
}
},
"node_modules/ansi-escapes": {
"version": "4.3.2",
"dev": true,

View file

@ -30,7 +30,6 @@
"acorn-import-assertions": "^1.9.0",
"admin-lte": "^2.4.18",
"ajv": "^6.12.6",
"alpinejs": "^3.13.10",
"blueimp-file-upload": "^9.34.0",
"bootstrap": "^3.4.1",
"bootstrap-colorpicker": "^2.5.3",

10792
public/vendor/livewire/livewire.esm.js vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

103
public/vendor/livewire/livewire.min.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1,2 @@
{"/livewire.js":"/livewire.js?id=90730a3b0e7144480175"}
{"/livewire.js":"87e1046f"}

View file

@ -610,24 +610,27 @@ function htmlEntities(str) {
*
* 1. Set the class of your select2 elements to 'livewire-select2').
* 2. Name your element to match a property in your Livewire component
* 3. Add an attribute called 'data-livewire-component' that points to $_instance->id (via `{{ }}` if you're in a blade,
* or just $_instance->id if not).
* 3. Add an attribute called 'data-livewire-component' that points to $this->getId() (via `{{ }}` if you're in a blade,
* or just $this->getId() if not).
*/
$(function () {
document.addEventListener('livewire:init', () => {
$('.livewire-select2').select2()
$(document).on('select2:select', '.livewire-select2', function (event) {
var target = $(event.target)
if(!event.target.name || !target.data('livewire-component')) {
console.error("You need to set both name (which should match a Livewire property) and data-livewire-component on your Livewire-ed select2 elements!")
console.error("For data-livewire-component, you probably want to use $_instance->id or {{ $_instance->id }}, as appropriate")
console.error("For data-livewire-component, you probably want to use $this->getId() or {{ $this->getId() }}, as appropriate")
return false
}
window.livewire.find(target.data('livewire-component')).set(event.target.name, this.options[this.selectedIndex].value)
})
window.livewire.hook('message.processed', function (el,component) {
$('.livewire-select2').select2();
Livewire.find(target.data('livewire-component')).set(event.target.name, this.options[this.selectedIndex].value)
});
})
Livewire.hook('request', ({succeed}) => {
succeed(() => {
queueMicrotask(() => {
$('.livewire-select2').select2();
});
});
});
});

View file

@ -19,7 +19,6 @@
}
};
</script>
@livewireStyles
@if (($snipeSettings) && ($snipeSettings->header_color))
@ -74,7 +73,6 @@
@stack('js')
@livewireScripts
</body>
</html>

View file

@ -83,7 +83,7 @@ dir="{{ in_array(app()->getLocale(),['ar-SA','fa-IR', 'he-IL']) ? 'rtl' : 'ltr'
<script src="{{ url(asset('js/html5shiv.js')) }}" nonce="{{ csrf_token() }}"></script>
<script src="{{ url(asset('js/respond.js')) }}" nonce="{{ csrf_token() }}"></script>
@livewireStyles
</head>
@ -949,7 +949,6 @@ dir="{{ in_array(app()->getLocale(),['ar-SA','fa-IR', 'he-IL']) ? 'rtl' : 'ltr'
{{-- Javascript files --}}
<script src="{{ url(mix('js/dist/all.js')) }}" nonce="{{ csrf_token() }}"></script>
<script defer src="{{ url(mix('js/dist/all-defer.js')) }}" nonce="{{ csrf_token() }}"></script>
<!-- v5-beta: This pGenerator call must remain here for v5 - until fixed - so that the JS password generator works for the user create modal. -->
<script src="{{ url('js/pGenerator.jquery.js') }}"></script>
@ -1128,7 +1127,6 @@ dir="{{ in_array(app()->getLocale(),['ar-SA','fa-IR', 'he-IL']) ? 'rtl' : 'ltr'
@include('partials.bpay')
@livewireScripts
</body>
</html>

View file

@ -3,13 +3,13 @@
<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]) }}
{{ Form::textarea('eula_text', null, ['wire:model.live' => '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" />
<input type="hidden" name="eula_text" wire:model.live="eulaText" />
@endif
</div>
@ -18,12 +18,12 @@
<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']) }}
{{ Form::checkbox('use_default_eula', '1', $useDefaultEula, ['wire:model.live' => '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']) }}
{{ Form::checkbox('use_default_eula', '0', $useDefaultEula, ['wire:model.live' => 'useDefaultEula', 'class'=>'disabled','disabled' => 'disabled', 'aria-label'=>'use_default_eula']) }}
<span>{!! trans('admin/categories/general.use_default_eula_disabled') !!}</span>
</label>
@endif
@ -34,7 +34,7 @@
<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']) }}
{{ Form::checkbox('require_acceptance', '1', $requireAcceptance, ['wire:model.live' => 'requireAcceptance', 'aria-label'=>'require_acceptance']) }}
{{ trans('admin/categories/general.require_acceptance') }}
</label>
</div>
@ -44,7 +44,7 @@
<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]) }}
{{ Form::checkbox('checkin_email', '1', $sendCheckInEmail, ['wire:model.live' => 'sendCheckInEmail', 'aria-label'=>'checkin_email', 'disabled' => $this->sendCheckInEmailDisabled]) }}
{{ trans('admin/categories/general.checkin_email') }}
</label>
@if ($this->shouldDisplayEmailMessage)
@ -54,7 +54,7 @@
</div>
@endif
@if ($this->sendCheckInEmailDisabled)
<input type="hidden" name="checkin_email" wire:model="sendCheckInEmail" />
<input type="hidden" name="checkin_email" wire:model.live="sendCheckInEmail" />
@endif
</div>
</div>

View file

@ -5,12 +5,12 @@
{{ trans('admin/models/general.fieldset') }}
</label>
<div class="col-md-5">
{{ Form::select('fieldset_id', Helper::customFieldsetList(), old('fieldset_id', $fieldset_id), array('class'=>'select2 js-fieldset-field livewire-select2', 'style'=>'width:100%; min-width:350px', 'aria-label'=>'custom_fieldset', 'data-livewire-component' => $_instance->id)) }}
{{ Form::select('fieldset_id', Helper::customFieldsetList(), old('fieldset_id', $fieldset_id), array('class'=>'select2 js-fieldset-field livewire-select2', 'style'=>'width:100%; min-width:350px', 'aria-label'=>'custom_fieldset', 'data-livewire-component' => $this->getId())) }}
{!! $errors->first('custom_fieldset', '<span class="alert-msg" aria-hidden="true"><br><i class="fas fa-times"></i> :message</span>') !!}
</div>
<div class="col-md-3">
<label class="form-control">
{{ Form::checkbox('add_default_values', 1, old('add_default_values', $add_default_values), ['data-livewire-component' => $_instance->id, 'id' => 'add_default_values', 'wire:model' => 'add_default_values']) }}
{{ Form::checkbox('add_default_values', 1, old('add_default_values', $add_default_values), ['data-livewire-component' => $this->getId(), 'id' => 'add_default_values', 'wire:model.live' => 'add_default_values']) }}
{{ trans('admin/models/general.add_default_values') }}
</label>
</div>

View file

@ -129,7 +129,7 @@
<i class="fa-solid fa-list-check" aria-hidden="true"></i>
<span class="sr-only">{{ trans('general.import') }}</span>
</button>
<a href="#" wire:click="$set('activeFile',null)">
<a href="#" wire:click.prevent="$set('activeFile',null)">
<button class="btn btn-sm btn-danger" wire:click="destroy({{ $currentFile->id }})">
<i class="fas fa-trash icon-white" aria-hidden="true"></i><span class="sr-only"></span></button>
</a>
@ -146,7 +146,7 @@
{{ trans('general.import_type') }}
</label>
<div class="col-md-9 col-xs-12">
<div class="col-md-9 col-xs-12" wire:ignore>
{{ Form::select('activeFile.import_type', $importTypes, $activeFile->import_type, [
'id' => 'import_type',
'class' => 'livewire-select2',
@ -154,7 +154,7 @@
'data-placeholder' => trans('general.select_var', ['thing' => trans('general.import_type')]),
'placeholder' => '', //needed so that the form-helper will put an empty option first
'data-minimum-results-for-search' => '-1', // Remove this if the list gets long enough that we need to search
'data-livewire-component' => $_instance->id
'data-livewire-component' => $this->getId()
]) }}
@if ($activeFile->import_type === 'asset' && $snipeSettings->auto_increment_assets == 0)
<p class="help-block">
@ -166,7 +166,7 @@
<div class="form-group col-md-9 col-md-offset-3">
<label class="form-control">
<input type="checkbox" name="update" data-livewire-component="{{ $_instance->id }}" wire:model="update">
<input type="checkbox" name="update" data-livewire-component="{{ $this->getId() }}" wire:model.live="update">
{{ trans('general.update_existing_values') }}
</label>
@if ($activeFile->import_type === 'asset' && $snipeSettings->auto_increment_assets == 1 && $update)
@ -176,12 +176,12 @@
@endif
<label class="form-control">
<input type="checkbox" name="send_welcome" data-livewire-component="{{ $_instance->id }}" wire:model="send_welcome">
<input type="checkbox" name="send_welcome" data-livewire-component="{{ $this->getId() }}" wire:model.live="send_welcome">
{{ trans('general.send_welcome_email_to_users') }}
</label>
<label class="form-control">
<input type="checkbox" name="run_backup" data-livewire-component="{{ $_instance->id }}" wire:model="run_backup">
<input type="checkbox" name="run_backup" data-livewire-component="{{ $this->getId() }}" wire:model.live="run_backup">
{{ trans('general.back_before_importing') }}
</label>
@ -220,14 +220,14 @@
<div class="form-group col-md-12" wire:key="header-row-{{ $index }}">
<label for="field_map.{{ $index }}" class="col-md-3 control-label text-right">{{ $header }}</label>
<div class="col-md-4">
<div class="col-md-4" wire:ignore>
{{ Form::select('field_map.'.$index, $columnOptions[$activeFile->import_type], @$field_map[$index],
[
'class' => 'mappings livewire-select2',
'placeholder' => trans('general.importer.do_not_import'),
'style' => 'min-width: 100%',
'data-livewire-component' => $_instance->id
'data-livewire-component' => $this->getId()
],[
'-' => ['disabled' => true] // this makes the "-----" line unclickable
])
@ -251,7 +251,7 @@
<div class="form-group col-md-12">
<div class="col-md-3 text-left">
<a href="#" wire:click="$set('activeFile',null)">{{ trans('general.cancel') }}</a>
<a href="#" wire:click.prevent="$set('activeFile',null)">{{ trans('general.cancel') }}</a>
</div>
<div class="col-md-9">
<button type="submit" class="btn btn-primary col-md-5" id="import">Import</button>
@ -267,7 +267,7 @@
@else
<div class="form-group col-md-10">
<div class="col-md-3 text-left">
<a href="#" wire:click="$set('activeFile',null)">{{ trans('general.cancel') }}</a>
<a href="#" wire:click.prevent="$set('activeFile',null)">{{ trans('general.cancel') }}</a>
</div>
</div>
@endif {{-- end of if ... activeFile->import_type --}}
@ -290,16 +290,16 @@
</div>
</div>
@push('js')
@script
<script>
{{-- TODO: Maybe change this to the file upload thing that's baked-in to Livewire? --}}
$('#fileupload').fileupload({
dataType: 'json',
done: function(e, data) {
@this.progress_bar_class = 'progress-bar-success';
@this.progress_message = '<i class="fas fa-check faa-pulse animated"></i> {{ trans('general.notification_success') }}';
@this.progress = 100;
$wire.$set('progress_bar_class', 'progress-bar-success');
$wire.$set('progress_message', '<i class="fas fa-check faa-pulse animated"></i> {{ trans('general.notification_success') }}');
$wire.$set('progress', 100);
},
add: function(e, data) {
data.headers = {
@ -307,17 +307,17 @@
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
};
data.process().done( function () {data.submit();});
@this.progress = 0;
@this.clearMessage();
$wire.$set('progress', 0);
$wire.clearMessage();
},
progress: function(e, data) {
@this.progress = parseInt((data.loaded / data.total * 100, 10));
@this.progress_message = '{{ trans('general.uploading') }}';
$wire.$set('progress', parseInt((data.loaded / data.total * 100, 10)));
$wire.$set('progress_message', '{{ trans('general.uploading') }}');
},
fail: function() {
@this.progress_bar_class = "progress-bar-danger";
@this.progress = 100;
@this.progress_message = '<i class="fas fa-exclamation-triangle faa-pulse animated"></i> {{ trans('general.upload_error') }}';
$wire.$set('progress_bar_class', "progress-bar-danger");
$wire.$set('progress', 100);
$wire.$set('progress_message', '<i class="fas fa-exclamation-triangle faa-pulse animated"></i> {{ trans('general.upload_error') }}');
}
})
@ -328,28 +328,28 @@
// we have to hook up to the `<tr id='importer-file'>` at the root of this display,
// because the #import button isn't visible until you click an import_type
$('#upload-table').on('click', '#import', function () {
if(!@this.activeFile.import_type) {
@this.statusType='error';
@this.statusText= "An import type is required... "; //TODO: translate?
if (!$wire.$get('activeFile.import_type')) {
$wire.$set('statusType', 'error');
$wire.$set('statusText', "An import type is required... "); //TODO: translate?
return;
}
@this.statusType ='pending';
@this.statusText = '<i class="fa fa-spinner fa-spin" aria-hidden="true"></i> {{ trans('admin/hardware/form.processing_spinner') }}';
@this.generate_field_map().then(function (mappings_raw) {
$wire.$set('statusType', 'pending');
$wire.$set('statusText', '<i class="fa fa-spinner fa-spin" aria-hidden="true"></i> {{ trans('admin/hardware/form.processing_spinner') }}');
$wire.generate_field_map().then(function (mappings_raw) {
var mappings = JSON.parse(mappings_raw)
// console.warn("Here is the mappings:")
// console.dir(mappings)
// console.warn("Uh, active file id is, I guess: "+@this.activeFile.id)
var this_file = @this.file_id; // okay, I actually don't know what I'm doing here.
// console.warn("Uh, active file id is, I guess: "+$wire.$get('activeFile.id'))
var this_file = $wire.$get('file_id'); // okay, I actually don't know what I'm doing here.
$.post({
{{-- I want to do something like: route('api.imports.importFile', $activeFile->id) }} --}}
url: "api/v1/imports/process/"+this_file, // maybe? Good a guess as any..FIXME. HARDCODED DUMB FILE
contentType: 'application/json',
data: JSON.stringify({
'import-update': !!@this.update,
'send-welcome': !!@this.send_welcome,
'import-type': @this.activeFile.import_type,
'run-backup': !!@this.run_backup,
'import-update': !!$wire.$get('update'),
'send-welcome': !!$wire.$get('send_welcome'),
'import-type': $wire.$get('activeFile.import_type'),
'run-backup': !!$wire.$get('run_backup'),
'column-mappings': mappings
}),
headers: {
@ -357,19 +357,19 @@
}
}).done( function (body) {
// Success
@this.statusType="success";
@this.statusText = "{{ trans('general.success_redirecting') }}";
$wire.$set('statusType', "success");
$wire.$set('statusText', "{{ trans('general.success_redirecting') }}");
// console.dir(body)
window.location.href = body.messages.redirect_url;
}).fail( function (jqXHR, textStatus, error) {
// Failure
var body = jqXHR.responseJSON
if((body) && (body.status) && body.status == 'import-errors') {
@this.emit('importError', body.messages);
@this.import_errors = body.messages
$wire.$dispatch('importError', body.messages);
$wire.$set('import_errors', body.messages);
@this.statusType='error';
@this.statusText = "Error";
$wire.$set('statusType', 'error');
$wire.$set('statusText', "Error");
// If Slack/notifications hits API thresholds, we *do* 500, but we never
// actually surface that info.
@ -380,19 +380,19 @@
// notifications could be sent".
} else {
console.warn("Not import-errors, just regular errors - maybe API limits")
@this.message_type="warning"
$wire.$set('message_type', "warning");
if ((body) && (error in body)) {
@this.message = body.error ? body.error:"Unknown error - might just be throttling by notifications."
$wire.$set('message', body.error ? body.error : "Unknown error - might just be throttling by notifications.");
} else {
@this.message = "{{ trans('general.importer_generic_error') }}"
$wire.$set('message', "{{ trans('general.importer_generic_error') }}");
}
}
@this.activeFile = null; //@this.set('hideDetails')
$wire.$set('activeFile', null); //$wire.$set('hideDetails')
});
})
return false;
});})
</script>
@endpush
@endscript

View file

@ -16,7 +16,7 @@
<div class="box-tools pull-right">
<a class="btn btn-primary"
wire:click="$emit('openModal')"
wire:click="$dispatch('openModal')"
onclick="$('#modal-create-client').modal('show');">
{{ trans('general.create') }}
</a>
@ -285,7 +285,7 @@
type="text"
aria-label="edit-client-name"
class="form-control"
wire:model="editName"
wire:model.live="editName"
wire:keydown.enter="updateClient('{{ $editClientId }}')"
>
@ -333,7 +333,7 @@
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
window.livewire.on('openModal', () => {
Livewire.on('openModal', () => {
$('#modal-create-client').modal('show').on('shown.bs.modal', function() {
$(this).find('[autofocus]').focus();
});
@ -354,3 +354,4 @@
</script>
</div>

View file

@ -4,7 +4,7 @@
<div class="text-right" style="display: flex; justify-content: space-between; align-items: center;">
<a class="btn btn-info btn-sm action-link pull-right"
onclick="$('#modal-create-token').modal('show');"
wire:click="$emit('openModal')"
wire:click="$dispatch('openModal')"
>
Create New Token
</a>
@ -98,7 +98,7 @@
name="name"
wire:keydown.enter="createToken(name)"
{{-- defer because it's submitting as i type if i don't --}}
wire:model.defer="name"
wire:model="name"
autofocus
>
</div>

View file

@ -13,7 +13,7 @@
@section('content')
<div><!-- livewire div - do not remove -->
<form class="form-horizontal" role="form" wire:submit.prevent="submit">
<form class="form-horizontal" role="form" wire:submit="submit">
{{csrf_field()}}
<div class="row">
@ -79,7 +79,7 @@
{{ Form::label('webhook_endpoint', trans('admin/settings/general.webhook_endpoint',['app' => $webhook_name ])) }}
</div>
<div class="col-md-9 required">
<input type="text" wire:model.lazy="webhook_endpoint" class="form-control" placeholder="{{$webhook_placeholder}}" value="{{old('webhook_endpoint', $webhook_endpoint)}}"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
<input type="text" wire:model.blur="webhook_endpoint" class="form-control" placeholder="{{$webhook_placeholder}}" value="{{old('webhook_endpoint', $webhook_endpoint)}}"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
{!! $errors->first('webhook_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
@ -96,7 +96,7 @@
{{ Form::label('webhook_channel', trans('admin/settings/general.webhook_channel',['app' => $webhook_name ])) }}
</div>
<div class="col-md-9 required">
<input type="text" wire:model.lazy="webhook_channel" class="form-control" placeholder="#IT-Ops" value="{{ old('webhook_channel', $webhook_channel) }}"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
<input type="text" wire:model.blur="webhook_channel" class="form-control" placeholder="#IT-Ops" value="{{ old('webhook_channel', $webhook_channel) }}"{{ Helper::isDemoMode() ? ' disabled' : ''}}>
{!! $errors->first('webhook_channel', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
@ -114,7 +114,7 @@
{{ Form::label('webhook_botname', trans('admin/settings/general.webhook_botname',['app' => $webhook_name ])) }}
</div>
<div class="col-md-9">
<input type="text" wire:model.lazy="webhook_botname" class='form-control' placeholder="Snipe-Bot" {{ old('webhook_botname', $webhook_botname)}}{{ Helper::isDemoMode() ? ' disabled' : ''}}>
<input type="text" wire:model.blur="webhook_botname" class='form-control' placeholder="Snipe-Bot" {{ old('webhook_botname', $webhook_botname)}}{{ Helper::isDemoMode() ? ' disabled' : ''}}>
{!! $errors->first('webhook_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div><!--col-md-10-->
</div>
@ -175,11 +175,6 @@
var data = $('#select2').select2("val");
@this.set('webhook_selected', data);
});
// Re-render select2
window.livewire.hook('message.processed', function (el, component) {
$('.select2').select2();
});
});

View file

@ -430,3 +430,8 @@
{{Form::close()}}
@stop
@push('js')
{{-- Can't use @script here because we're not in a livewire component so let's manually load --}}
@livewireScripts
@endpush

View file

@ -384,7 +384,6 @@
{{-- Javascript files --}}
<script src="{{ url(mix('js/dist/all.js')) }}" nonce="{{ csrf_token() }}"></script>
<script defer src="{{ url(mix('js/dist/all-defer.js')) }}" nonce="{{ csrf_token() }}"></script>
@push('css')

View file

@ -23,6 +23,7 @@ use App\Http\Controllers\ViewAssetsController;
use App\Http\Controllers\Auth\LoginController;
use App\Http\Controllers\Auth\ForgotPasswordController;
use App\Http\Controllers\Auth\ResetPasswordController;
use App\Livewire\Importer;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
@ -262,7 +263,7 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser
*/
Route::get('/import',
\App\Http\Livewire\Importer::class
Importer::class
)->middleware('auth')->name('imports.index');
/*

View file

@ -2,7 +2,7 @@
namespace Tests\Feature\Livewire;
use App\Http\Livewire\CategoryEditForm;
use App\Livewire\CategoryEditForm;
use Livewire\Livewire;
use Tests\TestCase;

View file

@ -189,13 +189,6 @@ mix
)
.version();
mix
.combine(
['./node_modules/alpinejs/dist/cdn.js'],
'./public/js/dist/all-defer.js'
)
.version();
/**
* Copy, minify and version skins
*/