11<script setup lang="ts">
2- import {
3- faArchive ,
4- faBars ,
5- faBurn ,
6- faColumns ,
7- faCopy ,
8- faExchangeAlt ,
9- faFileArchive ,
10- faFileExport ,
11- faList ,
12- faPlay ,
13- faPlus ,
14- faSpinner ,
15- faStream ,
16- faTrash ,
17- faUsersCog ,
18- } from " @fortawesome/free-solid-svg-icons" ;
2+ import { faExchangeAlt , faPlus , faSpinner } from " @fortawesome/free-solid-svg-icons" ;
193import { FontAwesomeIcon } from " @fortawesome/vue-fontawesome" ;
20- import axios from " axios" ;
21- import {
22- BButton ,
23- BButtonGroup ,
24- BDropdown ,
25- BDropdownDivider ,
26- BDropdownItem ,
27- BDropdownText ,
28- BFormCheckbox ,
29- BModal ,
30- BSpinner ,
31- } from " bootstrap-vue" ;
4+ import { BButton , BButtonGroup } from " bootstrap-vue" ;
325import { storeToRefs } from " pinia" ;
33- import { computed , ref } from " vue" ;
6+ import { ref } from " vue" ;
347
35- import { canMutateHistory , type HistorySummary } from " @/api" ;
36- import { iframeRedirect } from " @/components/plugins/legacyNavigation" ;
37- import { useToast } from " @/composables/toast" ;
38- import { getAppRoot } from " @/onload/loadConfig" ;
8+ import type { HistorySummary } from " @/api" ;
399import { useHistoryStore } from " @/stores/historyStore" ;
4010import { useUserStore } from " @/stores/userStore" ;
4111import localize from " @/utils/localization" ;
42- import { rethrowSimple } from " @/utils/simple-error" ;
4312
44- import CopyModal from " @/components/History/Modals/CopyModal .vue" ;
13+ import HistoryOptions from " @/components/History/HistoryOptions .vue" ;
4514import SelectorModal from " @/components/History/Modals/SelectorModal.vue" ;
4615
4716interface Props {
48- histories: HistorySummary [];
4917 history: HistorySummary ;
50- historiesLoading? : boolean ;
5118 minimal? : boolean ;
5219}
5320
5421const props = withDefaults (defineProps <Props >(), {
55- historiesLoading: false ,
5622 minimal: false ,
5723});
5824
59- // modal refs
60- const showSwitchModal = ref (false );
61- const showDeleteModal = ref (false );
62- const showCopyModal = ref (false );
63-
64- const purgeHistory = ref (false );
25+ const historyStore = useHistoryStore ();
26+ const { histories, changingCurrentHistory } = storeToRefs (historyStore );
6527
66- const toast = useToast ( );
28+ const showSwitchModal = ref ( false );
6729
6830const userStore = useUserStore ();
69- const historyStore = useHistoryStore ();
7031
7132const { isAnonymous } = storeToRefs (userStore );
72- const { totalHistoryCount, changingCurrentHistory } = storeToRefs (historyStore );
73-
74- const canEditHistory = computed (() => {
75- return canMutateHistory (props .history );
76- });
77-
78- const isDeletedNotPurged = computed (() => {
79- return props .history .deleted && ! props .history .purged ;
80- });
81-
82- const historyState = computed (() => {
83- if (props .history .purged ) {
84- return " purged" ;
85- } else if (props .history .deleted ) {
86- return " deleted" ;
87- } else if (props .history .archived ) {
88- return " archived" ;
89- } else {
90- return " active" ;
91- }
92- });
93-
94- function onDelete() {
95- if (purgeHistory .value ) {
96- historyStore .deleteHistory (props .history .id , true );
97- } else {
98- historyStore .deleteHistory (props .history .id , false );
99- }
100- }
10133
10234function userTitle(title : string ) {
10335 if (isAnonymous .value ) {
@@ -106,16 +38,6 @@ function userTitle(title: string) {
10638 return localize (title );
10739 }
10840}
109-
110- async function resumePausedJobs() {
111- const url = ` ${getAppRoot ()}history/resume_paused_jobs?current=True ` ;
112- try {
113- const response = await axios .get (url );
114- toast .success (response .data .message );
115- } catch (e ) {
116- rethrowSimple (e );
117- }
118- }
11941 </script >
12042
12143<template >
@@ -154,130 +76,7 @@ async function resumePausedJobs() {
15476 :spin =" changingCurrentHistory" />
15577 </BButton >
15678
157- <BDropdown
158- v-b-tooltip.top.hover.noninteractive
159- no-caret
160- size =" sm"
161- :variant =" props.minimal ? 'outline-info' : 'link'"
162- toggle-class =" text-decoration-none"
163- menu-class =" history-options-button-menu"
164- title =" History options"
165- right
166- data-description =" history options" >
167- <template v-slot :button-content >
168- <FontAwesomeIcon fixed-width :icon =" faBars" />
169- <span class =" sr-only" >History Options</span >
170- </template >
171-
172- <BDropdownText >
173- <div v-if =" historiesLoading" >
174- <BSpinner v-if =" historiesLoading" small />
175- <span >Fetching histories from server</span >
176- </div >
177-
178- <span v-else-if =" !props.minimal" >You have {{ totalHistoryCount }} histories.</span >
179- <span v-else >Manage History</span >
180- </BDropdownText >
181-
182- <BDropdownItem
183- v-if =" !props.minimal"
184- data-description =" switch to multi history view"
185- :disabled =" isAnonymous"
186- :title =" userTitle('Open History Multiview')"
187- @click =" $router.push('/histories/view_multiple')" >
188- <FontAwesomeIcon fixed-width class =" mr-1" :icon =" faColumns" />
189- <span v-localize >Show Histories Side-by-Side</span >
190- </BDropdownItem >
191-
192- <BDropdownDivider v-if =" !props.minimal" />
193-
194- <BDropdownText v-if =" !canEditHistory" >
195- This history has been <span class =" font-weight-bold" >{{ historyState }}</span
196- >.
197- <span v-localize >Some actions might not be available.</span >
198- </BDropdownText >
199-
200- <BDropdownDivider v-if =" !canEditHistory" />
201-
202- <BDropdownItem
203- :disabled =" !canEditHistory"
204- :title =" localize('Resume all Paused Jobs in this History')"
205- @click =" resumePausedJobs()" >
206- <FontAwesomeIcon fixed-width :icon =" faPlay" class =" mr-1" />
207- <span v-localize >Resume Paused Jobs</span >
208- </BDropdownItem >
209-
210- <BDropdownDivider />
211-
212- <BDropdownItem
213- :disabled =" isAnonymous"
214- :title =" userTitle('Copy History to a New History')"
215- @click =" showCopyModal = !showCopyModal" >
216- <FontAwesomeIcon fixed-width :icon =" faCopy" class =" mr-1" />
217- <span v-localize >Copy this History</span >
218- </BDropdownItem >
219-
220- <BDropdownItem
221- :disabled =" !canEditHistory"
222- :title =" localize(isDeletedNotPurged ? 'Permanently Delete History' : 'Delete History')"
223- @click =" showDeleteModal = !showDeleteModal" >
224- <FontAwesomeIcon fixed-width :icon =" isDeletedNotPurged ? faBurn : faTrash" class =" mr-1" />
225- <span v-if =" isDeletedNotPurged" v-localize >Permanently Delete History</span >
226- <span v-else v-localize >Delete this History</span >
227- </BDropdownItem >
228-
229- <BDropdownItem
230- :title =" localize('Export references for all Tools used in this History')"
231- @click =" $router.push(`/histories/citations?id=${history.id}`)" >
232- <FontAwesomeIcon fixed-width :icon =" faStream" class =" mr-1" />
233- <span v-localize >Export Tool References</span >
234- </BDropdownItem >
235-
236- <BDropdownItem
237- data-description =" export to file"
238- :disabled =" history.purged"
239- :title =" localize('Export and Download History as a File')"
240- @click =" $router.push(`/histories/${history.id}/export`)" >
241- <FontAwesomeIcon fixed-width :icon =" faFileArchive" class =" mr-1" />
242- <span v-localize >Export History to File</span >
243- </BDropdownItem >
244-
245- <BDropdownItem
246- :disabled =" isAnonymous || history.archived || history.purged"
247- data-description =" archive history"
248- :title =" userTitle('Archive this History')"
249- @click =" $router.push(`/histories/${history.id}/archive`)" >
250- <FontAwesomeIcon fixed-width :icon =" faArchive" class =" mr-1" />
251- <span v-localize >Archive History</span >
252- </BDropdownItem >
253-
254- <BDropdownItem
255- :disabled =" isAnonymous"
256- :title =" userTitle('Convert History to Workflow')"
257- @click =" iframeRedirect(`/workflow/build_from_current_history?history_id=${history.id}`)" >
258- <FontAwesomeIcon fixed-width :icon =" faFileExport" class =" mr-1" />
259- <span v-localize >Extract Workflow</span >
260- </BDropdownItem >
261-
262- <BDropdownItem
263- :disabled =" isAnonymous"
264- :title =" userTitle('Display Workflow Invocations')"
265- @click =" $router.push(`/histories/${history.id}/invocations`)" >
266- <FontAwesomeIcon fixed-width :icon =" faList" class =" mr-1" />
267- <span v-localize >Show Invocations</span >
268- </BDropdownItem >
269-
270- <BDropdownDivider />
271-
272- <BDropdownItem
273- :disabled =" isAnonymous || !canEditHistory"
274- data-description =" share and manage access"
275- :title =" userTitle('Share, Publish, or Set Permissions for this History')"
276- @click =" $router.push(`/histories/sharing?id=${history.id}`)" >
277- <FontAwesomeIcon fixed-width :icon =" faUsersCog" class =" mr-1" />
278- <span v-localize >Share & Manage Access</span >
279- </BDropdownItem >
280- </BDropdown >
79+ <HistoryOptions :history =" history" :minimal =" props.minimal" />
28180 </BButtonGroup >
28281 </nav >
28382
@@ -288,21 +87,5 @@ async function resumePausedJobs() {
28887 :additional-options =" ['center', 'multi']"
28988 :show-modal.sync =" showSwitchModal"
29089 @selectHistory =" historyStore.setCurrentHistory($event.id)" />
291-
292- <CopyModal :history =" history" :show-modal.sync =" showCopyModal" />
293-
294- <BModal
295- v-model =" showDeleteModal"
296- :title =" isDeletedNotPurged ? 'Permanently Delete History?' : 'Delete History?'"
297- title-tag =" h2"
298- @ok =" onDelete"
299- @show =" purgeHistory = isDeletedNotPurged" >
300- <p v-localize >
301- Do you also want to permanently delete the history <i class =" ml-1" >{{ history.name }}</i >
302- </p >
303- <BFormCheckbox id =" purge-history" v-model =" purgeHistory" :disabled =" isDeletedNotPurged" >
304- <span v-localize >Yes, permanently delete this history.</span >
305- </BFormCheckbox >
306- </BModal >
30790 </div >
30891</template >
0 commit comments