Skip to content

Commit 25e7b93

Browse files
Merge pull request #1862 from openshift-cherrypick-robot/cherry-pick-1861-to-release-4.19
[release-4.19] OLS-2925: Fix revert not clearing edit icon from attachment label
2 parents a4a10fa + 9d188b9 commit 25e7b93

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/components/AttachmentModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const AttachmentModal: React.FC = () => {
149149
attachment.ownerName,
150150
attachment.namespace,
151151
value,
152-
undefined,
152+
value,
153153
attachment.id,
154154
),
155155
);

unit-tests/redux-reducers.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,27 @@ describe('attachments', () => {
239239
strictEqual(state.getIn(['attachments', 'a']).originalValue, 'apiVersion: v1');
240240
});
241241

242+
it('AttachmentSet revert clears changed state when originalValue equals value', () => {
243+
let state = initState();
244+
state = dispatch(state, ActionType.AttachmentSet, {
245+
...attachment,
246+
id: 'a',
247+
value: 'edited yaml',
248+
originalValue: 'apiVersion: v1',
249+
});
250+
strictEqual(state.getIn(['attachments', 'a']).value, 'edited yaml');
251+
strictEqual(state.getIn(['attachments', 'a']).originalValue, 'apiVersion: v1');
252+
253+
state = dispatch(state, ActionType.AttachmentSet, {
254+
...attachment,
255+
id: 'a',
256+
value: 'apiVersion: v1',
257+
originalValue: 'apiVersion: v1',
258+
});
259+
strictEqual(state.getIn(['attachments', 'a']).value, 'apiVersion: v1');
260+
strictEqual(state.getIn(['attachments', 'a']).originalValue, 'apiVersion: v1');
261+
});
262+
242263
it('AttachmentSet respects empty-string originalValue as explicit', () => {
243264
let state = initState();
244265
state = dispatch(state, ActionType.AttachmentSet, {

0 commit comments

Comments
 (0)