diff --git a/packages/grafana-ui/src/components/Pagination/Pagination.tsx b/packages/grafana-ui/src/components/Pagination/Pagination.tsx
index 57afc826b93..4ac6c009f83 100644
--- a/packages/grafana-ui/src/components/Pagination/Pagination.tsx
+++ b/packages/grafana-ui/src/components/Pagination/Pagination.tsx
@@ -19,6 +19,8 @@ export interface Props {
/** Small version only shows the current page and the navigation buttons. */
showSmallVersion?: boolean;
className?: string;
+ /** If we are using cursor based pagination, disable next page button when we have no cursor */
+ hasNextPage?: boolean;
}
/**
@@ -33,6 +35,7 @@ export const Pagination = ({
hideWhenSinglePage,
showSmallVersion,
className,
+ hasNextPage,
}: Props) => {
const styles = useStyles2(getStyles);
const pageLengthToCondense = showSmallVersion ? 1 : 8;
@@ -122,13 +125,14 @@ export const Pagination = ({
{pageButtons}
+ {pageButtons.length === 0 &&
{currentPage}}
diff --git a/public/app/features/correlations/CorrelationsPage.tsx b/public/app/features/correlations/CorrelationsPage.tsx
index a8ae0739c66..6058b843edd 100644
--- a/public/app/features/correlations/CorrelationsPage.tsx
+++ b/public/app/features/correlations/CorrelationsPage.tsx
@@ -42,6 +42,7 @@ type CorrelationsPageProps = {
| Status
>;
error?: Error;
+ hasNextPage?: boolean;
};
const collator = new Intl.Collator();
@@ -57,7 +58,7 @@ const loaderWrapper = css({
});
export default function CorrelationsPage(props: CorrelationsPageProps) {
- const { fetchCorrelations, correlations, isLoading, error, removeFn, changePageFn } = props;
+ const { fetchCorrelations, correlations, isLoading, error, removeFn, changePageFn, hasNextPage } = props;
const navModel = useNavModel('correlations');
const [isAdding, setIsAddingValue] = useState(false);
const page = useRef(1);
@@ -157,6 +158,7 @@ export default function CorrelationsPage(props: CorrelationsPageProps) {
[RowActions, canWriteCorrelations]
);
+ console.log(correlations?.totalCount, correlations?.limit);
const corrData = correlations?.correlations ?? [];
const showEmptyListCTA = corrData.length === 0 && !isAdding && !error;
const addButton = canWriteCorrelations && corrData.length !== 0 && !isAdding && (
@@ -231,6 +233,7 @@ export default function CorrelationsPage(props: CorrelationsPageProps) {
}
fetchCorrelations({ page: (page.current = toPage) });
}}
+ hasNextPage={hasNextPage}
/>
>
)}
diff --git a/public/app/features/correlations/CorrelationsPageWrapper.tsx b/public/app/features/correlations/CorrelationsPageWrapper.tsx
index 2814bc5a9a5..a06c3609fc7 100644
--- a/public/app/features/correlations/CorrelationsPageWrapper.tsx
+++ b/public/app/features/correlations/CorrelationsPageWrapper.tsx
@@ -24,8 +24,8 @@ export function CorrelationsPageLegacy() {
function CorrelationsPageAppPlatform() {
const [page, setPage] = useState(1);
let totalItems = useRef(0);
- const limit = 100;
- const { currentData, isLoading, error, remainingItems } = useCorrelationsK8s(limit, page);
+ const limit = 10;
+ const { currentData, isLoading, error, remainingItems, doesContinue } = useCorrelationsK8s(limit, page);
const [deleteCorrelation] = useDeleteCorrelationMutation();
if (page === 1) {
totalItems.current = remainingItems;
@@ -54,6 +54,7 @@ function CorrelationsPageAppPlatform() {
const deleteData = deleteCorrelation({ name: params.uid });
return deleteData.unwrap();
}}
+ hasNextPage={doesContinue}
/>
);
}
diff --git a/public/app/features/correlations/useCorrelationsK8s.ts b/public/app/features/correlations/useCorrelationsK8s.ts
index e74ed19ad7f..a6e9d2c8df5 100644
--- a/public/app/features/correlations/useCorrelationsK8s.ts
+++ b/public/app/features/correlations/useCorrelationsK8s.ts
@@ -23,7 +23,7 @@ export const toEnrichedCorrelationDataK8s = (item: CorrelationK8s): CorrelationD
config: {
field: item.spec.config.field,
target: {
- url: item.spec.config.target.url || '',
+ url: item.spec.config?.target?.url || '',
},
transformations: [], // todo fix
},
@@ -73,5 +73,6 @@ export const useCorrelationsK8s = (limit = 100, page: number) => {
isLoading,
error: fmtedError,
remainingItems: currentData?.metadata.remainingItemCount || 0,
+ doesContinue: currentData?.metadata.continue !== undefined,
};
};