♻️(frontend) generalize recording availability hook for all types
Extend recording availability and access hook to work with all recording types instead of being transcript-specific. Create flexible implementation that determines availability and permissions for screen recordings and future recording formats.
This commit is contained in:
committed by
aleb_the_flash
parent
9734df9d5d
commit
a22d052f46
@@ -6,8 +6,9 @@ import { CRISP_HELP_ARTICLE_MORE_TOOLS } from '@/utils/constants'
|
|||||||
import { ReactNode } from 'react'
|
import { ReactNode } from 'react'
|
||||||
import { Transcript } from './Transcript'
|
import { Transcript } from './Transcript'
|
||||||
import { RiFileTextFill } from '@remixicon/react'
|
import { RiFileTextFill } from '@remixicon/react'
|
||||||
import { useIsTranscriptEnabled } from '../hooks/useIsTranscriptEnabled'
|
|
||||||
import { useSidePanel } from '../hooks/useSidePanel'
|
import { useSidePanel } from '../hooks/useSidePanel'
|
||||||
|
import { useIsRecordingModeEnabled } from '../hooks/useIsRecordingModeEnabled'
|
||||||
|
import { RecordingMode } from '@/features/rooms/api/startRecording'
|
||||||
|
|
||||||
export interface ToolsButtonProps {
|
export interface ToolsButtonProps {
|
||||||
icon: ReactNode
|
icon: ReactNode
|
||||||
@@ -70,7 +71,9 @@ const ToolButton = ({
|
|||||||
export const Tools = () => {
|
export const Tools = () => {
|
||||||
const { openTranscript, isTranscriptOpen } = useSidePanel()
|
const { openTranscript, isTranscriptOpen } = useSidePanel()
|
||||||
const { t } = useTranslation('rooms', { keyPrefix: 'moreTools' })
|
const { t } = useTranslation('rooms', { keyPrefix: 'moreTools' })
|
||||||
const isTranscriptEnabled = useIsTranscriptEnabled()
|
const isTranscriptEnabled = useIsRecordingModeEnabled(
|
||||||
|
RecordingMode.Transcript
|
||||||
|
)
|
||||||
|
|
||||||
if (isTranscriptOpen && isTranscriptEnabled) {
|
if (isTranscriptOpen && isTranscriptEnabled) {
|
||||||
return <Transcript />
|
return <Transcript />
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { NotificationPayload } from '@/features/notifications/NotificationPayloa
|
|||||||
import { NotificationType } from '@/features/notifications/NotificationType'
|
import { NotificationType } from '@/features/notifications/NotificationType'
|
||||||
import { useSnapshot } from 'valtio/index'
|
import { useSnapshot } from 'valtio/index'
|
||||||
import { RecordingStatus, recordingStore } from '@/stores/recording'
|
import { RecordingStatus, recordingStore } from '@/stores/recording'
|
||||||
import { useHasTranscriptAccess } from '../hooks/useHasTranscriptAccess'
|
import { useHasRecordingAccess } from '../hooks/useHasScreenRecordingAccess'
|
||||||
import {
|
import {
|
||||||
BETA_USERS_FORM_URL,
|
BETA_USERS_FORM_URL,
|
||||||
CRISP_HELP_ARTICLE_TRANSCRIPT,
|
CRISP_HELP_ARTICLE_TRANSCRIPT,
|
||||||
@@ -26,7 +26,10 @@ export const Transcript = () => {
|
|||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const { t } = useTranslation('rooms', { keyPrefix: 'transcript' })
|
const { t } = useTranslation('rooms', { keyPrefix: 'transcript' })
|
||||||
|
|
||||||
const hasTranscriptAccess = useHasTranscriptAccess()
|
const hasTranscriptAccess = useHasRecordingAccess(
|
||||||
|
RecordingMode.Transcript,
|
||||||
|
'transcription-summary'
|
||||||
|
)
|
||||||
const roomId = useRoomId()
|
const roomId = useRoomId()
|
||||||
|
|
||||||
const { mutateAsync: startRecordingRoom } = useStartRecording()
|
const { mutateAsync: startRecordingRoom } = useStartRecording()
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
import { useFeatureFlagEnabled } from 'posthog-js/react'
|
import { useFeatureFlagEnabled } from 'posthog-js/react'
|
||||||
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
|
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
|
||||||
import { useIsTranscriptEnabled } from './useIsTranscriptEnabled'
|
import { RecordingMode } from '@/features/rooms/api/startRecording'
|
||||||
|
import { useIsRecordingModeEnabled } from './useIsRecordingModeEnabled'
|
||||||
import { useIsAdminOrOwner } from './useIsAdminOrOwner'
|
import { useIsAdminOrOwner } from './useIsAdminOrOwner'
|
||||||
|
|
||||||
export const useHasTranscriptAccess = () => {
|
export const useHasRecordingAccess = (
|
||||||
const featureEnabled = useFeatureFlagEnabled('transcription-summary')
|
mode: RecordingMode,
|
||||||
|
featureFlag: string
|
||||||
|
) => {
|
||||||
|
const featureEnabled = useFeatureFlagEnabled(featureFlag)
|
||||||
const isAnalyticsEnabled = useIsAnalyticsEnabled()
|
const isAnalyticsEnabled = useIsAnalyticsEnabled()
|
||||||
const isTranscriptEnabled = useIsTranscriptEnabled()
|
const isRecordingModeEnabled = useIsRecordingModeEnabled(mode)
|
||||||
const isAdminOrOwner = useIsAdminOrOwner()
|
const isAdminOrOwner = useIsAdminOrOwner()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
(featureEnabled || !isAnalyticsEnabled) &&
|
(featureEnabled || !isAnalyticsEnabled) &&
|
||||||
isAdminOrOwner &&
|
isAdminOrOwner &&
|
||||||
isTranscriptEnabled
|
isRecordingModeEnabled
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { RecordingMode } from '@/features/rooms/api/startRecording'
|
import { RecordingMode } from '@/features/rooms/api/startRecording'
|
||||||
import { useConfig } from '@/api/useConfig'
|
import { useConfig } from '@/api/useConfig'
|
||||||
|
|
||||||
export const useIsTranscriptEnabled = () => {
|
export const useIsRecordingModeEnabled = (mode: RecordingMode) => {
|
||||||
const { data } = useConfig()
|
const { data } = useConfig()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
data?.recording?.is_enabled &&
|
data?.recording?.is_enabled &&
|
||||||
data?.recording?.available_modes?.includes(RecordingMode.Transcript)
|
data?.recording?.available_modes?.includes(mode)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user