1
1
import * as React from 'react' ;
2
2
3
- import { Box , Popover , Portal , Flex , LinkButton } from '@strapi/design-system' ;
3
+ import { Box , Popover , Portal , Flex , Button } from '@strapi/design-system' ;
4
4
import { FormattedMessage } from 'react-intl' ;
5
- import { NavLink } from 'react-router-dom' ;
6
5
import { styled } from 'styled-components' ;
7
6
8
7
import { useGetGuidedTourMetaQuery } from '../../services/admin' ;
@@ -20,6 +19,16 @@ import { Step, createStepComponents } from './Step';
20
19
* Tours
21
20
* -----------------------------------------------------------------------------------------------*/
22
21
22
+ const GotItAction = ( { onClick} :{ onClick :( ) => void } ) => {
23
+ return (
24
+ < Flex justifyContent = "end" width = "100%" >
25
+ < Button onClick = { onClick } >
26
+ < FormattedMessage id = "tours.gotIt" defaultMessage = "Got it" />
27
+ </ Button >
28
+ </ Flex >
29
+ ) ;
30
+ } ;
31
+
23
32
const tours = {
24
33
contentTypeBuilder :createTour ( 'contentTypeBuilder' , [
25
34
{
@@ -72,14 +81,18 @@ const tours = {
72
81
} ,
73
82
{
74
83
name :'Components' ,
75
- content :( Step ) => (
84
+ content :( Step , { dispatch } ) => (
76
85
< Step . Root side = "right" sideOffset = { 16 } >
77
86
< Step . Title id = "tours.contentTypeBuilder.Components.title" defaultMessage = "Components" />
78
87
< Step . Content
79
88
id = "tours.contentTypeBuilder.Components.content"
80
89
defaultMessage = "A reusable content structure that can be used across multiple content types, such as buttons, sliders or cards."
81
90
/>
82
- < Step . Actions />
91
+ < Step . Actions >
92
+ < GotItAction
93
+ onClick = { ( ) => dispatch ( { type :'next_step' , payload :'contentTypeBuilder' } ) }
94
+ />
95
+ </ Step . Actions >
83
96
</ Step . Root >
84
97
) ,
85
98
} ,
@@ -104,6 +117,9 @@ const tours = {
104
117
contentManager :createTour ( 'contentManager' , [
105
118
{
106
119
name :'Introduction' ,
120
+ when :( completedActions ) =>
121
+ completedActions . includes ( 'didCreateContentTypeSchema' ) &&
122
+ ! completedActions . includes ( 'didCreateContent' ) ,
107
123
content :( Step ) => (
108
124
< Step . Root side = "top" withArrow = { false } >
109
125
< Step . Title
@@ -133,14 +149,18 @@ const tours = {
133
149
} ,
134
150
{
135
151
name :'Publish' ,
136
- content :( Step ) => (
152
+ content :( Step , { dispatch } ) => (
137
153
< Step . Root side = "left" align = "center" >
138
154
< Step . Title id = "tours.contentManager.Publish.title" defaultMessage = "Publish" />
139
155
< Step . Content
140
156
id = "tours.contentManager.Publish.content"
141
157
defaultMessage = "Publish entries to make their content available through the Document Service API."
142
158
/>
143
- < Step . Actions />
159
+ < Step . Actions >
160
+ < GotItAction
161
+ onClick = { ( ) => dispatch ( { type :'next_step' , payload :'contentManager' } ) }
162
+ />
163
+ </ Step . Actions >
144
164
</ Step . Root >
145
165
) ,
146
166
} ,
@@ -165,6 +185,7 @@ const tours = {
165
185
apiTokens :createTour ( 'apiTokens' , [
166
186
{
167
187
name :'Introduction' ,
188
+ when :( completedActions ) => ! completedActions . includes ( 'didCreateApiToken' ) ,
168
189
content :( Step ) => (
169
190
< Step . Root sideOffset = { - 36 } withArrow = { false } >
170
191
< Step . Title id = "tours.apiTokens.Introduction.title" defaultMessage = "API tokens" />
@@ -194,7 +215,7 @@ const tours = {
194
215
} ,
195
216
{
196
217
name :'CopyAPIToken' ,
197
- content :( Step ) => (
218
+ content :( Step , { dispatch } ) => (
198
219
< Step . Root side = "bottom" align = "start" sideOffset = { - 5 } >
199
220
< Step . Title
200
221
id = "tours.apiTokens.CopyAPIToken.title"
@@ -204,41 +225,28 @@ const tours = {
204
225
id = "tours.apiTokens.CopyAPIToken.content"
205
226
defaultMessage = "Make sure to do it now, you won’t be able to see it again. You’ll need to generate a new one if you lose it."
206
227
/>
207
- < Step . Actions />
228
+ < Step . Actions >
229
+ < GotItAction onClick = { ( ) => dispatch ( { type :'next_step' , payload :'apiTokens' } ) } />
230
+ </ Step . Actions >
208
231
</ Step . Root >
209
232
) ,
210
233
when :( completedActions ) => completedActions . includes ( 'didCreateApiToken' ) ,
211
234
} ,
212
235
{
213
236
name :'Finish' ,
214
- content :( Step ) => {
215
- const dispatch = unstableUseGuidedTour ( 'GuidedTourPopover' , ( s ) => s . dispatch ) ;
216
- return (
217
- < Step . Root side = "right" align = "start" >
218
- < Step . Title
219
- id = "tours.apiTokens.FinalStep.title"
220
- defaultMessage = "It’s time to deploy your application!"
221
- />
222
- < Step . Content
223
- id = "tours.apiTokens.FinalStep.content"
224
- defaultMessage = "Your application is ready to be deployed and its content to be shared with the world!"
225
- />
226
- < Step . Actions showStepCount = { false } >
227
- < Flex justifyContent = "end" width = { '100%' } >
228
- < LinkButton
229
- onClick = { ( ) => {
230
- dispatch ( { type :'next_step' , payload :'apiTokens' } ) ;
231
- } }
232
- tag = { NavLink }
233
- to = "/"
234
- >
235
- < FormattedMessage id = "tours.gotIt" defaultMessage = "Got it" />
236
- </ LinkButton >
237
- </ Flex >
238
- </ Step . Actions >
239
- </ Step . Root >
240
- ) ;
241
- } ,
237
+ content :( Step ) => (
238
+ < Step . Root side = "right" align = "start" >
239
+ < Step . Title
240
+ id = "tours.apiTokens.FinalStep.title"
241
+ defaultMessage = "It’s time to deploy your application!"
242
+ />
243
+ < Step . Content
244
+ id = "tours.apiTokens.FinalStep.content"
245
+ defaultMessage = "Your application is ready to be deployed and its content to be shared with the world!"
246
+ />
247
+ < Step . Actions showStepCount = { false } to = "/" />
248
+ </ Step . Root >
249
+ ) ,
242
250
when :( completedActions ) => completedActions . includes ( 'didCopyApiToken' ) ,
243
251
} ,
244
252
] ) ,