mirror of
https://github.com/supabase/supabase.git
synced 2026-10-18 23:59:08 +03:00
* Add the new realtime js library under an alias. * Add a isChannelPrivate property to realtime config. * Use the aliased realtime-js library to connect to the realtime server. * Add a new switch to enable users to connect to a private channel. * Hide the public/private switch behind a feature flag. * Fix an import. * Add description to the switch. * Small updates, add documentation button in choose channel popover --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
import { useParams, useTelemetryProps } from 'common'
|
|
import { useRouter } from 'next/router'
|
|
import { useState } from 'react'
|
|
|
|
import Telemetry from 'lib/telemetry'
|
|
import { Header } from './Header'
|
|
import MessagesTable from './MessagesTable'
|
|
import { SendMessageModal } from './SendMessageModal'
|
|
import { RealtimeConfig, useRealtimeMessages } from './useRealtimeMessages'
|
|
|
|
/**
|
|
* Acts as a container component for the entire log display
|
|
*/
|
|
export const RealtimeInspector = () => {
|
|
const { ref } = useParams()
|
|
const telemetryProps = useTelemetryProps()
|
|
const router = useRouter()
|
|
const [sendMessageShown, setSendMessageShown] = useState(false)
|
|
|
|
const [realtimeConfig, setRealtimeConfig] = useState<RealtimeConfig>({
|
|
enabled: false,
|
|
projectRef: ref!,
|
|
channelName: '',
|
|
logLevel: 'info',
|
|
token: '', // will be filled out by RealtimeTokensPopover
|
|
schema: 'public',
|
|
table: '*',
|
|
isChannelPrivate: false,
|
|
filter: undefined,
|
|
bearer: null,
|
|
enablePresence: true,
|
|
enableDbChanges: true,
|
|
enableBroadcast: true,
|
|
})
|
|
|
|
const { logData, sendMessage } = useRealtimeMessages(realtimeConfig, setRealtimeConfig)
|
|
|
|
return (
|
|
<div className="flex flex-col grow h-full">
|
|
<Header config={realtimeConfig} onChangeConfig={setRealtimeConfig} />
|
|
<div className="relative flex flex-col grow">
|
|
<div className="flex grow">
|
|
<MessagesTable
|
|
hasChannelSet={realtimeConfig.channelName.length > 0}
|
|
enabled={realtimeConfig.enabled}
|
|
data={logData}
|
|
showSendMessage={() => setSendMessageShown(true)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<SendMessageModal
|
|
visible={sendMessageShown}
|
|
onSelectCancel={() => setSendMessageShown(false)}
|
|
onSelectConfirm={(v) => {
|
|
Telemetry.sendEvent(
|
|
{
|
|
category: 'realtime_inspector',
|
|
action: 'send_broadcast_message',
|
|
label: 'realtime_inspector_results',
|
|
},
|
|
telemetryProps,
|
|
router
|
|
)
|
|
sendMessage(v.message, v.payload, () => setSendMessageShown(false))
|
|
}}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|