diff --git a/packages/components/src/components/DataTableSkeleton/DataTableSkeleton.jsx b/packages/components/src/components/DataTableSkeleton/DataTableSkeleton.jsx
new file mode 100644
index 000000000..1d02f5176
--- /dev/null
+++ b/packages/components/src/components/DataTableSkeleton/DataTableSkeleton.jsx
@@ -0,0 +1,97 @@
+/*
+Copyright 2024 The Tekton Authors
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+import { usePrefix } from '@carbon/react';
+import { classNames } from '@tektoncd/dashboard-utils';
+
+export default function DataTableSkeleton({
+ filters,
+ headers,
+ rowCount = 5,
+ columnCount = 5,
+ compact = false,
+ className,
+ showDescription,
+ showHeader = true,
+ showToolbar = true,
+ size,
+ ...rest
+}) {
+ const prefix = usePrefix();
+
+ const dataTableSkeletonClasses = classNames(className, {
+ [`${prefix}--skeleton`]: true,
+ [`${prefix}--data-table`]: true,
+ [`${prefix}--data-table--compact`]: compact,
+ [`${prefix}--data-table--${size}`]: true
+ });
+
+ const rows = Array(rowCount);
+ const columnsArray = Array.from({ length: columnCount }, (_, index) => index);
+ for (let i = 0; i < rowCount; i += 1) {
+ rows[i] = (
+
+ {columnsArray.map(j => (
+
+
+ |
+ ))}
+
+ );
+ }
+
+ return (
+
+ {showHeader ? (
+
+
+ {showDescription && (
+
+ )}
+
+ ) : null}
+ {showToolbar ? (
+
+
+ {filters || (
+
+ )}
+
+
+ ) : null}
+
+
+
+ {columnsArray.map(i => (
+
+ {headers ? (
+
+ {headers[i]?.header}
+
+ ) : (
+
+ )}
+ |
+ ))}
+
+
+ {rows}
+
+
+ );
+}
diff --git a/packages/components/src/components/DataTableSkeleton/index.js b/packages/components/src/components/DataTableSkeleton/index.js
new file mode 100644
index 000000000..e6964f5fc
--- /dev/null
+++ b/packages/components/src/components/DataTableSkeleton/index.js
@@ -0,0 +1,15 @@
+/*
+Copyright 2024 The Tekton Authors
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+/* istanbul ignore file */
+
+export { default } from './DataTableSkeleton';
diff --git a/packages/components/src/components/Table/Table.jsx b/packages/components/src/components/Table/Table.jsx
index ba692ba52..9ee21da76 100644
--- a/packages/components/src/components/Table/Table.jsx
+++ b/packages/components/src/components/Table/Table.jsx
@@ -16,17 +16,17 @@ import PropTypes from 'prop-types';
import {
Button,
DataTable,
- DataTableSkeleton,
TableBatchAction,
TableBatchActions,
TableSelectAll,
TableSelectRow,
TableToolbar,
- TableToolbarContent,
- usePrefix
+ TableToolbarContent
} from '@carbon/react';
import { ALL_NAMESPACES, classNames } from '@tektoncd/dashboard-utils';
+import DataTableSkeleton from '../DataTableSkeleton';
+
const {
TableContainer,
Table: CarbonTable,
@@ -138,7 +138,6 @@ const Table = ({
title = null,
toolbarButtons = defaults.toolbarButtons
}) => {
- const carbonPrefix = usePrefix();
const intl = useIntl();
const shouldRenderBatchActions = !!(
dataRows.length && batchActionButtons.length
@@ -157,20 +156,12 @@ const Table = ({
});
if (loading) {
- const tableSizeClassNames = {
- xs: `${carbonPrefix}--data-table--xs`,
- sm: `${carbonPrefix}--data-table--sm`,
- md: `${carbonPrefix}--data-table--md`,
- lg: `${carbonPrefix}--data-table--lg`,
- xl: `${carbonPrefix}--data-table--xl`
- };
-
return (