Skip to content

Commit 795cad7

Browse files
committed
feat(broker-configs): adjust edit button state in read-only mode
1 parent 4e2cee7 commit 795cad7

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

frontend/src/components/Brokers/Broker/Configs/TableComponents/InputCell/InputCellViewMode.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import React, { type FC } from 'react';
1+
import React, { type FC, useContext } from 'react';
22
import { Button } from 'components/common/Button/Button';
33
import EditIcon from 'components/common/Icons/EditIcon';
44
import type { ConfigUnit } from 'components/Brokers/Broker/Configs/lib/types';
55
import Tooltip from 'components/common/Tooltip/Tooltip';
66
import { getConfigDisplayValue } from 'components/Brokers/Broker/Configs/lib/utils';
77

88
import * as S from './styled';
9+
import ClusterContext from 'components/contexts/ClusterContext';
910

1011
interface InputCellViewModeProps {
1112
value: string;
1213
unit: ConfigUnit | undefined;
1314
onEdit: () => void;
1415
isDynamic: boolean;
1516
isSensitive: boolean;
16-
isReadOnly: boolean;
1717
}
1818

1919
const InputCellViewMode: FC<InputCellViewModeProps> = ({
@@ -22,14 +22,15 @@ const InputCellViewMode: FC<InputCellViewModeProps> = ({
2222
onEdit,
2323
isDynamic,
2424
isSensitive,
25-
isReadOnly,
2625
}) => {
2726
const { displayValue, title } = getConfigDisplayValue(
2827
isSensitive,
2928
value,
3029
unit
3130
);
3231

32+
const { isReadOnly } = useContext(ClusterContext);
33+
3334
return (
3435
<S.ValueWrapper $isDynamic={isDynamic}>
3536
<S.Value title={title}>{displayValue}</S.Value>

frontend/src/components/Brokers/Broker/Configs/TableComponents/InputCell/__test__/InputCellViewMode.spec.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ describe('InputCellViewMode', () => {
1616
onEdit={mockOnEdit}
1717
isDynamic
1818
isSensitive={false}
19-
isReadOnly={false}
2019
/>
2120
);
2221
expect(screen.getByTitle(value)).toBeInTheDocument();
@@ -30,7 +29,6 @@ describe('InputCellViewMode', () => {
3029
onEdit={mockOnEdit}
3130
isDynamic
3231
isSensitive
33-
isReadOnly={false}
3432
/>
3533
);
3634
expect(screen.getByTitle('Sensitive Value')).toBeInTheDocument();
@@ -46,7 +44,6 @@ describe('InputCellViewMode', () => {
4644
onEdit={mockOnEdit}
4745
isDynamic
4846
isSensitive={false}
49-
isReadOnly={false}
5047
/>
5148
);
5249
await user.click(screen.getByLabelText('editAction'));
@@ -61,7 +58,6 @@ describe('InputCellViewMode', () => {
6158
onEdit={mockOnEdit}
6259
isDynamic
6360
isSensitive={false}
64-
isReadOnly
6561
/>
6662
);
6763
expect(screen.getByLabelText('editAction')).toBeDisabled();

frontend/src/components/Brokers/Broker/Configs/TableComponents/InputCell/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const InputCell: FC<InputCellProps> = ({ row, onUpdate }) => {
2424
source,
2525
value: initialValue,
2626
isSensitive,
27-
isReadOnly,
2827
} = row.original;
2928

3029
const handleSave = (newValue: string) => {
@@ -52,7 +51,6 @@ const InputCell: FC<InputCellProps> = ({ row, onUpdate }) => {
5251
onEdit={() => setIsEdit(true)}
5352
isDynamic={isDynamic}
5453
isSensitive={isSensitive}
55-
isReadOnly={isReadOnly}
5654
/>
5755
);
5856
};

0 commit comments

Comments
 (0)