Skip to content

Commit

Permalink
feat: toggle visibility of dotfiles on frontend (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
marekful authored Apr 12, 2023
1 parent 8c8cf56 commit 959eeec
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
26 changes: 24 additions & 2 deletions frontend/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<span>{{ $t("sidebar.myFiles") }}</span>
</button>

<div v-if="user.perm.create">
<div v-if="user.perm.create && isListing">
<button
@click="$store.commit('showHover', 'newDir')"
class="action"
Expand All @@ -33,6 +33,19 @@
</button>
</div>

<div>
<button
v-if="isListing && !userHiddenDotfiles"
class="action"
@click="toggleDotfiles"
:aria-label="$t('sidebar.dotfiles')"
:title="this.$store.state.showDotfiles ? $t('sidebar.dotfiles_hide') : $t('sidebar.dotfiles_show')"
>
<i class="material-icons">{{ toggleDotfilesIcon }}</i>
<span>{{ $t("sidebar.dotfiles") }}</span>
</button>
</div>

<div>
<button
class="action"
Expand Down Expand Up @@ -134,14 +147,20 @@ export default {
},
computed: {
...mapState(["user"]),
...mapGetters(["isLogged"]),
...mapGetters(["isLogged", "isListing"]),
active() {
return this.$store.state.show === "sidebar";
},
signup: () => signup,
version: () => version,
disableExternal: () => disableExternal,
disableUsedPercentage: () => disableUsedPercentage,
toggleDotfilesIcon() {
return this.$store.state.showDotfiles ? "visibility" : "visibility_off";
},
userHiddenDotfiles() {
return this.user.hideDotfiles;
},
canLogout: () => (!noAuth && loginPage) || authMethod === "oidc",
},
asyncComputed: {
Expand Down Expand Up @@ -181,6 +200,9 @@ export default {
this.$router.push({ path: "/settings" }, () => {});
this.$store.commit("closeHovers");
},
toggleDotfiles() {
this.$store.commit("toggleDotfiles", true);
},
help() {
this.$store.commit("showHover", "help");
},
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/files/ListingItem.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div
class="item"
:class="{ item: true, dotfile: this.isDotFile, hidden: this.isDotFile && !showDotfiles }"
role="button"
tabindex="0"
:draggable="isDraggable"
Expand Down Expand Up @@ -61,7 +61,7 @@ export default {
"path",
],
computed: {
...mapState(["user", "selected", "req", "jwt"]),
...mapState(["user", "selected", "req", "jwt", "showDotfiles"]),
...mapGetters(["selectedCount"]),
singleClick() {
return this.readOnly == undefined && this.user.singleClick;
Expand Down Expand Up @@ -94,6 +94,9 @@ export default {
isThumbsEnabled() {
return enableThumbs;
},
isDotFile: function () {
return this.name[0] === ".";
},
},
methods: {
...mapMutations(["addSelected", "removeSelected", "resetSelected"]),
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/css/listing.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ body.rtl #listing {
vertical-align: bottom;
}

#listing .item.dotfile.hidden {
display: none;
}

.message {
text-align: center;
font-size: 2em;
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@
"users": "Users"
},
"sidebar": {
"dotfiles": "Dotfiles",
"dotfiles_show": "Dotfiles are hidden, click to show them",
"dotfiles_hide": "Dotfiles are shown, click to hide them",
"help": "Help",
"hugoNew": "Hugo New",
"login": "Login",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const state = {
show: null,
showShell: false,
showConfirm: null,
showDotfiles: true,
};

export default new Vuex.Store({
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const mutations = {
toggleShell: (state) => {
state.showShell = !state.showShell;
},
toggleDotfiles: (state) => {
state.showDotfiles = !state.showDotfiles;
},
showHover: (state, value) => {
if (typeof value !== "object") {
state.show = value;
Expand Down

0 comments on commit 959eeec

Please sign in to comment.