Separated index file into smaller files
Summary: More is more. Just moving code, no further changes. Reviewed By: nikoant Differential Revision: D22374891 fbshipit-source-id: 65c9af8b4b34ee8e16aeae5705528093e1c800cc
This commit is contained in:
committed by
Facebook GitHub Bot
parent
006bf5357f
commit
fbb1c78184
@@ -21,13 +21,11 @@ import {
|
|||||||
import {Counter} from './LogWatcher';
|
import {Counter} from './LogWatcher';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Text,
|
|
||||||
ManagedTableClass,
|
ManagedTableClass,
|
||||||
Button,
|
Button,
|
||||||
colors,
|
colors,
|
||||||
ContextMenu,
|
ContextMenu,
|
||||||
FlexColumn,
|
FlexColumn,
|
||||||
Glyph,
|
|
||||||
DetailSidebar,
|
DetailSidebar,
|
||||||
FlipperDevicePlugin,
|
FlipperDevicePlugin,
|
||||||
SearchableTable,
|
SearchableTable,
|
||||||
@@ -40,6 +38,8 @@ import {
|
|||||||
} from 'flipper';
|
} from 'flipper';
|
||||||
import LogWatcher from './LogWatcher';
|
import LogWatcher from './LogWatcher';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import {Icon, LogCount, HiddenScrollText} from './logComponents';
|
||||||
|
import {pad, getLineCount, keepKeys} from './logUtils';
|
||||||
|
|
||||||
const LOG_WATCHER_LOCAL_STORAGE_KEY = 'LOG_WATCHER_LOCAL_STORAGE_KEY';
|
const LOG_WATCHER_LOCAL_STORAGE_KEY = 'LOG_WATCHER_LOCAL_STORAGE_KEY';
|
||||||
|
|
||||||
@@ -63,33 +63,6 @@ type State = BaseState & AdditionalState;
|
|||||||
|
|
||||||
type PersistedState = {};
|
type PersistedState = {};
|
||||||
|
|
||||||
const Icon = styled(Glyph)({
|
|
||||||
marginTop: 5,
|
|
||||||
});
|
|
||||||
|
|
||||||
function getLineCount(str: string): number {
|
|
||||||
let count = 1;
|
|
||||||
if (!(typeof str === 'string')) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
for (let i = 0; i < str.length; i++) {
|
|
||||||
if (str[i] === '\n') {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
function keepKeys<A>(obj: A, keys: Array<string>): A {
|
|
||||||
const result: A = {} as A;
|
|
||||||
for (const key in obj) {
|
|
||||||
if (keys.includes(key)) {
|
|
||||||
result[key] = obj[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
const COLUMN_SIZE = {
|
const COLUMN_SIZE = {
|
||||||
type: 40,
|
type: 40,
|
||||||
time: 120,
|
time: 120,
|
||||||
@@ -222,41 +195,6 @@ const DEFAULT_FILTERS = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const HiddenScrollText = styled(Text)({
|
|
||||||
alignSelf: 'baseline',
|
|
||||||
lineHeight: '130%',
|
|
||||||
marginTop: 5,
|
|
||||||
paddingBottom: 3,
|
|
||||||
'&::-webkit-scrollbar': {
|
|
||||||
display: 'none',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const LogCount = styled.div<{backgroundColor: string}>(({backgroundColor}) => ({
|
|
||||||
backgroundColor,
|
|
||||||
borderRadius: '999em',
|
|
||||||
fontSize: 11,
|
|
||||||
marginTop: 4,
|
|
||||||
minWidth: 16,
|
|
||||||
height: 16,
|
|
||||||
color: colors.white,
|
|
||||||
textAlign: 'center',
|
|
||||||
lineHeight: '16px',
|
|
||||||
paddingLeft: 4,
|
|
||||||
paddingRight: 4,
|
|
||||||
textOverflow: 'ellipsis',
|
|
||||||
overflow: 'hidden',
|
|
||||||
whiteSpace: 'nowrap',
|
|
||||||
}));
|
|
||||||
|
|
||||||
function pad(chunk: any, len: number): string {
|
|
||||||
let str = String(chunk);
|
|
||||||
while (str.length < len) {
|
|
||||||
str = `0${str}`;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addEntriesToState(
|
export function addEntriesToState(
|
||||||
items: Entries,
|
items: Entries,
|
||||||
state: BaseState = {
|
state: BaseState = {
|
||||||
|
|||||||
44
desktop/plugins/logs/logComponents.tsx
Normal file
44
desktop/plugins/logs/logComponents.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {Text, colors, Glyph, styled} from 'flipper';
|
||||||
|
|
||||||
|
export const Icon = styled(Glyph)({
|
||||||
|
marginTop: 5,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const HiddenScrollText = styled(Text)({
|
||||||
|
userSelect: 'none',
|
||||||
|
alignSelf: 'baseline',
|
||||||
|
lineHeight: '130%',
|
||||||
|
marginTop: 5,
|
||||||
|
paddingBottom: 3,
|
||||||
|
'&::-webkit-scrollbar': {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const LogCount = styled.div<{backgroundColor: string}>(
|
||||||
|
({backgroundColor}) => ({
|
||||||
|
backgroundColor,
|
||||||
|
borderRadius: '999em',
|
||||||
|
fontSize: 11,
|
||||||
|
marginTop: 4,
|
||||||
|
minWidth: 16,
|
||||||
|
height: 16,
|
||||||
|
color: colors.white,
|
||||||
|
textAlign: 'center',
|
||||||
|
lineHeight: '16px',
|
||||||
|
paddingLeft: 4,
|
||||||
|
paddingRight: 4,
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
overflow: 'hidden',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
}),
|
||||||
|
);
|
||||||
39
desktop/plugins/logs/logUtils.tsx
Normal file
39
desktop/plugins/logs/logUtils.tsx
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function getLineCount(str: string): number {
|
||||||
|
let count = 1;
|
||||||
|
if (!(typeof str === 'string')) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
for (let i = 0; i < str.length; i++) {
|
||||||
|
if (str[i] === '\n') {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function keepKeys<A>(obj: A, keys: Array<string>): A {
|
||||||
|
const result: A = {} as A;
|
||||||
|
for (const key in obj) {
|
||||||
|
if (keys.includes(key)) {
|
||||||
|
result[key] = obj[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function pad(chunk: any, len: number): string {
|
||||||
|
let str = String(chunk);
|
||||||
|
while (str.length < len) {
|
||||||
|
str = `0${str}`;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user