@@ -4,18 +4,20 @@ import classNames from "classnames";
4
4
import { useRouter } from "next/router" ;
5
5
import { ClipboardEvent , KeyboardEvent , useLayoutEffect , useRef , useState } from "react" ;
6
6
7
+ import Icon , { IconType } from "replay-next/components/Icon" ;
8
+ import { useNag } from "replay-next/src/hooks/useNag" ;
7
9
import { RecordingTarget } from "replay-next/src/suspense/BuildIdCache" ;
8
- import { Recording } from "shared/graphql/types" ;
10
+ import { Nag , Recording } from "shared/graphql/types" ;
9
11
import { selectAll } from "shared/utils/selection" ;
10
- import { getAccessToken , getRecordingTarget } from "ui/actions/app" ;
12
+ import { getAccessToken , getRecordingTarget , setModal } from "ui/actions/app" ;
11
13
import Avatar from "ui/components/Avatar" ;
12
14
import UserOptions from "ui/components/Header/UserOptions" ;
13
15
import ViewToggle , { shouldShowDevToolsNag } from "ui/components/Header/ViewToggle" ;
14
16
import IconWithTooltip from "ui/components/shared/IconWithTooltip" ;
15
17
import hooks from "ui/hooks" ;
16
18
import { useGetActiveSessions } from "ui/hooks/sessions" ;
17
19
import { getViewMode } from "ui/reducers/layout" ;
18
- import { useAppSelector } from "ui/setup/hooks" ;
20
+ import { useAppDispatch , useAppSelector } from "ui/setup/hooks" ;
19
21
import { trackEvent } from "ui/utils/telemetry" ;
20
22
21
23
import { isTestSuiteReplay } from "../TestSuite/utils/isTestSuiteReplay" ;
@@ -169,9 +171,13 @@ export default function Header() {
169
171
const recordingTarget = useAppSelector ( getRecordingTarget ) ;
170
172
const isAuthenticated = ! ! useAppSelector ( getAccessToken ) ;
171
173
const recordingId = hooks . useGetRecordingId ( ) ;
172
- const { recording , loading } = hooks . useGetRecording ( recordingId ) ;
174
+ const { loading , recording } = hooks . useGetRecording ( recordingId ) ;
173
175
const backIcon = < div className = { classNames ( styles . BackButton , "img" , "arrowhead-right" ) } /> ;
174
176
177
+ const dispatch = useAppDispatch ( ) ;
178
+
179
+ const [ , dismissShareNag ] = useNag ( Nag . SHARE ) ; // Properly call useNag and destructure dismissShareNag
180
+
175
181
if ( loading ) {
176
182
return < div className = { styles . Header } > </ div > ;
177
183
}
@@ -197,6 +203,25 @@ export default function Header() {
197
203
}
198
204
}
199
205
206
+ let iconType : IconType ;
207
+ let visibilityLabel : string ;
208
+ if ( ! recording . private ) {
209
+ iconType = "visibility-public" ;
210
+ visibilityLabel = "Public" ;
211
+ } else if ( recording . workspace ) {
212
+ iconType = "visibility-team" ;
213
+ visibilityLabel = "Team" ;
214
+ } else {
215
+ iconType = "visibility-private" ;
216
+ visibilityLabel = "Private" ;
217
+ }
218
+
219
+ const onClick = ( ) => {
220
+ trackEvent ( "header.open_share" ) ;
221
+ dismissShareNag ( ) ;
222
+ dispatch ( setModal ( "sharing" , { recordingId : recordingId ! } ) ) ;
223
+ } ;
224
+
200
225
return (
201
226
< div className = { styles . Header } >
202
227
< div className = "relative flex flex-grow flex-row items-center overflow-hidden" >
@@ -210,6 +235,9 @@ export default function Header() {
210
235
) : (
211
236
< div className = { styles . ReadOnlyTitle } > Recordings</ div >
212
237
) }
238
+ < button className = { styles . VisibilityIconAndText } onClick = { onClick } >
239
+ < Icon className = { styles . VisibilityIcon } type = { iconType } /> { visibilityLabel }
240
+ </ button >
213
241
< div className = "flex-grow" > </ div >
214
242
</ div >
215
243
< Links recordingTarget = { recordingTarget } />
0 commit comments