mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
fix: Add folder names in permissions dialog similar to the launch dialog (#11278)
This commit is contained in:
@@ -46,6 +46,7 @@ describe('PermissionsModifyTrustDialog', () => {
|
|||||||
let mockCommitTrustLevelChange: Mock;
|
let mockCommitTrustLevelChange: Mock;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
mockedCwd.mockReturnValue('/test/dir');
|
||||||
mockUpdateTrustLevel = vi.fn();
|
mockUpdateTrustLevel = vi.fn();
|
||||||
mockCommitTrustLevelChange = vi.fn();
|
mockCommitTrustLevelChange = vi.fn();
|
||||||
vi.mocked(usePermissionsModifyTrust).mockReturnValue({
|
vi.mocked(usePermissionsModifyTrust).mockReturnValue({
|
||||||
@@ -120,6 +121,17 @@ describe('PermissionsModifyTrustDialog', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render the labels with folder names', async () => {
|
||||||
|
const { lastFrame } = renderWithProviders(
|
||||||
|
<PermissionsModifyTrustDialog onExit={vi.fn()} addItem={vi.fn()} />,
|
||||||
|
);
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(lastFrame()).toContain('Trust this folder (dir)');
|
||||||
|
expect(lastFrame()).toContain('Trust parent folder (test)');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should call onExit when escape is pressed', async () => {
|
it('should call onExit when escape is pressed', async () => {
|
||||||
const onExit = vi.fn();
|
const onExit = vi.fn();
|
||||||
const { stdin, lastFrame } = renderWithProviders(
|
const { stdin, lastFrame } = renderWithProviders(
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
import { Box, Text } from 'ink';
|
import { Box, Text } from 'ink';
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
|
import * as process from 'node:process';
|
||||||
|
import * as path from 'node:path';
|
||||||
import { TrustLevel } from '../../config/trustedFolders.js';
|
import { TrustLevel } from '../../config/trustedFolders.js';
|
||||||
import { useKeypress } from '../hooks/useKeypress.js';
|
import { useKeypress } from '../hooks/useKeypress.js';
|
||||||
import { usePermissionsModifyTrust } from '../hooks/usePermissionsModifyTrust.js';
|
import { usePermissionsModifyTrust } from '../hooks/usePermissionsModifyTrust.js';
|
||||||
@@ -19,14 +21,21 @@ interface PermissionsModifyTrustDialogProps {
|
|||||||
addItem: UseHistoryManagerReturn['addItem'];
|
addItem: UseHistoryManagerReturn['addItem'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function PermissionsModifyTrustDialog({
|
||||||
|
onExit,
|
||||||
|
addItem,
|
||||||
|
}: PermissionsModifyTrustDialogProps): React.JSX.Element {
|
||||||
|
const dirName = path.basename(process.cwd());
|
||||||
|
const parentFolder = path.basename(path.dirname(process.cwd()));
|
||||||
|
|
||||||
const TRUST_LEVEL_ITEMS = [
|
const TRUST_LEVEL_ITEMS = [
|
||||||
{
|
{
|
||||||
label: 'Trust this folder',
|
label: `Trust this folder (${dirName})`,
|
||||||
value: TrustLevel.TRUST_FOLDER,
|
value: TrustLevel.TRUST_FOLDER,
|
||||||
key: TrustLevel.TRUST_FOLDER,
|
key: TrustLevel.TRUST_FOLDER,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Trust parent folder',
|
label: `Trust parent folder (${parentFolder})`,
|
||||||
value: TrustLevel.TRUST_PARENT,
|
value: TrustLevel.TRUST_PARENT,
|
||||||
key: TrustLevel.TRUST_PARENT,
|
key: TrustLevel.TRUST_PARENT,
|
||||||
},
|
},
|
||||||
@@ -37,10 +46,6 @@ const TRUST_LEVEL_ITEMS = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export function PermissionsModifyTrustDialog({
|
|
||||||
onExit,
|
|
||||||
addItem,
|
|
||||||
}: PermissionsModifyTrustDialogProps): React.JSX.Element {
|
|
||||||
const {
|
const {
|
||||||
cwd,
|
cwd,
|
||||||
currentTrustLevel,
|
currentTrustLevel,
|
||||||
|
|||||||
Reference in New Issue
Block a user