-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix resizing issues with cloud shell terminal drawer
- Loading branch information
1 parent
3945e51
commit 0fc8c51
Showing
7 changed files
with
186 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
frontend/packages/console-shared/src/components/drawer/DraggableCoreIFrameFix.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.ocs-draggable-core-iframe-fix { | ||
& iframe { | ||
pointer-events: none !important; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
frontend/packages/console-shared/src/components/drawer/DraggableCoreIFrameFix.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as React from 'react'; | ||
import { DraggableCore, DraggableEvent, DraggableData } from 'react-draggable'; | ||
|
||
import './DraggableCoreIFrameFix.scss'; | ||
|
||
const DraggableCoreIFrameFix: React.FC<React.ComponentProps<typeof DraggableCore>> = ({ | ||
onStart, | ||
onStop, | ||
...other | ||
}) => { | ||
const onStartFn = | ||
// rule is inconsistent with typescript return type | ||
// eslint-disable-next-line consistent-return | ||
(e: DraggableEvent, data: DraggableData): false | void => { | ||
document.body.classList.add('ocs-draggable-core-iframe-fix'); | ||
if (onStart) { | ||
return onStart(e, data); | ||
} | ||
}; | ||
|
||
const onStopFn = | ||
// rule is inconsistent with typescript return type | ||
// eslint-disable-next-line consistent-return | ||
(e: DraggableEvent, data: DraggableData): false | void => { | ||
document.body.classList.remove('ocs-draggable-core-iframe-fix'); | ||
if (onStop) { | ||
return onStop(e, data); | ||
} | ||
}; | ||
|
||
return <DraggableCore {...other} onStart={onStartFn} onStop={onStopFn} />; | ||
}; | ||
|
||
export default DraggableCoreIFrameFix; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...d/packages/console-shared/src/components/drawer/__tests__/DraggableCoreIFrameFix.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import DraggableCoreIFrameFix from '../DraggableCoreIFrameFix'; | ||
import { DraggableCore, DraggableEvent, DraggableData } from 'react-draggable'; | ||
|
||
describe('DraggableCoreIFrameFix', () => { | ||
it('should execute handlers and apply fix class', () => { | ||
const onStart = jest.fn(); | ||
const onStop = jest.fn(); | ||
const event = {} as DraggableEvent; | ||
const data = {} as DraggableData; | ||
const wrapper = shallow(<DraggableCoreIFrameFix onStart={onStart} onStop={onStop} />); | ||
|
||
wrapper | ||
.find(DraggableCore) | ||
.props() | ||
.onStart(event, data); | ||
expect(document.body.className).toBe('ocs-draggable-core-iframe-fix'); | ||
|
||
wrapper | ||
.find(DraggableCore) | ||
.props() | ||
.onStop(event, data); | ||
expect(document.body.className).toBe(''); | ||
|
||
expect(onStart).toHaveBeenCalledWith(event, data); | ||
expect(onStop).toHaveBeenCalledWith(event, data); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters