Merge branch 'develop'

# Conflicts:
#	public/css/app.css
#	public/js/2035.js
#	public/js/2407.js
#	public/js/2741.js
#	public/js/4104.js
#	public/js/4627.js
#	public/js/547.js
#	public/js/5727.js
#	public/js/630.js
#	public/js/6341.js
#	public/js/6675.js
#	public/js/6974.js
#	public/js/7438.js
#	public/js/9039.js
#	public/js/9202.js
#	public/js/9737.js
#	public/js/9989.js
#	public/js/app.js
#	public/js/app.js.LICENSE.txt
This commit is contained in:
Dennis
2021-05-11 11:54:09 +02:00
29 changed files with 5895 additions and 6223 deletions

281
app/Helpers/Country.php Normal file
View File

@@ -0,0 +1,281 @@
<?php
if (!function_exists('countries')) {
function countries($key = null)
{
$arr = [
'af' => 'Afghanistan',
'al' => 'Albania',
'dz' => 'Algeria',
'as' => 'American Samoa',
'ad' => 'Andorra',
'ao' => 'Angola',
'ai' => 'Anguilla',
'aq' => 'Antarctica',
'ag' => 'Antigua and Barbuda',
'ar' => 'Argentina',
'am' => 'Armenia',
'aw' => 'Aruba',
'au' => 'Australia',
'at' => 'Austria',
'az' => 'Azerbaijan',
'bs' => 'Bahamas',
'bh' => 'Bahrain',
'bd' => 'Bangladesh',
'bb' => 'Barbados',
'by' => 'Belarus',
'be' => 'Belgium',
'bz' => 'Belize',
'bj' => 'Benin',
'bm' => 'Bermuda',
'bt' => 'Bhutan',
'bo' => 'Bolivia',
'ba' => 'Bosnia and Herzegovina',
'bw' => 'Botswana',
'bv' => 'Bouvet Island',
'br' => 'Brazil',
'bq' => 'British Antarctic Territory',
'io' => 'British Indian Ocean Territory',
'vg' => 'British Virgin Islands',
'bn' => 'Brunei',
'bg' => 'Bulgaria',
'bf' => 'Burkina Faso',
'bi' => 'Burundi',
'kh' => 'Cambodia',
'cm' => 'Cameroon',
'ca' => 'Canada',
'ct' => 'Canton and Enderbury Islands',
'cv' => 'Cape Verde',
'ky' => 'Cayman Islands',
'cf' => 'Central African Republic',
'td' => 'Chad',
'cl' => 'Chile',
'cn' => 'China',
'cx' => 'Christmas Island',
'cc' => 'Cocos [Keeling] Islands',
'co' => 'Colombia',
'km' => 'Comoros',
'cg' => 'Congo - Brazzaville',
'cd' => 'Congo - Kinshasa',
'ck' => 'Cook Islands',
'cr' => 'Costa Rica',
'hr' => 'Croatia',
'cu' => 'Cuba',
'cy' => 'Cyprus',
'cz' => 'Czech Republic',
'ci' => 'Côte dIvoire',
'dk' => 'Denmark',
'dj' => 'Djibouti',
'dm' => 'Dominica',
'do' => 'Dominican Republic',
'nq' => 'Dronning Maud Land',
'dd' => 'East Germany',
'ec' => 'Ecuador',
'eg' => 'Egypt',
'sv' => 'El Salvador',
'gq' => 'Equatorial Guinea',
'er' => 'Eritrea',
'ee' => 'Estonia',
'et' => 'Ethiopia',
'fk' => 'Falkland Islands',
'fo' => 'Faroe Islands',
'fj' => 'Fiji',
'fi' => 'Finland',
'fr' => 'France',
'gf' => 'French Guiana',
'pf' => 'French Polynesia',
'tf' => 'French Southern Territories',
'fq' => 'French Southern and Antarctic Territories',
'ga' => 'Gabon',
'gm' => 'Gambia',
'ge' => 'Georgia',
'de' => 'Germany',
'gh' => 'Ghana',
'gi' => 'Gibraltar',
'gr' => 'Greece',
'gl' => 'Greenland',
'gd' => 'Grenada',
'gp' => 'Guadeloupe',
'gu' => 'Guam',
'gt' => 'Guatemala',
'gg' => 'Guernsey',
'gn' => 'Guinea',
'gw' => 'Guinea-Bissau',
'gy' => 'Guyana',
'ht' => 'Haiti',
'hm' => 'Heard Island and McDonald Islands',
'hn' => 'Honduras',
'hk' => 'Hong Kong SAR China',
'hu' => 'Hungary',
'is' => 'Iceland',
'in' => 'India',
'id' => 'Indonesia',
'ir' => 'Iran',
'iq' => 'Iraq',
'ie' => 'Ireland',
'im' => 'Isle of Man',
'il' => 'Israel',
'it' => 'Italy',
'jm' => 'Jamaica',
'jp' => 'Japan',
'je' => 'Jersey',
'jt' => 'Johnston Island',
'jo' => 'Jordan',
'kz' => 'Kazakhstan',
'ke' => 'Kenya',
'ki' => 'Kiribati',
'kw' => 'Kuwait',
'kg' => 'Kyrgyzstan',
'la' => 'Laos',
'lv' => 'Latvia',
'lb' => 'Lebanon',
'ls' => 'Lesotho',
'lr' => 'Liberia',
'ly' => 'Libya',
'li' => 'Liechtenstein',
'lt' => 'Lithuania',
'lu' => 'Luxembourg',
'mo' => 'Macau SAR China',
'mk' => 'Macedonia',
'mg' => 'Madagascar',
'mw' => 'Malawi',
'my' => 'Malaysia',
'mv' => 'Maldives',
'ml' => 'Mali',
'mt' => 'Malta',
'mh' => 'Marshall Islands',
'mq' => 'Martinique',
'mr' => 'Mauritania',
'mu' => 'Mauritius',
'yt' => 'Mayotte',
'fx' => 'Metropolitan France',
'mx' => 'Mexico',
'fm' => 'Micronesia',
'mi' => 'Midway Islands',
'md' => 'Moldova',
'mc' => 'Monaco',
'mn' => 'Mongolia',
'me' => 'Montenegro',
'ms' => 'Montserrat',
'ma' => 'Morocco',
'mz' => 'Mozambique',
'mm' => 'Myanmar [Burma]',
'na' => 'Namibia',
'nr' => 'Nauru',
'np' => 'Nepal',
'nl' => 'Netherlands',
'an' => 'Netherlands Antilles',
'nt' => 'Neutral Zone',
'nc' => 'New Caledonia',
'nz' => 'New Zealand',
'ni' => 'Nicaragua',
'ne' => 'Niger',
'ng' => 'Nigeria',
'nu' => 'Niue',
'nf' => 'Norfolk Island',
'kp' => 'North Korea',
'vd' => 'North Vietnam',
'mp' => 'Northern Mariana Islands',
'no' => 'Norway',
'om' => 'Oman',
'pc' => 'Pacific Islands Trust Territory',
'pk' => 'Pakistan',
'pw' => 'Palau',
'ps' => 'Palestinian Territories',
'pa' => 'Panama',
'pz' => 'Panama Canal Zone',
'pg' => 'Papua New Guinea',
'py' => 'Paraguay',
'yd' => 'People\'s Democratic Republic of Yemen',
'pe' => 'Peru',
'ph' => 'Philippines',
'pn' => 'Pitcairn Islands',
'pl' => 'Poland',
'pt' => 'Portugal',
'pr' => 'Puerto Rico',
'qa' => 'Qatar',
'ro' => 'Romania',
'ru' => 'Russia',
'rw' => 'Rwanda',
're' => 'Réunion',
'bl' => 'Saint Barthélemy',
'sh' => 'Saint Helena',
'kn' => 'Saint Kitts and Nevis',
'lc' => 'Saint Lucia',
'mf' => 'Saint Martin',
'pm' => 'Saint Pierre and Miquelon',
'vc' => 'Saint Vincent and the Grenadines',
'ws' => 'Samoa',
'sm' => 'San Marino',
'sa' => 'Saudi Arabia',
'sn' => 'Senegal',
'rs' => 'Serbia',
'cs' => 'Serbia and Montenegro',
'sc' => 'Seychelles',
'sl' => 'Sierra Leone',
'sg' => 'Singapore',
'sk' => 'Slovakia',
'si' => 'Slovenia',
'sb' => 'Solomon Islands',
'so' => 'Somalia',
'za' => 'South Africa',
'gs' => 'South Georgia and the South Sandwich Islands',
'kr' => 'South Korea',
'es' => 'Spain',
'lk' => 'Sri Lanka',
'sd' => 'Sudan',
'sr' => 'Suriname',
'sj' => 'Svalbard and Jan Mayen',
'sz' => 'Swaziland',
'se' => 'Sweden',
'ch' => 'Switzerland',
'sy' => 'Syria',
'st' => 'São Tomé and Príncipe',
'tw' => 'Taiwan',
'tj' => 'Tajikistan',
'tz' => 'Tanzania',
'th' => 'Thailand',
'tl' => 'Timor-Leste',
'tg' => 'Togo',
'tk' => 'Tokelau',
'to' => 'Tonga',
'tt' => 'Trinidad and Tobago',
'tn' => 'Tunisia',
'tr' => 'Turkey',
'tm' => 'Turkmenistan',
'tc' => 'Turks and Caicos Islands',
'tv' => 'Tuvalu',
'um' => 'U.S. Minor Outlying Islands',
'pu' => 'U.S. Miscellaneous Pacific Islands',
'vi' => 'U.S. Virgin Islands',
'ug' => 'Uganda',
'ua' => 'Ukraine',
'su' => 'Union of Soviet Socialist Republics',
'ae' => 'United Arab Emirates',
'en' => 'United Kingdom (EN)',
'uk' => 'United Kingdom (UK)',
'gb' => 'United Kingdom (GB)',
'us' => 'United States',
'zz' => 'Unknown or Invalid Region',
'uy' => 'Uruguay',
'uz' => 'Uzbekistan',
'vu' => 'Vanuatu',
'va' => 'Vatican City',
've' => 'Venezuela',
'vn' => 'Vietnam',
'wk' => 'Wake Island',
'wf' => 'Wallis and Futuna',
'eh' => 'Western Sahara',
'ye' => 'Yemen',
'zm' => 'Zambia',
'zw' => 'Zimbabwe',
'ax' => 'Åland Islands',
];
if ($key && array_key_exists($key, $arr)) {
return $arr[strtolower($key)];
}
return $arr;
}
}

