Folders: Fix frontend permission check (#109290)
This commit is contained in:
@@ -17,10 +17,6 @@ export async function listFolders(
|
||||
page = 1,
|
||||
pageSize = PAGE_SIZE
|
||||
): Promise<DashboardViewItem[]> {
|
||||
if (parentUID) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const backendSrv = getBackendSrv();
|
||||
|
||||
// TODO: what to do here for unified search?
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { config, reportInteraction } from '@grafana/runtime';
|
||||
import { Button, Drawer, Stack, Tooltip } from '@grafana/ui';
|
||||
import { Button, Drawer, Stack } from '@grafana/ui';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { ManagerKind } from 'app/features/apiserver/types';
|
||||
import { useSearchStateManager } from 'app/features/search/state/SearchStateManager';
|
||||
@@ -42,9 +42,6 @@ export function BrowseActions({ folderDTO }: Props) {
|
||||
folderDTO?.managedBy === ManagerKind.Repo
|
||||
);
|
||||
|
||||
// Folders can only be moved if nested folders is enabled
|
||||
const moveIsInvalid = useMemo(() => Object.values(selectedItems.folder).some((v) => v), [selectedItems]);
|
||||
|
||||
const isSearching = stateManager.hasSearchFilters();
|
||||
|
||||
const onActionComplete = () => {
|
||||
@@ -125,7 +122,7 @@ export function BrowseActions({ folderDTO }: Props) {
|
||||
};
|
||||
|
||||
const moveButton = (
|
||||
<Button onClick={showMoveModal} variant="secondary" disabled={moveIsInvalid}>
|
||||
<Button onClick={showMoveModal} variant="secondary">
|
||||
<Trans i18nKey="browse-dashboards.action.move-button">Move</Trans>
|
||||
</Button>
|
||||
);
|
||||
@@ -133,13 +130,7 @@ export function BrowseActions({ folderDTO }: Props) {
|
||||
return (
|
||||
<>
|
||||
<Stack gap={1} data-testid="manage-actions">
|
||||
{moveIsInvalid ? (
|
||||
<Tooltip content={t('browse-dashboards.action.cannot-move-folders', 'Folders cannot be moved')}>
|
||||
{moveButton}
|
||||
</Tooltip>
|
||||
) : (
|
||||
moveButton
|
||||
)}
|
||||
{moveButton}
|
||||
|
||||
<Button onClick={showDeleteModal} variant="destructive">
|
||||
<Trans i18nKey="browse-dashboards.action.delete-button">Delete</Trans>
|
||||
|
||||
@@ -7,11 +7,6 @@ function checkFolderPermission(action: AccessControlAction, folderDTO?: FolderDT
|
||||
}
|
||||
|
||||
function checkCanCreateFolders(folderDTO?: FolderDTO) {
|
||||
// Can only create a folder if we have permissions and either we're at root
|
||||
if (folderDTO && folderDTO.uid !== 'general') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return checkFolderPermission(AccessControlAction.FoldersCreate, folderDTO);
|
||||
}
|
||||
|
||||
|
||||
@@ -3489,7 +3489,6 @@
|
||||
"bulk-delete-provisioned-resources": "Bulk Delete Provisioned Resources",
|
||||
"bulk-move-provisioned-resources": "Bulk Move Provisioned Resources",
|
||||
"cancel-button": "Cancel",
|
||||
"cannot-move-folders": "Folders cannot be moved",
|
||||
"confirmation-text": "Delete",
|
||||
"delete-button": "Delete",
|
||||
"delete-modal-invalid-text": "One or more folders contain library panels or alert rules. Delete these first in order to proceed.",
|
||||
|
||||
Reference in New Issue
Block a user