Skip to content

Commit

Permalink
Update Redis CLI auto-scrolling textarea to autosize (#26)
Browse files Browse the repository at this point in the history
* Add auto resizing for redis cli textarea

* Update Icon

* Update styles

Co-authored-by: Mikhail <[email protected]>
  • Loading branch information
asimonok and Mikhail authored Dec 29, 2020
1 parent edf9ec9 commit edffd91
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 36 deletions.
1 change: 0 additions & 1 deletion src/redis-cli-panel/components/redis-cli-panel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ describe('RedisCLIPanel', () => {
const testedComponent = wrapper.find(AutoScrollingTextarea);
expect(testedComponent.exists()).toBeTruthy();
expect(testedComponent.prop('value')).toEqual(options.output);
expect(testedComponent.prop('rows')).toEqual(options.height);
});

/*
Expand Down
4 changes: 2 additions & 2 deletions src/redis-cli-panel/components/redis-cli-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ export const RedisCLIPanel: React.FC<PanelProps<PanelOptions>> = ({
`
)}
>
<div className="gf-form">
<AutoScrollingTextarea className={cx(styles.textarea)} value={output} rows={options.height} />
<div className={cx('gf-form', styles.form)}>
<AutoScrollingTextarea className={cx(styles.textarea)} value={output} />
</div>

{query && help && (
Expand Down
22 changes: 12 additions & 10 deletions src/redis-cli-panel/img/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 0 additions & 8 deletions src/redis-cli-panel/module.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,4 @@ describe('plugin', () => {
it('should be instance of PanelPlugin', () => {
expect(plugin).toBeInstanceOf(PanelPlugin);
});

it('Should add textarea height input', () => {
const builder = {
addNumberInput: jest.fn(),
};
plugin['registerOptionEditors'](builder);
expect(builder.addNumberInput).toHaveBeenCalledWith({ path: 'height', name: 'Textarea height', defaultValue: 12 });
});
});
8 changes: 1 addition & 7 deletions src/redis-cli-panel/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,4 @@ import { PanelOptions } from './types';
/**
* Panel Plugin
*/
export const plugin = new PanelPlugin<PanelOptions>(RedisCLIPanel).setPanelOptions((builder) => {
return builder.addNumberInput({
path: 'height',
name: 'Textarea height',
defaultValue: 12,
});
});
export const plugin = new PanelPlugin<PanelOptions>(RedisCLIPanel);
7 changes: 6 additions & 1 deletion src/redis-cli-panel/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ export const Styles = stylesFactory(() => {
return {
wrapper: css`
position: relative;
min-height: 100px;
`,
textarea: css`
font-family: Consolas, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono,
Courier New, monospace;
height: 100%;
`,
form: css`
height: calc(100% - 40px);
`,
help: css`
position: absolute;
bottom: 100px;
bottom: 80px;
left: 10px;
width: calc(100% - 22px);
min-height: 124px;
Expand Down
7 changes: 0 additions & 7 deletions src/redis-cli-panel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ import {
* Panel Options
*/
export interface PanelOptions {
/**
* TextArea Height
*
* @type {number}
*/
height: number;

/**
* Query command
*
Expand Down

0 comments on commit edffd91

Please sign in to comment.