Skip to content

Commit c30f7cf

Browse files
committed
Fix tour for anonymous users
1 parent 6995f9b commit c30f7cf

File tree

7 files changed

+15
-23
lines changed

7 files changed

+15
-23
lines changed

engine-wizard/elm/Wizard/Common/Driver.elm

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ port module Wizard.Common.Driver exposing
22
( DriverOptionsStep
33
, TourConfig
44
, TourId
5-
, addCompletedTourIds
65
, addModalDelay
76
, addStep
87
, init
@@ -14,7 +13,9 @@ port module Wizard.Common.Driver exposing
1413
import Gettext exposing (gettext)
1514
import Json.Encode as E
1615
import Json.Encode.Extra as E
16+
import Shared.Auth.Session as Session
1717
import String.Format as String
18+
import Wizard.Common.AppState exposing (AppState)
1819

1920

2021
type TourId
@@ -32,29 +33,26 @@ type TourConfig
3233

3334
type alias TourConfigData =
3435
{ tourId : String
36+
, loggedIn : Bool
3537
, completedTourIds : List String
3638
, locale : Gettext.Locale
3739
, steps : List DriverOptionsStep
3840
, delay : Int
3941
}
4042

4143

42-
tourConfig : TourId -> Gettext.Locale -> TourConfig
43-
tourConfig (TourId id) locale =
44+
tourConfig : TourId -> AppState -> TourConfig
45+
tourConfig (TourId id) appState =
4446
TourConfig
4547
{ tourId = id
46-
, completedTourIds = []
47-
, locale = locale
48+
, loggedIn = Session.exists appState.session
49+
, completedTourIds = appState.config.tours
50+
, locale = appState.locale
4851
, steps = []
4952
, delay = 0
5053
}
5154

5255

53-
addCompletedTourIds : List String -> TourConfig -> TourConfig
54-
addCompletedTourIds completedTourIds (TourConfig config) =
55-
TourConfig { config | completedTourIds = completedTourIds }
56-
57-
5856
addStep : DriverOptionsStep -> TourConfig -> TourConfig
5957
addStep step (TourConfig config) =
6058
TourConfig { config | steps = config.steps ++ [ step ] }
@@ -114,7 +112,7 @@ encodeStep step =
114112

115113
init : TourConfig -> Cmd msg
116114
init (TourConfig config) =
117-
if List.member config.tourId config.completedTourIds then
115+
if not config.loggedIn || List.member config.tourId config.completedTourIds then
118116
Cmd.none
119117

120118
else

engine-wizard/elm/Wizard/Dashboard/Update.elm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ tour appState =
5656
, description = gettext "We'll guide you through creating your data management plan." appState.locale
5757
}
5858
in
59-
Driver.tourConfig TourId.dashboard appState.locale
60-
|> Driver.addCompletedTourIds appState.config.tours
59+
Driver.tourConfig TourId.dashboard appState
6160
|> Driver.addStep
6261
{ element = Nothing
6362
, popover = firstStep

engine-wizard/elm/Wizard/Projects/Create/Update.elm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ tour appState createFromTemplate createCustom =
135135
}
136136
}
137137
in
138-
Driver.tourConfig TourId.projectsCreate appState.locale
139-
|> Driver.addCompletedTourIds appState.config.tours
138+
Driver.tourConfig TourId.projectsCreate appState
140139
|> Driver.addStep
141140
{ element = selectDataTour "form-group_name"
142141
, popover =

engine-wizard/elm/Wizard/Projects/Detail/Components/ShareModal.elm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ openMsg =
129129

130130
tour : AppState -> TourConfig
131131
tour appState =
132-
Driver.tourConfig TourId.projectsDetailShareModal appState.locale
133-
|> Driver.addCompletedTourIds appState.config.tours
132+
Driver.tourConfig TourId.projectsDetailShareModal appState
134133
|> Driver.addModalDelay
135134
|> Driver.addStep
136135
{ element = selectDataTour "project-detail_share-modal_users"

engine-wizard/elm/Wizard/Projects/Detail/Update.elm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ fetchSubrouteData appState model =
131131

132132
tour : AppState -> TourConfig
133133
tour appState =
134-
Driver.tourConfig TourId.projectsDetail appState.locale
135-
|> Driver.addCompletedTourIds appState.config.tours
134+
Driver.tourConfig TourId.projectsDetail appState
136135
|> Driver.addStep
137136
{ element = selectDataTour "questionnaire_body"
138137
, popover =

engine-wizard/elm/Wizard/Projects/Index/Update.elm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ fetchData appState model =
7878

7979
tour : AppState -> TourConfig
8080
tour appState =
81-
Driver.tourConfig TourId.projectsIndex appState.locale
82-
|> Driver.addCompletedTourIds appState.config.tours
81+
Driver.tourConfig TourId.projectsIndex appState
8382
|> Driver.addStep
8483
{ element = Nothing
8584
, popover =

engine-wizard/elm/Wizard/Users/Edit/Components/Tours.elm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ fetchData appState =
4242

4343
tour : AppState -> TourConfig
4444
tour appState =
45-
Driver.tourConfig TourId.usersEditTours appState.locale
46-
|> Driver.addCompletedTourIds appState.config.tours
45+
Driver.tourConfig TourId.usersEditTours appState
4746
|> Driver.addStep
4847
{ element = Nothing
4948
, popover =

0 commit comments

Comments
 (0)