Skip to content

Commit

Permalink
Merge pull request #18469 from guerler/allow_ab_reset
Browse files Browse the repository at this point in the history
Adds an option to restore activity bar defaults
  • Loading branch information
martenson authored Jul 14, 2024
2 parents fdd9cb0 + 2c83500 commit 4fec21e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
27 changes: 27 additions & 0 deletions client/src/components/Panels/SettingsPanel.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<script setup lang="ts">
import { faUndo } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BButton, BModal } from "bootstrap-vue";
import { ref } from "vue";
import { useActivityStore } from "@/stores/activityStore";
import ActivitySettings from "@/components/ActivityBar/ActivitySettings.vue";
import DelayedInput from "@/components/Common/DelayedInput.vue";
import ActivityPanel from "@/components/Panels/ActivityPanel.vue";
const activityStore = useActivityStore();
const confirmRestore = ref(false);
const query = ref("");
function onQuery(newQuery: string) {
Expand All @@ -17,6 +25,25 @@ function onQuery(newQuery: string) {
<template v-slot:header>
<DelayedInput :delay="100" placeholder="Search activities" @change="onQuery" />
</template>
<template v-slot:header-buttons>
<BButton
v-b-tooltip.bottom.hover
data-description="restore factory settings"
size="sm"
variant="link"
title="Restore default"
@click="confirmRestore = true">
<span v-localize>Reset</span>
<FontAwesomeIcon :icon="faUndo" fixed-width />
</BButton>
</template>
<ActivitySettings :query="query" />
<BModal
v-model="confirmRestore"
title="Restore Activity Bar Defaults"
title-tag="h2"
@ok="activityStore.restore()">
<p v-localize>Are you sure you want to reset the activity bar to its default settings?</p>
</BModal>
</ActivityPanel>
</template>
2 changes: 1 addition & 1 deletion client/src/stores/activitySetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const Activities = [
optional: true,
panel: false,
title: "Libraries",
tooltip: "Access Data Libraries",
tooltip: "Access data libraries",
to: "/libraries",
visible: true,
},
Expand Down
8 changes: 8 additions & 0 deletions client/src/stores/activityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export interface Activity {
export const useActivityStore = defineStore("activityStore", () => {
const activities: Ref<Array<Activity>> = useUserLocalStorage("activity-store-activities", []);

/**
* Restores the default activity bar items
*/
function restore() {
activities.value = Activities.slice();
}

/**
* The set of built-in activities is defined in activitySetup.js.
* This helper function applies changes of the built-in activities,
Expand Down Expand Up @@ -100,6 +107,7 @@ export const useActivityStore = defineStore("activityStore", () => {
getAll,
remove,
setAll,
restore,
sync,
};
});

0 comments on commit 4fec21e

Please sign in to comment.