View File

@@ -1,7 +1,7 @@
<?php
if (!function_exists('languages')) {
function languages()
function languages(): array
{
$languages = [
'en'

View File

@@ -75,6 +75,7 @@ class ProfileBillingController extends Controller
return inertia('Profile/Billing', [
'packages' => $packages,
'countries' => countries(),
'subscription' => $user->subscription('default'),
'public_key' => config('cashier.key'),
'data_client_secret' => $clientSecret,
@@ -96,8 +97,14 @@ class ProfileBillingController extends Controller
$user = $request->user();
$user->createOrGetStripeCustomer([
'name' => $user->name,
'description' => $request->input('billing_details')
'name' => $request->input('billing_details.name'),
'description' => 'Ploi Core Customer ' . $request->input('billing_details.name'),
'address' => [
'line1' => $request->input('billing_details.address.line1'),
'postal_code' => $request->input('billing_details.address.postal_code'),
'city' => $request->input('billing_details.address.city'),
'country' => $request->input('billing_details.address.country'),
]
]);
foreach ($user->paymentMethods() as $paymentMethod) {

View File

@@ -12,7 +12,8 @@ class ProfileController extends Controller
public function index()
{
return inertia('Profile/Index', [
'profile' => new UserProfileResource(auth()->user())
'profile' => new UserProfileResource(auth()->user()),
'countries' => countries()
]);
}

View File

@@ -61,6 +61,10 @@ class HandleInertiaRequests extends Middleware
'theme' => Auth::user()->theme,
'keyboard_shortcuts' => Auth::user()->keyboard_shortcuts,
'requires_password_for_ftp' => Auth::user()->requires_password_for_ftp,
'address' => Auth::user()->address,
'country' => Auth::user()->country,
'zip' => Auth::user()->zip,
'city' => Auth::user()->city,
] : null,
'package' => auth()->user() && auth()->user()->package ? [
'name' => auth()->user()->package->name,

View File

@@ -41,6 +41,22 @@ class UserProfileRequest extends FormRequest
'required',
'string',
Rule::in(languages()),
],
'address' => [
'nullable',
'string'
],
'country' => [
'nullable',
'string'
],
'zip' => [
'nullable',
'string'
],
'city' => [
'nullable',
'string'
]
];
}

View File

@@ -19,7 +19,11 @@ class UserProfileResource extends JsonResource
return [
'name' => $this->name,
'email' => $this->email,
'language' => $this->language
'language' => $this->language,
'address' => $this->address,
'country' => $this->country,
'zip' => $this->zip,
'city' => $this->city
];
}
}

View File

@@ -28,6 +28,7 @@ class User extends Authenticatable implements HasLocalePreference
'address',
'city',
'country',
'zip',
'notes',
'language',
'blocked',

View File

@@ -31,9 +31,10 @@
"facade/ignition": "^2.3",
"friendsofphp/php-cs-fixer": "^2.16",
"fzaninotto/faker": "^1.9.1",
"laravel/dusk": "^6.15",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^8.5"
"phpunit/phpunit": "^9.5.4"
},
"config": {
"optimize-autoloader": true,

1162
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddZipToUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('zip')->after('city')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('zip');
});
}
}

