Skip to content

Commit 311f0f0

Browse files
authored
Merge pull request #157 from opcodesio/small-improvements
small UI improvements to multi-file deletion
2 parents 32d36e9 + f6cc734 commit 311f0f0

File tree

6 files changed

+40
-23
lines changed

6 files changed

+40
-23
lines changed

public/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/css/app.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,3 +537,18 @@ html.dark {
537537
@apply outline-none ring-2 ring-emerald-500 dark:ring-emerald-700;
538538
}
539539
}
540+
541+
button.button, a.button {
542+
@apply block flex items-center w-full px-4 py-2 text-left text-sm outline-emerald-500 dark:outline-emerald-800 text-gray-900 dark:text-gray-200 rounded-md;
543+
& > svg {
544+
@apply w-4 h-4 text-gray-600 dark:text-gray-400;
545+
&.spin {
546+
// Spinner is slightly dimmer by default, especially because it's constantly spinning
547+
// and it's also a little smaller in size
548+
@apply text-gray-600;
549+
}
550+
}
551+
}
552+
button.button:hover, a.button:hover {
553+
@apply bg-gray-50 dark:bg-gray-700;
554+
}

resources/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Alpine.store('fileViewer', {
106106
}
107107
})
108108
},
109-
checkBoxesVisibility:false,
109+
checkBoxesVisibility: false,
110110
filesChecked: [],
111111
foldersOpen: [],
112112
foldersInView: [],

resources/views/livewire/file-list.blade.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@
3232
</div>
3333
</div>
3434

35+
<div class="grid grid-flow-col pr-4 mt-2" x-bind:class="[$store.fileViewer.filesChecked.length ? 'justify-between' : 'justify-end']" x-show="$store.fileViewer.checkBoxesVisibility">
36+
<button x-show="$store.fileViewer.filesChecked.length" x-on:click.stop="if (confirm('Are you sure you want to delete selected log files? THIS ACTION CANNOT BE UNDONE.')) { $wire.call('deleteMultipleFiles', $store.fileViewer.filesChecked) }"
37+
class="button inline-flex">
38+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="w-5 mr-1" fill="currentColor"><use href="#icon-trashcan" /></svg>
39+
Delete selected files
40+
</button>
41+
<button class="button inline-flex" x-on:click.stop="$store.fileViewer.showCheckBoxes(); $store.fileViewer.resetChecks()">
42+
Cancel <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="w-5 ml-1" fill="currentColor"><use href="#icon-cross" /></svg>
43+
</button>
44+
</div>
45+
3546
<div id="file-list-container" class="relative h-full overflow-hidden" x-cloak>
3647
<div class="pointer-events-none absolute z-10 top-0 h-4 w-full bg-gradient-to-b from-gray-100 dark:from-gray-900 to-transparent"></div>
3748
<div class="file-list" x-ref="fileList" x-on:scroll="(event) => $store.fileViewer.onScroll(event)">
@@ -98,14 +109,6 @@ class="dropdown w-48"
98109
</div>
99110

100111
<div class="folder-files pl-3 ml-1 border-l border-gray-200 dark:border-gray-800" x-show="$store.fileViewer.isOpen(folder)">
101-
<div class="grid grid-flow-col gap-x-32" x-show="$store.fileViewer.filesChecked.length">
102-
<button x-on:click.stop="if (confirm('Are you sure you want to delete selected log files? THIS ACTION CANNOT BE UNDONE.')) { $wire.call('deleteMultipleFiles', $store.fileViewer.filesChecked) }" class="pt-4 pb-3 inline-flex" >
103-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="w-5" fill="currentColor"><use href="#icon-trashcan" /></svg>&nbsp;<small>Delete Selected Files</small>
104-
</button>
105-
<button class="inline-flex pt-4 pb-3" x-on:click.stop="$store.fileViewer.showCheckBoxes(), $store.fileViewer.resetChecks()">
106-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" class="w-5" fill="currentColor"><use href="#icon-cross" /></svg>
107-
</button>
108-
</div>
109112
@foreach($folder->files() as $logFile)
110113
@include('log-viewer::partials.file-list-item', ['logFile' => $logFile])
111114
@endforeach

resources/views/partials/file-list-item.blade.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
x-on:focusin.window="! $refs.panel.contains($event.target) && close()"
99
x-id="['dropdown-button']"
1010
>
11-
@can('deleteLogFile', $logFile)
12-
<div class="my-auto px-2" x-show="$store.fileViewer.checkBoxesVisibility">
13-
<input
14-
type="checkbox"
15-
x-init="$watch(`$store.fileViewer.isChecked('{{$logFile->identifier}}')`, (value) => {
16-
$el.checked = value;
17-
})"
18-
x-on:click.stop="$store.fileViewer.checkBoxToggle('{{$logFile->identifier}}')"
19-
value="{{$logFile->identifier}}" />
20-
</div>
21-
@endcan
2211
<div class="file-item grow">
12+
@can('deleteLogFile', $logFile)
13+
<div class="my-auto mr-2" x-show="$store.fileViewer.checkBoxesVisibility">
14+
<input type="checkbox"
15+
x-init="$watch(`$store.fileViewer.isChecked('{{$logFile->identifier}}')`, (value) => {
16+
$el.checked = value;
17+
})"
18+
x-on:click.stop="$store.fileViewer.checkBoxToggle('{{$logFile->identifier}}')"
19+
value="{{$logFile->identifier}}" />
20+
</div>
21+
@endcan
2322
<p class="file-name">{{ $logFile->name }}</p>
2423
<span class="file-size">{{ $logFile->sizeFormatted() }}</span>
2524
<button type="button" class="file-dropdown-toggle"
@@ -60,7 +59,7 @@ class="dropdown w-48"
6059
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><use href="#icon-trashcan" /></svg>
6160
Delete
6261
</button>
63-
<button x-on:click.stop="$store.fileViewer.showCheckBoxes()">
62+
<button x-on:click.stop="$store.fileViewer.showCheckBoxes(); $store.fileViewer.checkBoxToggle('{{$logFile->identifier}}'); close($refs.button)">
6463
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><use href="#icon-trashcan" /></svg>
6564
Delete Multiple
6665
</button>

src/Http/Livewire/FileList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function deleteFile(string $fileIdentifier)
8080

8181
public function deleteMultipleFiles(array $selectedFilesArray)
8282
{
83-
foreach($selectedFilesArray as $fileIdentifier){
83+
foreach ($selectedFilesArray as $fileIdentifier) {
8484
$this->deleteFile($fileIdentifier);
8585
}
8686
$this->dispatchBrowserEvent('files-deleted');

0 commit comments

Comments
 (0)