Skip to content

Commit 5417fba

Browse files
committed
Update Navbar
- disable delete, copy, cut if no item selected - show notification on cut and copy - upload icon changed
1 parent dc49741 commit 5417fba

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/components/blocks/Navbar.vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,30 @@
3636
disabled
3737
v-if="uploading"
3838
v-bind:title="lang.btn.upload">
39-
<i class="fas fa-download"></i>
39+
<i class="fas fa-upload"></i>
4040
</button>
4141
<button type="button" class="btn btn-secondary"
4242
v-else
4343
v-on:click="showModal('Upload')"
4444
v-bind:title="lang.btn.upload">
45-
<i class="fas fa-download"></i>
45+
<i class="fas fa-upload"></i>
4646
</button>
4747
<button type="button" class="btn btn-secondary"
48+
v-bind:disabled="!isAnyItemSelected"
4849
v-on:click="showModal('Delete')"
4950
v-bind:title="lang.btn.delete">
5051
<i class="fas fa-trash-alt"></i>
5152
</button>
5253
</div>
5354
<div class="btn-group" role="group">
5455
<button type="button" class="btn btn-secondary"
56+
v-bind:disabled="!isAnyItemSelected"
5557
v-bind:title="lang.btn.copy"
5658
v-on:click="toClipboard('copy')">
5759
<i class="fas fa-copy"></i>
5860
</button>
5961
<button type="button" class="btn btn-secondary"
62+
v-bind:disabled="!isAnyItemSelected"
6063
v-bind:title="lang.btn.cut"
6164
v-on:click="toClipboard('cut')">
6265
<i class="fas fa-cut"></i>
@@ -106,6 +109,7 @@
106109

107110
<script>
108111
import translate from './../../mixins/translate';
112+
import EventBus from './../../eventBus';
109113
110114
export default {
111115
mixins: [translate],
@@ -135,6 +139,15 @@ export default {
135139
this.$store.state.fm[this.activeManager].history.length - 1;
136140
},
137141
142+
/**
143+
* Is any files or directories selected?
144+
* @returns {boolean}
145+
*/
146+
isAnyItemSelected() {
147+
return this.$store.state.fm[this.activeManager].selected.files.length > 0 ||
148+
this.$store.state.fm[this.activeManager].selected.directories.length > 0;
149+
},
150+
138151
/**
139152
* Manager view type - grid or table
140153
* @returns {default.computed.viewType|(function())|string}
@@ -195,6 +208,13 @@ export default {
195208
*/
196209
toClipboard(type) {
197210
this.$store.dispatch('fm/toClipboard', type);
211+
212+
// show notification
213+
if(type === 'cut') {
214+
EventBus.$emit('addNotification', {status: 'success', message: 'Cut to clipboard!'});
215+
} else if(type === 'copy') {
216+
EventBus.$emit('addNotification', {status: 'success', message: 'Copied to clipboard!'});
217+
}
198218
},
199219
200220
/**

0 commit comments

Comments
 (0)