10317
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
@@ -12,13 +13,16 @@
"@inertiajs/inertia": "^0.4.3",
"@inertiajs/inertia-vue": "^0.3.2",
"@inertiajs/progress": "^0.1.2",
"@tailwindcss/ui": "^0.3.0",
"@tailwindcss/forms": "^0.3.2",
"@tailwindcss/typography": "^0.4.0",
"autoprefixer": "^10.2.5",
"axios": "^0.19",
"balloon-css": "^1.2.0",
"cross-env": "^7.0",
"laravel-mix": "^6.0.18",
"lodash": "^4.17.15",
"portal-vue": "^2.1.7",
"postcss": "^8.2.13",
"resolve-url-loader": "^3.1.0",
"sass": "^1.15.2",
"sass-loader": "^8.0.0",
@@ -30,11 +34,5 @@
"vue-meta": "^2.4.0",
"vue-template-compiler": "^2.6.11",
"vuex": "^3.5.1"
},
"dependencies": {
"@tailwindcss/forms": "^0.3.2",
"@tailwindcss/typography": "^0.4.0",
"autoprefixer": "^10.2.5",
"postcss": "^8.2.13"
}
}

1
public/js/461.js vendored

File diff suppressed because one or more lines are too long

1
public/js/6996.js vendored Normal file

