Skip to content

Commit 9353efc

Browse files
committed
fix: follower page
1 parent f98b378 commit 9353efc

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

src/components/TabletNameWrapper/TabletNameWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface TabletNameWrapperProps {
1818
export function TabletNameWrapper({tabletId, followerId, database}: TabletNameWrapperProps) {
1919
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
2020

21-
const tabletPath = getTabletPagePath(tabletId, {database});
21+
const tabletPath = getTabletPagePath(tabletId, {database, followerId: followerId?.toString()});
2222
const tabletName = `${tabletId}${followerId ? `.${followerId}` : ''}`;
2323

2424
return (

src/containers/Tablet/Tablet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ export function Tablet() {
6363

6464
const {id} = useParams<{id: string}>();
6565

66-
const [{database: queryDatabase, clusterName: queryClusterName}] =
66+
const [{database: queryDatabase, clusterName: queryClusterName, followerId: queryFollowerId}] =
6767
useQueryParams(tabletPageQueryParams);
6868

6969
const [autoRefreshInterval] = useAutoRefreshInterval();
7070
const {currentData, isFetching, error} = tabletApi.useGetTabletQuery(
71-
{id, database: queryDatabase ?? undefined},
71+
{id, database: queryDatabase ?? undefined, followerId: queryFollowerId ?? undefined},
7272
{pollingInterval: autoRefreshInterval},
7373
);
7474

src/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export const tabletPageQueryParams = {
124124
database: StringParam,
125125
clusterName: StringParam,
126126
activeTab: StringParam,
127+
followerId: StringParam,
127128
} as const;
128129

129130
type TabletPageQuery = QueryParamsTypeFromQueryObject<typeof tabletPageQueryParams>;

src/store/reducers/tablet.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ export const tabletApi = api.injectEndpoints({
88
endpoints: (build) => ({
99
getTablet: build.query({
1010
queryFn: async (
11-
{id, database}: {id: string; database?: string; nodeId?: string},
11+
{
12+
id,
13+
database,
14+
followerId,
15+
}: {id: string; database?: string; nodeId?: string; followerId?: string},
1216
{signal},
1317
) => {
1418
try {
@@ -50,7 +54,11 @@ export const tabletApi = api.injectEndpoints({
5054
}, []);
5155

5256
const {TabletStateInfo = []} = tabletResponseData;
53-
const [tabletData = {}] = TabletStateInfo;
57+
const tabletData =
58+
TabletStateInfo.find((t) => t.FollowerId?.toString() === followerId) ||
59+
TabletStateInfo.find((t) => t.Leader) ||
60+
TabletStateInfo[0] ||
61+
{};
5462
const {TabletId} = tabletData;
5563

5664
return {data: {id: TabletId, data: tabletData, history: historyData}};

0 commit comments

Comments
 (0)