Skip to content

Commit

Permalink
Merge pull request #598 from lunarphp/develop
Browse files Browse the repository at this point in the history
0.1.0-rc.5
  • Loading branch information
alecritson authored Sep 29, 2022
2 parents 05433a2 + 748f4ae commit a6f3a7e
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 35 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) LunarPHP Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
2 changes: 1 addition & 1 deletion docs/src/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = {
nav: [
{
text: 'Roadmap',
link: 'https://github.com/orgs/lunarphp/projects/5',
link: 'https://github.com/orgs/lunarphp/projects/1',
},
{
text: 'Discord',
Expand Down
2 changes: 1 addition & 1 deletion docs/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Although the admin hub uses Laravel Livewire, there is no requirement for your a

Lunar as a company has grand plans to continue developing new functionality to help you build awesome e-commerce websites. We want Lunar to be a true alternative to the likes of Magento, Shopify, WooCommerce, etc.

Keep an eye on [our roadmap](https://github.com/orgs/lunarphp/projects/5) for future plans and recent releases.
Keep an eye on [our roadmap](https://github.com/orgs/lunarphp/projects/1) for future plans and recent releases.

## Get started

Expand Down
2 changes: 1 addition & 1 deletion docs/src/extending/admin-hub.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You should develop your additional functionality using Laravel Livewire using th
You can now modify the hub logo and fav icon, please publish views using the command below.

```bash
php artisan vendor:publish --tag=lunar-hub-views
php artisan vendor:publish --tag=lunar.hub.views
```

## Adding to Menus
Expand Down
2 changes: 1 addition & 1 deletion docs/src/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ Lunar assumes your User ID field is a "BIGINT". If you are using an "INT" or "UU
You can optionally publish Lunar's migrations so they're added to your Laravel app.

```sh
php artisan vendor:publish --tag=lunar-migrations
php artisan vendor:publish --tag=lunar.migrations
```
2 changes: 1 addition & 1 deletion docs/src/lunar/orders.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ Here's an example of what the template could look like:
By default when you click "Download PDF" in the hub when viewing an order, you will get a basic PDF generated for you to download. You can publish the view that powers this to create your own PDF template.

```bash
php artisan vendor:publish --tag=lunar-hub-views
php artisan vendor:publish --tag=lunar.hub.views
```

This will create a view called `resources/vendor/adminhub/pdf/order.blade.php`, where you will be able to freely customise the PDF you want displayed on download.
23 changes: 23 additions & 0 deletions docs/src/upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ Re-publish the admin hub assets
php artisan lunar:hub:install
```

## 0.1.0-rc.5

### Changed

#### Publishing changes

All publishing commands for Lunar now use `.` as a separator.

- Rename `lunar-hub-translations` to `lunar.hub.translations`
- Rename `lunar-hub-views` to `lunar.hub.views`
- Rename `lunar:hub:public` to `lunar.hub.public`
- Rename `lunar-migrations` to `lunar.migrations`

#### Brand requirement is now configurable.

Whether the product brand is required on your store is now configurable, the default behaviour is set to `true`. If you wish to change this, simply update `config/lunar-hub/products.php`.

```php
'require_brand' => false,
```

---

## Migrating from GetCandy to Lunar

The initial release of Lunar will be version `0.1.0`. This allows for a rapid development cycle until we reach `1.0.0`.
Expand Down
11 changes: 11 additions & 0 deletions packages/admin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## 0.1.0-rc.5

### Fixed

- Image manager with now use a set key when referenced by array index to keep Livewire state intact.

### Changed

- Brand requirement is now configurable via `config/lunar-hub/products.php`
- Updated publishing tag to be more consistent

## 0.1.0-rc.4

### Fixed
Expand Down
11 changes: 11 additions & 0 deletions packages/admin/config/products.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
*/
'disable_variants' => false,

/*
|--------------------------------------------------------------------------
| Require brand
|--------------------------------------------------------------------------
|
| If products are required to have a brand associated to them, set this to
| true, otherwise if brand is optional, set to false.
|
*/
'require_brand' => true,

/*
|--------------------------------------------------------------------------
| Product identifiers
Expand Down
17 changes: 8 additions & 9 deletions packages/admin/resources/views/partials/image-manager.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ class="sr-only peer"
<div wire:sort
sort.options='{group: "images", method: "sort"}'
class="relative mt-4 space-y-2">
@foreach ($this->images as $image)
@foreach ($this->images as $key => $image)
<div class="flex items-center justify-between p-4 bg-white border rounded-md shadow-sm"
sort.item="images"
sort.id="{{ $image['sort_key'] }}"
wire:key="image_{{ $image['sort_key'] }}">
sort.id="{{ $key }}"
wire:key="image_{{ $key }}">
<div class="flex items-center w-full space-x-6">
@if (count($images) > 1)
<div class="cursor-move"
Expand All @@ -91,24 +91,24 @@ class="text-gray-400 cursor-grab" />

<div>
<button type="button"
wire:click="$set('images.{{ $loop->index }}.preview', true)">
wire:click="$set('images.{{ $key }}.preview', true)">
<img src="{{ $image['thumbnail'] }}"
class="w-8 overflow-hidden rounded-md" />
</button>
<x-hub::modal wire:model="images.{{ $loop->index }}.preview">
<x-hub::modal wire:model="images.{{ $key }}.preview">
<img src="{{ $image['original'] }}">
</x-hub::modal>
</div>

<div class="w-full">
<x-hub::input.text wire:model="images.{{ $loop->index }}.caption"
<x-hub::input.text wire:model="images.{{ $key }}.caption"
placeholder="Enter Alt. text" />
</div>

<div class="flex items-center ml-4 space-x-4">
<x-hub::tooltip text="Make primary">
<x-hub::input.toggle :disabled="$image['primary']"
wire:model="images.{{ $loop->index }}.primary"/>
wire:model="images.{{ $key }}.primary"/>
</x-hub::tooltip>

@if (!empty($image['id']))
Expand All @@ -124,13 +124,12 @@ class="text-gray-400 hover:text-indigo-500 hover:underline" />
@endif

<button type="button"
wire:click.prevent="removeImage('{{ $image['sort_key'] }}')"
wire:click.prevent="removeImage('{{ $key }}')"
class="text-gray-400 hover:text-red-500 "
@if($image['primary']) disabled @endif>
<x-hub::icon ref="trash"
style="solid" />
</button>

</div>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions packages/admin/src/AdminHubServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,16 @@ public function boot()

$this->publishes([
__DIR__.'/../database/migrations/' => database_path('migrations'),
], 'lunar-migrations');
], 'lunar.migrations');

$this->publishes([
__DIR__.'/../resources/views/components/branding' => resource_path('views/vendor/adminhub/components/branding'),
__DIR__.'/../resources/views/pdf' => resource_path('views/vendor/adminhub'),
], 'lunar-hub-views');
], 'lunar.hub.views');

$this->publishes([
__DIR__.'/../resources/lang' => resource_path('lang/vendor/adminhub'),
], 'lunar-hub-translations');
], 'lunar.hub.translations');

$this->commands([
InstallHub::class,
Expand Down Expand Up @@ -442,7 +442,7 @@ private function registerPublishables()
{
$this->publishes([
__DIR__.'/../public' => public_path('vendor/lunar/admin-hub/'),
], 'lunar:hub:public');
], 'lunar.hub.public');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Console/Commands/InstallHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class InstallHub extends Command
{
protected $commands = [
'vendor:publish --tag=lunar:hub:public --force',
'vendor:publish --tag=lunar.hub.public --force',
'vendor:publish --tag=lunar.livewiretables.public --force',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ protected function rules()
{
$baseRules = [
'product.status' => 'required|string',
'product.brand_id' => 'required_without:brand',
'brand' => 'required_without:product.brand_id|unique:'.Brand::class.',name',
'product.product_type_id' => 'required',
'product.brand_id' => 'nullable',
'brand' => 'nullable',
'collections' => 'nullable|array',
'variant.tax_ref' => 'nullable|string|max:255',
'associations.*.type' => 'required|string',
Expand All @@ -239,6 +239,11 @@ protected function rules()
], $this->variant),
];

if (config('lunar-hub.products.require_brand', true)) {
$baseRules['product.brand_id'] = 'required_without:brand';
$baseRules['brand'] = 'required_without:product.brand_id|unique:'.Brand::class.',name';
}

if ($this->getVariantsCount() <= 1) {
$baseRules = array_merge(
$baseRules,
Expand Down
33 changes: 20 additions & 13 deletions packages/admin/src/Http/Livewire/Traits/HasImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,20 @@ public function mountHasImages()
{
$owner = $this->getMediaModel();

$this->images = $owner->getMedia('images')->map(function ($media) {
$this->images = $owner->getMedia('images')->mapWithKeys(function ($media) {
$key = Str::random();

return [
'id' => $media->id,
'sort_key' => Str::random(),
'thumbnail' => $media->getFullUrl('medium'),
'original' => $media->getFullUrl(),
'preview' => false,
'caption' => $media->getCustomProperty('caption'),
'primary' => $media->getCustomProperty('primary'),
'position' => $media->getCustomProperty('position', 1),
$key => [
'id' => $media->id,
'sort_key' => $key,
'thumbnail' => $media->getFullUrl('medium'),
'original' => $media->getFullUrl(),
'preview' => false,
'caption' => $media->getCustomProperty('caption'),
'primary' => $media->getCustomProperty('primary'),
'position' => $media->getCustomProperty('position', 1),
],
];
})->sortBy('position')->values()->toArray();
}
Expand Down Expand Up @@ -151,9 +155,11 @@ public function handleUploadFinished($name, array $filenames = [])
foreach ($filenames as $key => $filename) {
$file = TemporaryUploadedFile::createFromLivewire($filename);

$this->images[] = [
$key = Str::random();

$this->images[$key] = [
'thumbnail' => $file->temporaryUrl(),
'sort_key' => Str::random(),
'sort_key' => $key,
'filename' => $filename,
'original' => $file->temporaryUrl(),
'caption' => null,
Expand Down Expand Up @@ -291,10 +297,11 @@ public function selectImages()
$chosen = Media::findMany($this->selectedImages);

foreach ($chosen as $media) {
$this->images[] = [
$key = Str::random();
$this->images[$key] = [
'id' => $media->id,
'thumbnail' => $media->getUrl('small'),
'sort_key' => Str::random(),
'sort_key' => $key,
'filename' => $media->file_name,
'original' => $media->getUrl(),
'caption' => null,
Expand Down
7 changes: 7 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## 0.1.0-rc.5

### Changed

- Updated publishing tag to be more consistent

## 0.1.0-rc.4

### Fixed

- Lunar migration command will now add brands into the correct table.
- Added additional check for language existence when running the brand update state class.
- Publishing commands now use a consistent syntax.

## 0.1.0-rc.3

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/LunarServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function boot(): void

$this->publishes([
__DIR__.'/../database/migrations/' => database_path('migrations'),
], 'lunar-migrations');
], 'lunar.migrations');

$this->commands([
InstallLunar::class,
Expand Down
10 changes: 10 additions & 0 deletions utils/livewire-tables/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## 0.1.0-rc.5

### Changed

- Updated publishing tag to be more consistent

## 0.1.0-rc.4

> No notable changes
## 0.1.0-rc.3

> No notable changes
Expand Down

1 comment on commit a6f3a7e

@vercel
Copy link

@vercel vercel bot commented on a6f3a7e Sep 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.