[Remote Provisioning] Remove resource and file delete buttons (#102767)

* Remove delete file button in files tab

* Remove delete resource button in resources tab
pull/102783/head
Roberto Jiménez Sánchez 4 months ago committed by GitHub
parent 75ce8db0e2
commit 8dab99e1d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      .betterer.results
  2. 40
      public/app/features/provisioning/File/FilesView.tsx
  3. 43
      public/app/features/provisioning/Repository/RepositoryResources.tsx

@ -4740,10 +4740,8 @@ exports[`better eslint`] = {
],
"public/app/features/provisioning/File/FilesView.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "4"]
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"]
],
"public/app/features/provisioning/GettingStarted/EnhancedFeatures.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
@ -4844,11 +4842,9 @@ exports[`better eslint`] = {
],
"public/app/features/provisioning/Repository/RepositoryResources.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "1"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "2"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "4"],
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "5"]
[0, 0, 0, "No untranslated strings. Wrap text with <Trans />", "3"]
],
"public/app/features/provisioning/Repository/RepositoryStatusPage.tsx:5381": [
[0, 0, 0, "No untranslated strings in text props. Wrap text with <Trans /> or use t()", "0"],

@ -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>

Loading…
Cancel
Save