mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-07 03:06:40 +00:00
refresh button
This commit is contained in:
@@ -8,12 +8,16 @@ interface DataTableProps<TData, TValue> {
|
|||||||
columns: ColumnDef<TData, TValue>[];
|
columns: ColumnDef<TData, TValue>[];
|
||||||
data: TData[];
|
data: TData[];
|
||||||
addApiKey?: () => void;
|
addApiKey?: () => void;
|
||||||
|
onRefresh?: () => void;
|
||||||
|
isRefreshing?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function OrgApiKeysDataTable<TData, TValue>({
|
export function OrgApiKeysDataTable<TData, TValue>({
|
||||||
addApiKey,
|
addApiKey,
|
||||||
columns,
|
columns,
|
||||||
data
|
data,
|
||||||
|
onRefresh,
|
||||||
|
isRefreshing
|
||||||
}: DataTableProps<TData, TValue>) {
|
}: DataTableProps<TData, TValue>) {
|
||||||
|
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
@@ -27,6 +31,8 @@ export function OrgApiKeysDataTable<TData, TValue>({
|
|||||||
searchPlaceholder={t('searchApiKeys')}
|
searchPlaceholder={t('searchApiKeys')}
|
||||||
searchColumn="name"
|
searchColumn="name"
|
||||||
onAdd={addApiKey}
|
onAdd={addApiKey}
|
||||||
|
onRefresh={onRefresh}
|
||||||
|
isRefreshing={isRefreshing}
|
||||||
addButtonText={t('apiKeysAdd')}
|
addButtonText={t('apiKeysAdd')}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -46,6 +46,24 @@ export default function OrgApiKeysTable({
|
|||||||
const api = createApiClient(useEnvContext());
|
const api = createApiClient(useEnvContext());
|
||||||
|
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||||
|
|
||||||
|
const refreshData = async () => {
|
||||||
|
console.log("Data refreshed");
|
||||||
|
setIsRefreshing(true);
|
||||||
|
try {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||||
|
router.refresh();
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: t("error"),
|
||||||
|
description: t("refreshError"),
|
||||||
|
variant: "destructive"
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setIsRefreshing(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const deleteSite = (apiKeyId: string) => {
|
const deleteSite = (apiKeyId: string) => {
|
||||||
api.delete(`/org/${orgId}/api-key/${apiKeyId}`)
|
api.delete(`/org/${orgId}/api-key/${apiKeyId}`)
|
||||||
@@ -195,6 +213,8 @@ export default function OrgApiKeysTable({
|
|||||||
addApiKey={() => {
|
addApiKey={() => {
|
||||||
router.push(`/${orgId}/settings/api-keys/create`);
|
router.push(`/${orgId}/settings/api-keys/create`);
|
||||||
}}
|
}}
|
||||||
|
onRefresh={refreshData}
|
||||||
|
isRefreshing={isRefreshing}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user