File diff suppressed because one or more lines are too long

1
public/js/7319.js vendored Normal file

File diff suppressed because one or more lines are too long

1
public/js/7541.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -18,6 +18,22 @@
id="card-holder-name"
:label="__('Card holder name')"/>
<form-input v-model="address"
:errors="$page.props.errors.address"
:disabled="sending"
:label="__('Address')"/>
<form-select :label="__('Country')" :errors="$page.props.errors.country" v-model="country">
<option :value="code" v-for="(country, code) in countries" v-text="country"></option>
</form-select>
<form-input v-model="zip"
:errors="$page.props.errors.zip"
:disabled="sending"
:label="__('ZIP (postal code)')"/>
<form-input v-model="city"
:errors="$page.props.errors.city"
:disabled="sending"
:label="__('City')"/>
<div class="w-full pb-4">
<label class="form-label" for="card-element">{{ __('Card details') }}</label>
<div id="card-element" class="form-input"></div>
@@ -159,6 +175,7 @@
import Modal from '@/components/Modal'
import ModalContainer from '@/components/ModalContainer'
import FormInput from '@/components/forms/FormInput'
import FormSelect from '@/components/forms/FormSelect'
import FormTextarea from '@/components/forms/FormTextarea'
import FormActions from '@/components/FormActions'
import Table from '@/components/Table'
@@ -201,6 +218,7 @@
Modal,
ModalContainer,
FormInput,
FormSelect,
FormTextarea,
FormActions,
Table,
@@ -213,6 +231,7 @@
props: {
packages: Array,
countries: Object,
subscription: [Object, null],
public_key: String,
data_client_secret: String,
@@ -232,6 +251,11 @@
currentCardBrand: this.card.brand,
coupon: '',
address: this.$page.props.auth.user.address,
country: this.$page.props.auth.user.country,
zip: this.$page.props.auth.user.zip,
city: this.$page.props.auth.user.city,
invoices: [],
breadcrumbs: [
@@ -288,6 +312,12 @@
card: this.cardElement,
billing_details: {
name: this.cardHolderName,
address: {
line1: this.address,
postal_code: this.zip,
city: this.city,
country: this.country,
}
}
}
}
@@ -305,7 +335,15 @@
const paymentMethod = setupIntent.payment_method;
this.$inertia.post(this.route('profile.billing.update.card'), {
payment_method: paymentMethod,
billing_details: this.billingDetails
billing_details: {
name: this.cardHolderName,
address: {
line1: this.address,
postal_code: this.zip,
city: this.city,
country: this.country,
}
}
}, {
onStart: () => this.sending = true,
onFinish: () => this.sending = false

View File

@@ -17,6 +17,13 @@
<option value="pt">Portuguese</option>
</FormSelect>
<FormInput :label="__('Address')" type="text" :errors="$page.props.errors.address" v-model="form.address" />
<FormSelect :label="__('Country')" :errors="$page.props.errors.country" v-model="form.country">
<option :value="code" v-for="(country, code) in countries" v-text="country"></option>
</FormSelect>
<FormInput :label="__('ZIP')" type="text" :errors="$page.props.errors.zip" v-model="form.zip" />
<FormInput :label="__('City')" type="text" :errors="$page.props.errors.city" v-model="form.city" />
<FormActions>
<Button>{{ __('Save changes') }}</Button>
</FormActions>
@@ -84,6 +91,7 @@
props: {
profile: Object,
countries: Object,
},
data() {
@@ -92,6 +100,11 @@
name: this.profile.name,
email: this.profile.email,
language: this.profile.language,
address: this.profile.address,
country: this.profile.country,
zip: this.profile.zip,
city: this.profile.city,
},
breadcrumbs: [

View File

@@ -1,6 +1,6 @@
<template>
<aside
class="relative w-full h-full max-w-lg p-8 rounded shadow-2xl pointer-events-auto bg-overlay bf-blur"
class="relative w-full h-full max-w-lg p-8 rounded shadow-2xl pointer-events-auto bg-overlay bf-blur-high"
v-click-outside="() => $emit('close')"
>
<button

View File

@@ -13,6 +13,10 @@
backdrop-filter: blur(2px) saturate(125%);
}
.bf-blur-high {
backdrop-filter: blur(15px) saturate(125%);
}
.text-gradient {
background: -webkit-linear-gradient(
35deg,

View File

@@ -0,0 +1,26 @@
<?php
namespace Tests\Browser;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class DashboardTest extends DuskTestCase
{
/**
* A Dusk test example.
*
* @return void
*/
public function testDashboard()
{
$this->browse(function (Browser $browser) {
$browser
->loginAs(User::first())
->visit('/')
->assertSee('Dashboard');
});
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Tests\Browser;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class LoginTest extends DuskTestCase
{
public function testLogin()
{
$this->browse(function (Browser $browser) {
$browser
->loginAs(User::query()->where('role', User::ADMIN)->first())
->visit('/')
->assertUrlIs(config('app.url') . '/');
$browser->visit('/admin')
->assertSee('Administration');
});
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class HomePage extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url()
{
return '/';
}
/**
* Assert that the browser is on the page.
*
* @param \Laravel\Dusk\Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
//
}
/**
* Get the element shortcuts for the page.
*
* @return array
*/
public function elements()
{
return [
'@element' => '#selector',
];
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Page as BasePage;
abstract class Page extends BasePage
{
/**
* Get the global element shortcuts for the site.
*
* @return array
*/
public static function siteElements()
{
return [
'@element' => '#selector',
];
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Tests\Browser;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class ProfileChangeTest extends DuskTestCase
{
/**
* A Dusk test example.
*
* @return void
*/
public function testProfileChange()
{
$this->browse(function (Browser $browser) {
$browser
->loginAs(User::query()->where('role', User::ADMIN)->first())
->visit('/profile')
->press('Save Changes')
->pause(250)
->assertSee('Success')
->assertSee('Profile saved');
});
}
}

2
tests/Browser/console/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

2
tests/Browser/screenshots/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

61
tests/DuskTestCase.php Normal file
View File

@@ -0,0 +1,61 @@
<?php
namespace Tests;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\TestCase as BaseTestCase;
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
/**
* Prepare for Dusk test execution.
*
* @beforeClass
* @return void
*/
public static function prepare()
{
if (! static::runningInSail()) {
static::startChromeDriver();
}
}
/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments(collect([
'--window-size=1920,1080',
])->unless($this->hasHeadlessDisabled(), function ($items) {
return $items->merge([
'--disable-gpu',
'--headless',
]);
})->all());
return RemoteWebDriver::create(
$_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515',
DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
}
/**
* Determine whether the Dusk command has disabled headless mode.
*
* @return bool
*/
protected function hasHeadlessDisabled()
{
return isset($_SERVER['DUSK_HEADLESS_DISABLED']) ||
isset($_ENV['DUSK_HEADLESS_DISABLED']);
}
}