Skip to content

Commit d04aeee

Browse files
authored
Merge pull request #818 from RedisInsight/main
new rc
2 parents 7d330f3 + ce35f64 commit d04aeee

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

redisinsight/ui/src/pages/browser/components/stream-details/StreamDetailsWrapper.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ const StreamDetailsWrapper = (props: Props) => {
5757
&& !isNull(lastEntry)
5858
&& lastEntry.id !== ''
5959

60+
useEffect(() =>
61+
() => {
62+
dispatch(setStreamInitialState())
63+
}, [])
64+
6065
useEffect(() => {
6166
if (isNull(firstEntry)) {
6267
dispatch(updateStart(''))

redisinsight/ui/src/pages/pubSub/PubSubPage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
77
import InstanceHeader from 'uiSrc/components/instance-header'
88
import { SubscriptionType } from 'uiSrc/constants/pubSub'
99
import { sendPageViewTelemetry, TelemetryPageView } from 'uiSrc/telemetry'
10+
import { formatLongName, getDbIndex, setTitle } from 'uiSrc/utils'
1011

1112
import { MessagesListWrapper, PublishMessage, SubscriptionPanel } from './components'
1213

@@ -16,11 +17,14 @@ export const PUB_SUB_DEFAULT_CHANNEL = { channel: '*', type: SubscriptionType.PS
1617

1718
const PubSubPage = () => {
1819
const { identified: analyticsIdentified } = useSelector(appAnalyticsInfoSelector)
19-
const { name: connectedInstanceName } = useSelector(connectedInstanceSelector)
20+
const { name: connectedInstanceName, db } = useSelector(connectedInstanceSelector)
2021
const { instanceId } = useParams<{ instanceId: string }>()
2122

2223
const [isPageViewSent, setIsPageViewSent] = useState(false)
2324

25+
const dbName = `${formatLongName(connectedInstanceName, 33, 0, '...')} ${getDbIndex(db)}`
26+
setTitle(`${dbName} - Pub/Sub`)
27+
2428
useEffect(() => {
2529
if (connectedInstanceName && !isPageViewSent && analyticsIdentified) {
2630
sendPageView(instanceId)

redisinsight/ui/src/pages/slowLog/SlowLogPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
slowLogSelector
2929
} from 'uiSrc/slices/slowlog/slowlog'
3030
import { sendPageViewTelemetry, sendEventTelemetry, TelemetryEvent, TelemetryPageView } from 'uiSrc/telemetry'
31+
import { formatLongName, getDbIndex, setTitle } from 'uiSrc/utils'
3132
import { numberWithSpaces } from 'uiSrc/utils/numbers'
3233

3334
import { SlowLog } from 'apiSrc/modules/slow-log/models'
@@ -47,7 +48,7 @@ const countOptions: EuiSuperSelectOption<string>[] = [
4748
]
4849

4950
const SlowLogPage = () => {
50-
const { connectionType, name: connectedInstanceName } = useSelector(connectedInstanceSelector)
51+
const { connectionType, name: connectedInstanceName, db } = useSelector(connectedInstanceSelector)
5152
const { data, loading, durationUnit, config } = useSelector(slowLogSelector)
5253
const { slowlogLogSlowerThan = 0, slowlogMaxLen } = useSelector(slowLogConfigSelector)
5354
const { identified: analyticsIdentified } = useSelector(appAnalyticsInfoSelector)
@@ -59,6 +60,8 @@ const SlowLogPage = () => {
5960
const dispatch = useDispatch()
6061

6162
const lastTimestamp = minBy(data, 'time')?.time
63+
const dbName = `${formatLongName(connectedInstanceName, 33, 0, '...')} ${getDbIndex(db)}`
64+
setTitle(`${dbName} - Slow Log`)
6265

6366
useEffect(() => {
6467
getConfig()

redisinsight/ui/src/slices/browser/stream.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { SCAN_COUNT_DEFAULT } from 'uiSrc/constants/api'
77
import { ApiEndpoints, SortOrder } from 'uiSrc/constants'
88
import { refreshKeyInfoAction, } from 'uiSrc/slices/browser/keys'
99
import { getApiErrorMessage, getUrl, isStatusSuccessful, Maybe, Nullable } from 'uiSrc/utils'
10-
import { getStreamRangeStart, getStreamRangeEnd } from 'uiSrc/utils/streamUtils'
10+
import { getStreamRangeStart, getStreamRangeEnd, updateConsumerGroups, updateConsumers } from 'uiSrc/utils/streamUtils'
1111
import successMessages from 'uiSrc/components/notifications/success-messages'
1212
import {
1313
AddStreamEntriesDto,
@@ -214,6 +214,9 @@ const streamSlice = createSlice({
214214
loadConsumersSuccess: (state, { payload }: PayloadAction<ConsumerDto[]>) => {
215215
state.groups.loading = false
216216

217+
const groups = updateConsumerGroups(state.groups.data, state.groups.selectedGroup?.name, payload)
218+
219+
state.groups.data = groups
217220
state.groups.selectedGroup = {
218221
...state.groups.selectedGroup,
219222
lastRefreshTime: Date.now(),
@@ -244,8 +247,17 @@ const streamSlice = createSlice({
244247
loadConsumerMessagesSuccess: (state, { payload }: PayloadAction<PendingEntryDto[]>) => {
245248
state.groups.loading = false
246249

250+
const consumers = updateConsumers(
251+
state.groups.selectedGroup?.data,
252+
state.groups.selectedGroup?.selectedConsumer?.name,
253+
payload
254+
)
255+
const groups = updateConsumerGroups(state.groups.data, state.groups.selectedGroup?.name, consumers)
256+
257+
state.groups.data = groups
247258
state.groups.selectedGroup = {
248259
...state.groups.selectedGroup,
260+
data: consumers,
249261
selectedConsumer: {
250262
...state.groups.selectedGroup?.selectedConsumer,
251263
lastRefreshTime: Date.now(),

redisinsight/ui/src/utils/streamUtils.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { format } from 'date-fns'
22
import { orderBy } from 'lodash'
33
import { SortOrder } from 'uiSrc/constants'
44
import { SCAN_STREAM_START_DEFAULT, SCAN_STREAM_END_DEFAULT } from 'uiSrc/constants/api'
5-
import { ClaimPendingEntryDto, ConsumerDto } from 'apiSrc/modules/browser/dto/stream.dto'
5+
import { ClaimPendingEntryDto, ConsumerDto, ConsumerGroupDto, PendingEntryDto } from 'apiSrc/modules/browser/dto/stream.dto'
66

77
export enum ClaimTimeOptions {
88
RELATIVE = 'idle',
@@ -77,3 +77,20 @@ export const prepareDataForClaimRequest = (
7777
entries
7878
})
7979
}
80+
81+
export const updateConsumerGroups = (groups: ConsumerGroupDto[], groupName: string, consumers: ConsumerDto[]) =>
82+
groups?.map((group: ConsumerGroupDto) => {
83+
if (group.name === groupName) {
84+
group.consumers = consumers?.length
85+
group.pending = consumers?.reduce(((a, { pending }) => a + pending), 0)
86+
}
87+
return group
88+
})
89+
90+
export const updateConsumers = (consumers: ConsumerDto[], consumerName: string, messages: PendingEntryDto[]) =>
91+
consumers?.map((consumer: ConsumerDto) => {
92+
if (consumer.name === consumerName) {
93+
consumer.pending = messages?.length
94+
}
95+
return consumer
96+
})

0 commit comments

Comments
 (0)