File tree Expand file tree Collapse file tree
client/src/components/Tour Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ const PLAY_DELAY = 3000;
1818const props = defineProps <{
1919 steps: { title: string ; content: string ; onNext? : () => Promise <void >; onBefore? : () => Promise <void > }[];
2020 requirements: string [];
21+ /** A way to use the vue-router which won't be available in this component locally (because we mount it in `runTour`). */
22+ routePush? : (path : string ) => void ;
2123}>();
2224
2325const currentIndex = ref (- 1 );
@@ -69,13 +71,29 @@ const modalContents = computed<{
6971 title: " Requires Login" ,
7072 message: " You must log in to Galaxy to use this tour." ,
7173 variant: " info" ,
74+ okText: props .routePush ? " Login or Register" : undefined ,
75+ ok : async () => {
76+ if (props .routePush ) {
77+ props .routePush (" /login/start" );
78+ }
79+ },
7280 };
7381 }
7482 if (props .requirements .indexOf (" admin" ) >= 0 && ! isAdminUser (currentUser .value )) {
7583 return {
7684 title: " Requires Admin" ,
7785 message: " You must be an admin to use this tour." ,
7886 variant: " info" ,
87+ okText: props .routePush ? " Exit Tour" : undefined ,
88+ ok : async () => {
89+ if (props .routePush ) {
90+ if (isAnonymousUser (currentUser .value )) {
91+ props .routePush (" /login/start" );
92+ } else {
93+ props .routePush (" /" );
94+ }
95+ }
96+ },
7997 };
8098 }
8199 // TODO: better estimate for whether the history is new.
Original file line number Diff line number Diff line change 1- <template >
2- <CenterFrame src =" /welcome" />
3- </template >
4-
5- <script >
6- import CenterFrame from " entry/analysis/modules/CenterFrame" ;
1+ <script setup lang="ts">
2+ import { useRouter } from " vue-router/composables" ;
73
84import { runTour } from " ./runTour" ;
95
10- export default {
11- components: {
12- CenterFrame,
13- },
14- props: {
15- tourId: {
16- type: String ,
17- required: true ,
18- },
19- },
20- mounted () {
21- runTour (this .tourId );
22- },
23- };
6+ import CenterFrame from " @/entry/analysis/modules/CenterFrame.vue" ;
7+
8+ const props = defineProps <{
9+ tourId: string ;
10+ }>();
11+
12+ const router = useRouter ();
13+
14+ function routePush(path : string ) {
15+ router .push (path );
16+ }
17+
18+ runTour (props .tourId , null , routePush );
2419 </script >
20+
21+ <template >
22+ <CenterFrame src =" /welcome" />
23+ </template >
Original file line number Diff line number Diff line change @@ -87,9 +87,10 @@ function mountTour(props) {
8787 * Runs a Tour by identifier or from provided data.
8888 * @param {String } Unique Tour identifier (for api request)
8989 * @param {Object } Tour data
90+ * @param {Function } routePush function to handle route changes
9091 * @returns mounted instance
9192 */
92- export async function runTour ( tourId , tourData = null ) {
93+ export async function runTour ( tourId , tourData = null , routePush = undefined ) {
9394 if ( ! tourData ) {
9495 tourData = await getTourData ( tourId ) ;
9596 }
@@ -124,5 +125,5 @@ export async function runTour(tourId, tourData = null) {
124125 } ) ;
125126 } ) ;
126127 const requirements = tourData . requirements || [ ] ;
127- return mountTour ( { steps, requirements } ) ;
128+ return mountTour ( { steps, requirements, routePush } ) ;
128129}
You can’t perform that action at this time.
0 commit comments