Skip to content

Commit b4b7143

Browse files
abdullahtariq1171SaraVieira
authored andcommitted
Feature/add console filters (codesandbox#1225)
* add console filters * update 'console-feed' * connect filters with 'console-feed' * Add @abdullahtariq1171 as a contributor * update 'console-feed' update-checksums * Change input field component to FilterInput * use common <Select /> * add border for console filter select
1 parent f1372d1 commit b4b7143

File tree

8 files changed

+98
-18
lines changed

8 files changed

+98
-18
lines changed

.all-contributorsrc

+10
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,16 @@
645645
]
646646
},
647647
{
648+
"login": "abdullahtariq1171",
649+
"name": "Abdullah",
650+
"avatar_url": "https://avatars0.githubusercontent.com/u/5623766?v=4",
651+
"profile": "https://github.com/abdullahtariq1171",
652+
"contributions": [
653+
"code",
654+
"design"
655+
]
656+
}
657+
{
648658
"login": "dv297",
649659
"name": "Daniel Vu",
650660
"avatar_url": "https://avatars2.githubusercontent.com/u/5365325?v=4",

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Thanks goes to these wonderful people
5151
| [<img src="https://avatars0.githubusercontent.com/u/1820292?v=4" width="100px;"/><br /><sub><b>Michel Weststrate</b></sub>](https://twitter.com/mweststrate)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=mweststrate "Code") | [<img src="https://avatars0.githubusercontent.com/u/52824?v=4" width="100px;"/><br /><sub><b>Oleg</b></sub>](https://kof.github.io)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=kof "Code") | [<img src="https://avatars0.githubusercontent.com/u/1127037?v=4" width="100px;"/><br /><sub><b>Paul Sherman</b></sub>](https://www.pshrmn.com)<br />[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Apshrmn "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=pshrmn "Code") | [<img src="https://avatars2.githubusercontent.com/u/9244507?v=4" width="100px;"/><br /><sub><b>Ro Savage</b></sub>](https://github.com/ro-savage)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=ro-savage "Code") | [<img src="https://avatars3.githubusercontent.com/u/13242392?v=4" width="100px;"/><br /><sub><b>Sam Denty</b></sub>](https://samdd.me)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=samdenty99 "Code") | [<img src="https://avatars1.githubusercontent.com/u/3087225?v=4" width="100px;"/><br /><sub><b>Zephraph</b></sub>](https://github.com/zephraph)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=zephraph "Code") | [<img src="https://avatars1.githubusercontent.com/u/1900735?v=4" width="100px;"/><br /><sub><b>Josh Waller</b></sub>](https://www.joshwaller.me)<br />[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Amdxprograms "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=mdxprograms "Code") [📖](https://github.com/CompuIves/codesandbox-client/commits?author=mdxprograms "Documentation") |
5252
| [<img src="https://avatars0.githubusercontent.com/u/1195863?v=4" width="100px;"/><br /><sub><b>Joe Ng'ethe</b></sub>](http://joey.co.ke)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=joeynimu "Code") | [<img src="https://avatars0.githubusercontent.com/u/576935?v=4" width="100px;"/><br /><sub><b>Carles Codony</b></sub>](https://github.com/bitblitter)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=bitblitter "Code") | [<img src="https://avatars2.githubusercontent.com/u/468006?v=4" width="100px;"/><br /><sub><b>Vytenis</b></sub>](https://github.com/FDiskas)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=FDiskas "Code") | [<img src="https://avatars1.githubusercontent.com/u/894149?v=4" width="100px;"/><br /><sub><b>Manuel Dugué</b></sub>](http://manueldugue.de)<br />[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Amdugue "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=mdugue "Code") | [<img src="https://avatars2.githubusercontent.com/u/5346497?v=4" width="100px;"/><br /><sub><b>Demian Dekoninck</b></sub>](https://dem.be)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=DemianD "Code") | [<img src="https://avatars2.githubusercontent.com/u/3144549?v=4" width="100px;"/><br /><sub><b>Drake Costa</b></sub>](http://www.saeris.io)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=Saeris "Code") | [<img src="https://avatars2.githubusercontent.com/u/433394?v=4" width="100px;"/><br /><sub><b>Marko Stijak</b></sub>](https://cxjs.io/)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=mstijak "Code") |
5353
| [<img src="https://avatars2.githubusercontent.com/u/10588170?v=4" width="100px;"/><br /><sub><b>Ilya</b></sub>](https://twitter.com/ilya_komar0ff)<br />[💬](#question-Komar0ff "Answering Questions") [🤔](#ideas-Komar0ff "Ideas, Planning, & Feedback") | [<img src="https://avatars2.githubusercontent.com/u/10627086?v=4" width="100px;"/><br /><sub><b>Emerson Laurentino</b></sub>](https://twitter.com/elaurent_)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=emersonlaurentino "Code") [🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Aemersonlaurentino "Bug reports") | [<img src="https://avatars3.githubusercontent.com/u/180963?v=4" width="100px;"/><br /><sub><b>Aaron Reisman</b></sub>](https://github.com/lifeiscontent)<br />[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Alifeiscontent "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=lifeiscontent "Code") [📦](#platform-lifeiscontent "Packaging/porting to new platform") | [<img src="https://avatars2.githubusercontent.com/u/19484365?v=4" width="100px;"/><br /><sub><b>Colton Colcleasure</b></sub>](https://github.com/colshacol)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=colshacol "Code") [🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Acolshacol "Bug reports") | [<img src="https://avatars0.githubusercontent.com/u/497242?v=4" width="100px;"/><br /><sub><b>PJ Walker</b></sub>](https://github.com/PJWalker)<br />[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3APJWalker "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=PJWalker "Code") | [<img src="https://avatars2.githubusercontent.com/u/29819102?v=4" width="100px;"/><br /><sub><b>Satya Rohith</b></sub>](https://satya.tech)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=satyarohith "Code") [📖](https://github.com/CompuIves/codesandbox-client/commits?author=satyarohith "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/17421347?v=4" width="100px;"/><br /><sub><b>Melanie Seltzer</b></sub>](https://www.melanieseltzer.io/)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=melanieseltzer "Code") |
54-
| [<img src="https://avatars1.githubusercontent.com/u/23313266?v=4" width="100px;"/><br /><sub><b>ZYSzys</b></sub>](http://zyszys.top)<br />[📖](https://github.com/CompuIves/codesandbox-client/commits?author=ZYSzys "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/1051509?v=4" width="100px;"/><br /><sub><b>Sara Vieira</b></sub>](http://iamsaravieira.com)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=SaraVieira "Code") [🎨](#design-SaraVieira "Design") [🤔](#ideas-SaraVieira "Ideas, Planning, & Feedback") | [<img src="https://avatars3.githubusercontent.com/u/6137112?v=4" width="100px;"/><br /><sub><b>François Chalifour</b></sub>](https://francoischalifour.com)<br />[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Afrancoischalifour "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=francoischalifour "Code") | [<img src="https://avatars2.githubusercontent.com/u/5365325?v=4" width="100px;"/><br /><sub><b>Daniel Vu</b></sub>](https://twitter.com/dvv297)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=dv297 "Code") | [<img src="https://avatars3.githubusercontent.com/u/4931048?v=4" width="100px;"/><br /><sub><b>Vivek Nayyar</b></sub>](https://www.viveknayyar.in/)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=vivek12345 "Code") | [<img src="https://avatars3.githubusercontent.com/u/6244647?v=4" width="100px;"/><br /><sub><b>Bob Ziroll</b></sub>](https://github.com/bobziroll)<br />[📖](https://github.com/CompuIves/codesandbox-client/commits?author=bobziroll "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/640208?v=4" width="100px;"/><br /><sub><b>Alexander Lichter</b></sub>](https://blog.lichter.io)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=manniL "Code") |
54+
| [<img src="https://avatars1.githubusercontent.com/u/23313266?v=4" width="100px;"/><br /><sub><b>ZYSzys</b></sub>](http://zyszys.top)<br />[📖](https://github.com/CompuIves/codesandbox-client/commits?author=ZYSzys "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/1051509?v=4" width="100px;"/><br /><sub><b>Sara Vieira</b></sub>](http://iamsaravieira.com)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=SaraVieira "Code") [🎨](#design-SaraVieira "Design") [🤔](#ideas-SaraVieira "Ideas, Planning, & Feedback") | [<img src="https://avatars3.githubusercontent.com/u/6137112?v=4" width="100px;"/><br /><sub><b>François Chalifour</b></sub>](https://francoischalifour.com)<br />[🐛](https://github.com/CompuIves/codesandbox-client/issues?q=author%3Afrancoischalifour "Bug reports") [💻](https://github.com/CompuIves/codesandbox-client/commits?author=francoischalifour "Code") | [<img src="https://avatars2.githubusercontent.com/u/5365325?v=4" width="100px;"/><br /><sub><b>Daniel Vu</b></sub>](https://twitter.com/dvv297)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=dv297 "Code") | [<img src="https://avatars3.githubusercontent.com/u/4931048?v=4" width="100px;"/><br /><sub><b>Vivek Nayyar</b></sub>](https://www.viveknayyar.in/)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=vivek12345 "Code") | [<img src="https://avatars3.githubusercontent.com/u/6244647?v=4" width="100px;"/><br /><sub><b>Bob Ziroll</b></sub>](https://github.com/bobziroll)<br />[📖](https://github.com/CompuIves/codesandbox-client/commits?author=bobziroll "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/640208?v=4" width="100px;"/><br /><sub><b>Alexander Lichter</b></sub>](https://blog.lichter.io)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=manniL "Code") | <sub><b>Abdullah</b></sub>](https://github.com/abdullahtariq1171)<br />[💻](https://github.com/CompuIves/codesandbox-client/commits?author=abdullahtariq1171 "Code") [🎨](#design-abdullahtariq1171 "Design") |
5555
<!-- ALL-CONTRIBUTORS-LIST:END -->
5656

5757
## Backers

packages/app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
"codesandbox-import-utils": "1.3.5",
151151
"color": "^0.11.4",
152152
"compare-versions": "^3.1.0",
153-
"console-feed": "^2.8.0",
153+
"console-feed": "^2.8.5",
154154
"css-modules-loader-core": "^1.1.0",
155155
"cssnano": "^3.10.0",
156156
"debug": "^2.6.8",

packages/app/src/app/components/Preview/DevTools/Console/elements.js

+18
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ export const IconContainer = styled.div`
3535
justify-content: center;
3636
`;
3737

38+
export const FilterInput = styled.input`
39+
transition: 0.4s ease all;
40+
background-color: ${props =>
41+
props.theme['input.background'] || 'rgba(255, 255, 255, 0.1)'};
42+
border: 1px solid transparent;
43+
outline: none;
44+
border-radius: 4px;
45+
width: 6em;
46+
padding: 0.15em 0.5em;
47+
margin-right: 8px;
48+
49+
color: ${props => props.theme['input.foreground'] || 'white'};
50+
51+
&:focus {
52+
width: 8em;
53+
}
54+
`;
55+
3856
export const inspectorTheme = theme => ({
3957
PADDING: '0.4rem 1.5rem 0.4rem 0px',
4058

packages/app/src/app/components/Preview/DevTools/Console/index.js

+62-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import update from 'immutability-helper';
77
import ClearIcon from 'react-icons/lib/md/clear-all';
88
import { Decode, Console as ConsoleFeed } from 'console-feed';
99

10+
import Select from 'common/components/Select';
1011
import Input from './Input';
1112

12-
import { Container, Messages, inspectorTheme } from './elements';
13+
import { Container, Messages, inspectorTheme, FilterInput } from './elements';
1314

1415
export type IMessage = {
1516
type: 'message' | 'command' | 'return',
@@ -22,6 +23,8 @@ class Console extends React.Component {
2223
messages: [],
2324
scrollToBottom: true,
2425
initialClear: true,
26+
filter: [],
27+
searchKeywords: '',
2528
};
2629

2730
listener;
@@ -104,6 +107,14 @@ class Console extends React.Component {
104107
}
105108
break;
106109
}
110+
case 'search-log': {
111+
this.setState({ searchKeywords: data.value });
112+
break;
113+
}
114+
case 'filter-log': {
115+
this.setState({ filter: data.filters });
116+
break;
117+
}
107118
default: {
108119
break;
109120
}
@@ -193,6 +204,7 @@ class Console extends React.Component {
193204
return null;
194205
}
195206

207+
const { messages, filter, searchKeywords } = this.state;
196208
return (
197209
<Container>
198210
<Messages
@@ -201,9 +213,11 @@ class Console extends React.Component {
201213
}}
202214
>
203215
<ConsoleFeed
204-
logs={this.state.messages}
216+
logs={messages}
205217
variant={this.props.theme.light ? 'light' : 'dark'}
206218
styles={inspectorTheme(this.props.theme)}
219+
filter={filter}
220+
searchKeywords={searchKeywords}
207221
/>
208222
</Messages>
209223
<Input evaluateConsole={this.evaluateConsole} />
@@ -212,6 +226,40 @@ class Console extends React.Component {
212226
}
213227
}
214228

229+
const ConsoleFilterInput = ({ style }) => (
230+
<FilterInput
231+
placeholder="Filter"
232+
style={style}
233+
onChange={({ target: { value } }) =>
234+
dispatch({ type: 'search-log', value })
235+
}
236+
/>
237+
);
238+
239+
const ConsoleFilterSelect = props => {
240+
const handleOnChange = ({ target: { value } }) => {
241+
if (value === 'all') {
242+
dispatch({ type: 'filter-log', filters: [] });
243+
} else {
244+
const filters = value === 'info' ? ['info', 'log'] : [value];
245+
dispatch({ type: 'filter-log', filters });
246+
}
247+
};
248+
249+
return (
250+
<Select
251+
style={{ ...props.style, borderColor: '#2c2e30' }}
252+
onChange={handleOnChange}
253+
>
254+
<option value="all">All</option>
255+
<option value="info">Info</option>
256+
<option value="warn">Warning</option>
257+
<option value="error">Error</option>
258+
<option value="debug">Debug</option>
259+
</Select>
260+
);
261+
};
262+
215263
export default {
216264
title: 'Console',
217265
Content: withTheme(Console),
@@ -223,5 +271,17 @@ export default {
223271
},
224272
Icon: ClearIcon,
225273
},
274+
{
275+
title: 'Search',
276+
onClick: () => {
277+
dispatch({ type: 'Search Click' });
278+
},
279+
Icon: withTheme(ConsoleFilterInput),
280+
},
281+
{
282+
title: 'Log Filter',
283+
onClick: () => {},
284+
Icon: withTheme(ConsoleFilterSelect),
285+
},
226286
],
227287
};

packages/app/src/app/components/Preview/DevTools/elements.js

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export const Actions = styled.div`
7373
position: absolute;
7474
right: 1rem;
7575
font-size: 1.125rem;
76+
display: inline-flex;
7677
7778
svg {
7879
margin: 0 0.5rem;

packages/sandbox-hooks/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"private": true,
55
"dependencies": {
66
"codesandbox-api": "^0.0.18",
7-
"console-feed": "^2.8.1"
7+
"console-feed": "^2.8.5"
88
}
99
}

yarn.lock

+4-13
Original file line numberDiff line numberDiff line change
@@ -6143,19 +6143,10 @@ console-control-strings@^1.0.0, console-control-strings@~1.1.0:
61436143
version "1.1.0"
61446144
resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e"
61456145

6146-
console-feed@^2.8.0:
6147-
version "2.8.3"
6148-
resolved "https://registry.yarnpkg.com/console-feed/-/console-feed-2.8.3.tgz#81c07b14c236033fe26d76d2b5b305c3345cae99"
6149-
dependencies:
6150-
emotion "^9.1.1"
6151-
emotion-theming "^9.0.0"
6152-
linkifyjs "^2.1.6"
6153-
react-emotion "^9.1.1"
6154-
react-inspector "^2.2.2"
6155-
6156-
console-feed@^2.8.1:
6157-
version "2.8.1"
6158-
resolved "https://registry.yarnpkg.com/console-feed/-/console-feed-2.8.1.tgz#2f20be4457bd63cd45309733ae1187c3331e9574"
6146+
console-feed@^2.8.5:
6147+
version "2.8.5"
6148+
resolved "https://registry.yarnpkg.com/console-feed/-/console-feed-2.8.5.tgz#d91c360faf79c73fbc774fc5175b9ebbe6e1ebb4"
6149+
integrity sha512-cUClwZUScfP/7OwOxu/7f+AuVr8mCNquG5s0UPiLq1VHI+TBoIeYOM7sjsHthJfmBNbOWf/B5NNOqP43OrHMBw==
61596150
dependencies:
61606151
emotion "^9.1.1"
61616152
emotion-theming "^9.0.0"

0 commit comments

Comments
 (0)