import { useState } from 'react'; import { Trans, t } from '@grafana/i18n'; import { CellProps, Column, FilterInput, InteractiveTable, LinkButton, Spinner, Stack } from '@grafana/ui'; import { Repository, useGetRepositoryFilesQuery } from 'app/api/clients/provisioning/v0alpha1'; import { PROVISIONING_URL } from '../constants'; import { FileDetails } from '../types'; interface FilesViewProps { repo: Repository; } type FileCell = CellProps; export function FilesView({ repo }: FilesViewProps) { const name = repo.metadata?.name ?? ''; const query = useGetRepositoryFilesQuery({ name }); const [searchQuery, setSearchQuery] = useState(''); const data = [...(query.data?.items ?? [])].filter((file) => file.path.toLowerCase().includes(searchQuery.toLowerCase()) ); const columns: Array> = [ { id: 'path', header: 'Path', sortType: 'string', cell: ({ row: { original } }: FileCell<'path'>) => { const { path } = original; return {path}; }, }, { id: 'size', header: 'Size (KB)', cell: ({ row: { original } }: FileCell<'size'>) => { const { size } = original; return (parseInt(size, 10) / 1024).toFixed(2); }, sortType: 'number', }, { id: 'hash', header: 'Hash', sortType: 'string', }, { id: 'actions', header: '', cell: ({ row: { original } }: FileCell<'path'>) => { const { path } = original; return ( {(path.endsWith('.json') || path.endsWith('.yaml') || path.endsWith('.yml')) && ( View )} History ); }, }, ]; if (query.isLoading) { return ( ); } return ( String(f.path)} /> ); }