mirror of https://github.com/apache/druid.git
Add minor CSS to make long value copy even easier (#7829)
This commit is contained in:
parent
61ec521135
commit
0de7983db5
|
@ -29,7 +29,7 @@
|
||||||
"compile": "./script/build",
|
"compile": "./script/build",
|
||||||
"pretest": "./script/build",
|
"pretest": "./script/build",
|
||||||
"run": "./script/run",
|
"run": "./script/run",
|
||||||
"test": "jest --silent 2>&1",
|
"test": "npm run tslint && jest --silent 2>&1",
|
||||||
"coverage": "jest --coverage",
|
"coverage": "jest --coverage",
|
||||||
"update-snapshots": "jest -u",
|
"update-snapshots": "jest -u",
|
||||||
"tslint": "./node_modules/.bin/tslint -c tslint.json --project tsconfig.json --formatters-dir ./node_modules/awesome-code-style/formatter 'src/**/*.ts?(x)'",
|
"tslint": "./node_modules/.bin/tslint -c tslint.json --project tsconfig.json --formatters-dir ./node_modules/awesome-code-style/formatter 'src/**/*.ts?(x)'",
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { IconNames } from '@blueprintjs/icons';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { render } from 'react-testing-library';
|
import { render } from 'react-testing-library';
|
||||||
|
|
||||||
import { ActionIcon } from './action-icon';
|
import { ActionIcon } from './action-icon';
|
||||||
import { IconNames } from '@blueprintjs/icons';
|
|
||||||
|
|
||||||
describe('action icon', () => {
|
describe('action icon', () => {
|
||||||
it('matches snapshot', () => {
|
it('matches snapshot', () => {
|
||||||
|
|
|
@ -4,7 +4,13 @@ exports[`table cell matches snapshot array long 1`] = `
|
||||||
<span
|
<span
|
||||||
class="table-cell truncated"
|
class="table-cell truncated"
|
||||||
>
|
>
|
||||||
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ...323 omitted... 7, 98, 99]
|
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
|
||||||
|
<span
|
||||||
|
class="omitted"
|
||||||
|
>
|
||||||
|
...323 omitted...
|
||||||
|
</span>
|
||||||
|
7, 98, 99]
|
||||||
<span
|
<span
|
||||||
class="bp3-icon bp3-icon-clipboard action-icon"
|
class="bp3-icon bp3-icon-clipboard action-icon"
|
||||||
icon="clipboard"
|
icon="clipboard"
|
||||||
|
@ -43,7 +49,13 @@ exports[`table cell matches snapshot truncate 1`] = `
|
||||||
<span
|
<span
|
||||||
class="table-cell truncated"
|
class="table-cell truncated"
|
||||||
>
|
>
|
||||||
testtesttesttesttesttesttesttesttesttesttesttesttesttestt ...329 omitted... sttesttest
|
testtesttesttesttesttesttesttesttesttesttesttesttesttestt
|
||||||
|
<span
|
||||||
|
class="omitted"
|
||||||
|
>
|
||||||
|
...329 omitted...
|
||||||
|
</span>
|
||||||
|
sttesttest
|
||||||
<span
|
<span
|
||||||
class="bp3-icon bp3-icon-clipboard action-icon"
|
class="bp3-icon bp3-icon-clipboard action-icon"
|
||||||
icon="clipboard"
|
icon="clipboard"
|
||||||
|
|
|
@ -30,8 +30,23 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&.truncated {
|
&.truncated {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
display: inline-block;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
padding-right: 16px;
|
||||||
|
|
||||||
|
.omitted {
|
||||||
|
margin: 0 0.2em;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
.action-icon {
|
.action-icon {
|
||||||
margin-left: 5px;
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,23 @@ export interface NullTableCellProps extends React.Props<any> {
|
||||||
unparseable?: boolean;
|
unparseable?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ShortParts {
|
||||||
|
prefix: string;
|
||||||
|
omitted: string;
|
||||||
|
suffix: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class TableCell extends React.Component<NullTableCellProps, {}> {
|
export class TableCell extends React.Component<NullTableCellProps, {}> {
|
||||||
static MAX_CHARS_TO_SHOW = 50;
|
static MAX_CHARS_TO_SHOW = 50;
|
||||||
|
|
||||||
static possiblyTruncate(str: string): React.ReactNode {
|
static possiblyTruncate(str: string): React.ReactNode {
|
||||||
if (str.length < TableCell.MAX_CHARS_TO_SHOW) return str;
|
if (str.length < TableCell.MAX_CHARS_TO_SHOW) return str;
|
||||||
|
|
||||||
|
const { prefix, omitted, suffix } = TableCell.shortenString(str);
|
||||||
return <span className="table-cell truncated">
|
return <span className="table-cell truncated">
|
||||||
{TableCell.shortenString(str)}
|
{prefix}
|
||||||
|
<span className="omitted">{omitted}</span>
|
||||||
|
{suffix}
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
icon={IconNames.CLIPBOARD}
|
icon={IconNames.CLIPBOARD}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -53,13 +63,17 @@ export class TableCell extends React.Component<NullTableCellProps, {}> {
|
||||||
</span>;
|
</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
static shortenString(str: string): string {
|
static shortenString(str: string): ShortParts {
|
||||||
// Print something like:
|
// Print something like:
|
||||||
// BAAAArAAEiQKpDAEAACwZCBAGSBgiSEAAAAQpAIDwAg...23 omitted...gwiRoQBJIC
|
// BAAAArAAEiQKpDAEAACwZCBAGSBgiSEAAAAQpAIDwAg...23 omitted...gwiRoQBJIC
|
||||||
const omit = str.length - (TableCell.MAX_CHARS_TO_SHOW + 17);
|
const omit = str.length - (TableCell.MAX_CHARS_TO_SHOW + 17);
|
||||||
const prefix = str.substr(0, str.length - (omit + 10));
|
const prefix = str.substr(0, str.length - (omit + 10));
|
||||||
const suffix = str.substr(str.length - 10);
|
const suffix = str.substr(str.length - 10);
|
||||||
return `${prefix} ...${omit} omitted... ${suffix}`;
|
return {
|
||||||
|
prefix,
|
||||||
|
omitted: `...${omit} omitted...`,
|
||||||
|
suffix
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
Loading…
Reference in New Issue