mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 20:59:35 +08:00
[Remote Provisioning] Remove resource and file delete buttons (#102767)
* Remove delete file button in files tab * Remove delete resource button in resources tab
This commit is contained in:

committed by
GitHub

parent
75ce8db0e2
commit
8dab99e1d4
@ -1,21 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
import {
|
||||
Button,
|
||||
CellProps,
|
||||
Column,
|
||||
ConfirmModal,
|
||||
FilterInput,
|
||||
InteractiveTable,
|
||||
LinkButton,
|
||||
Spinner,
|
||||
Stack,
|
||||
} from '@grafana/ui';
|
||||
import {
|
||||
Repository,
|
||||
useGetRepositoryFilesQuery,
|
||||
useDeleteRepositoryFilesWithPathMutation,
|
||||
} from 'app/api/clients/provisioning';
|
||||
import { CellProps, Column, FilterInput, InteractiveTable, LinkButton, Spinner, Stack } from '@grafana/ui';
|
||||
import { Repository, useGetRepositoryFilesQuery } from 'app/api/clients/provisioning';
|
||||
|
||||
import { PROVISIONING_URL } from '../constants';
|
||||
import { FileDetails } from '../types';
|
||||
@ -29,10 +15,7 @@ type FileCell<T extends keyof FileDetails = keyof FileDetails> = CellProps<FileD
|
||||
export function FilesView({ repo }: FilesViewProps) {
|
||||
const name = repo.metadata?.name ?? '';
|
||||
const query = useGetRepositoryFilesQuery({ name });
|
||||
const [deleteFile, deleteFileStatus] = useDeleteRepositoryFilesWithPathMutation();
|
||||
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [pathToDelete, setPathToDelete] = useState<string>();
|
||||
const data = [...(query.data?.items ?? [])].filter((file) =>
|
||||
file.path.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
);
|
||||
@ -72,9 +55,6 @@ export function FilesView({ repo }: FilesViewProps) {
|
||||
<LinkButton href={`${PROVISIONING_URL}/${name}/file/${path}`}>View</LinkButton>
|
||||
)}
|
||||
<LinkButton href={`${PROVISIONING_URL}/${name}/history/${path}`}>History</LinkButton>
|
||||
<Button variant="destructive" onClick={() => setPathToDelete(path)}>
|
||||
Delete
|
||||
</Button>
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
@ -91,22 +71,6 @@ export function FilesView({ repo }: FilesViewProps) {
|
||||
|
||||
return (
|
||||
<Stack grow={1} direction={'column'} gap={2}>
|
||||
<ConfirmModal
|
||||
isOpen={Boolean(pathToDelete?.length) || deleteFileStatus.isLoading}
|
||||
title="Delete file in repository?"
|
||||
body={deleteFileStatus.isLoading ? 'Deleting file...' : pathToDelete}
|
||||
confirmText="Delete"
|
||||
icon={deleteFileStatus.isLoading ? `spinner` : `exclamation-triangle`}
|
||||
onConfirm={() => {
|
||||
deleteFile({
|
||||
name: name,
|
||||
path: pathToDelete!,
|
||||
message: `Deleted from repo test UI`,
|
||||
});
|
||||
setPathToDelete('');
|
||||
}}
|
||||
onDismiss={() => setPathToDelete('')}
|
||||
/>
|
||||
<Stack gap={2}>
|
||||
<FilterInput placeholder="Search" autoFocus={true} value={searchQuery} onChange={setSearchQuery} />
|
||||
</Stack>
|
||||
|
@ -1,23 +1,7 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
|
||||
import {
|
||||
Column,
|
||||
CellProps,
|
||||
Link,
|
||||
Stack,
|
||||
Spinner,
|
||||
FilterInput,
|
||||
InteractiveTable,
|
||||
LinkButton,
|
||||
ConfirmModal,
|
||||
Button,
|
||||
} from '@grafana/ui';
|
||||
import {
|
||||
Repository,
|
||||
ResourceListItem,
|
||||
useGetRepositoryResourcesQuery,
|
||||
useDeleteRepositoryFilesWithPathMutation,
|
||||
} from 'app/api/clients/provisioning';
|
||||
import { CellProps, Column, FilterInput, InteractiveTable, Link, LinkButton, Spinner, Stack } from '@grafana/ui';
|
||||
import { Repository, ResourceListItem, useGetRepositoryResourcesQuery } from 'app/api/clients/provisioning';
|
||||
|
||||
import { PROVISIONING_URL } from '../constants';
|
||||
|
||||
@ -34,8 +18,6 @@ export function RepositoryResources({ repo }: RepoProps) {
|
||||
const name = repo.metadata?.name ?? '';
|
||||
const query = useGetRepositoryResourcesQuery({ name });
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
const [deleteFile, deleteFileStatus] = useDeleteRepositoryFilesWithPathMutation();
|
||||
const [pathToDelete, setPathToDelete] = useState<string>();
|
||||
const data = (query.data?.items ?? []).filter((Resource) =>
|
||||
Resource.path.toLowerCase().includes(searchQuery.toLowerCase())
|
||||
);
|
||||
@ -107,9 +89,6 @@ export function RepositoryResources({ repo }: RepoProps) {
|
||||
{resource === 'dashboards' && <LinkButton href={`/d/${name}`}>View</LinkButton>}
|
||||
{resource === 'folders' && <LinkButton href={`/dashboards/f/${name}`}>View</LinkButton>}
|
||||
<LinkButton href={`${PROVISIONING_URL}/${repo.metadata?.name}/history/${path}`}>History</LinkButton>
|
||||
<Button variant="destructive" onClick={() => setPathToDelete(path)}>
|
||||
Delete
|
||||
</Button>
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
@ -128,24 +107,6 @@ export function RepositoryResources({ repo }: RepoProps) {
|
||||
|
||||
return (
|
||||
<Stack grow={1} direction={'column'} gap={2}>
|
||||
<ConfirmModal
|
||||
isOpen={Boolean(pathToDelete?.length) || deleteFileStatus.isLoading}
|
||||
title="Delete resource in repository?"
|
||||
body={deleteFileStatus.isLoading ? 'Deleting resource...' : pathToDelete}
|
||||
confirmText="Delete"
|
||||
icon={deleteFileStatus.isLoading ? `spinner` : `exclamation-triangle`}
|
||||
onConfirm={() => {
|
||||
if (pathToDelete) {
|
||||
deleteFile({
|
||||
name: name,
|
||||
path: pathToDelete,
|
||||
message: `Deleted from repo test UI`,
|
||||
});
|
||||
setPathToDelete('');
|
||||
}
|
||||
}}
|
||||
onDismiss={() => setPathToDelete('')}
|
||||
/>
|
||||
<Stack gap={2}>
|
||||
<FilterInput placeholder="Search" autoFocus={true} value={searchQuery} onChange={setSearchQuery} />
|
||||
</Stack>
|
||||
|
Reference in New Issue
Block a user