Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds an option to restore activity bar defaults #18469

Merged
merged 4 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};
});
Loading