Skip to content

Commit

Permalink
feature(castro): basic code browsing layout
Browse files Browse the repository at this point in the history
fix #15
  • Loading branch information
WangQianliang authored and zfy0701 committed Jul 3, 2018
1 parent 4ca28cf commit eecfcf8
Show file tree
Hide file tree
Showing 11 changed files with 209 additions and 5 deletions.
2 changes: 2 additions & 0 deletions kibana-extra/castro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"popper.js": "^1.14.3",
"react-dom": "^16.4.1",
"react-redux": "^5.0.7",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"redux": "^4.0.0",
"redux-actions": "^2.4.0",
"redux-saga": "^0.16.0"
Expand Down
4 changes: 2 additions & 2 deletions kibana-extra/castro/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { render, unmountComponentAtNode } from 'react-dom';

import 'ui/autoload/styles';
import './less/main.less';
import { Main } from './components/main';
import App from './components/App';
import store from './stores';

const app = uiModules.get("apps/castro");
Expand All @@ -28,7 +28,7 @@ function RootController($scope: any, $element: any, $http: any) {
// render react to DOM
render(
<Provider store={store}>
<Main title="castro" httpClient={$http} />
<App title="castro" httpClient={$http} />
</Provider>,
domNode
);
Expand Down
16 changes: 16 additions & 0 deletions kibana-extra/castro/public/components/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { HashRouter as Router, Route } from 'react-router-dom';

import { Main } from './main';
import Layout from './Layout/Layout';

export default props => {
return (
<Router>
<div>
<Route path="/" exact render={() => <Main {...props} />}/>
<Route path="/codebrowsing" component={Layout} />
</div>
</Router>
);
};
3 changes: 3 additions & 0 deletions kibana-extra/castro/public/components/Layout/CodeBlock.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.codeBlock {
height: 100%;
}
26 changes: 26 additions & 0 deletions kibana-extra/castro/public/components/Layout/CodeBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';

import { EuiCodeBlock } from '@elastic/eui';

import './CodeBlock.css'

const codeSnippet = `var y = function(le) {
return function(f) {
return f(f);
}(function(f) {
return le(
function(x) { return (f(f))(x); }
);
});
};`;

export default class CodeBlock extends React.PureComponent {
static defaultProps = {
code: codeSnippet,
language: 'js'
};

public render() {
return <EuiCodeBlock language={this.props.language} className="codeBlock">{this.props.code}</EuiCodeBlock>
}
}
34 changes: 34 additions & 0 deletions kibana-extra/castro/public/components/Layout/DirectoryTree.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { EuiSideNav, EuiIcon } from '@elastic/eui';

import directoryTree from './mockData/directoreTree';

function to (node) {
const data = {
id: node.name,
name: node.name,
isSelected: true,
onClick: () => {
//link to file path
console.log(node.path)
}
}
if(!node.is_simple && node.obj_type === 2) {
data.icon = <EuiIcon type="arrowRight"/>
}
if (node.children && node.children.length > 0) {
data.items = node.children.map(to);
}
return data
}

export default class DirectoryTree extends React.PureComponent {
public render() {
const items= directoryTree.children.map(to);
console.log(items, directoryTree)
return <EuiSideNav
items={items}
style={{ width: 192 }}
/>
}
}
49 changes: 49 additions & 0 deletions kibana-extra/castro/public/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';

import {
EuiHeader,
EuiHeaderBreadcrumbs,
EuiHeaderSection,
EuiHeaderSectionItem,
EuiHeaderSectionItemButton,
EuiHeaderLogo,
EuiIcon,
EuiSideNav,
EuiFlexGroup,
EuiFlexItem
} from '@elastic/eui';

import DirectoryTree from './DirectoryTree';
import CodeBlock from './CodeBlock';

export default class Layout extends React.Component {
public render() {
return <div><EuiHeader>
<EuiHeaderSection>
<EuiHeaderSectionItem border="right">
<EuiHeaderLogo>Code Browsing</EuiHeaderLogo>
</EuiHeaderSectionItem>

</EuiHeaderSection>

<EuiHeaderSection side="right">
<EuiHeaderSectionItemButton aria-label="Search">
<EuiIcon
type="search"
size="m"
/>
</EuiHeaderSectionItemButton>
</EuiHeaderSection>
</EuiHeader>
<EuiFlexGroup>
<EuiFlexItem style={{ maxWidth: 300 }}>
<DirectoryTree />
</EuiFlexItem>

<EuiFlexItem>
<CodeBlock />
</EuiFlexItem>
</EuiFlexGroup>
</div>
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const json = JSON.parse(`
{"name":"","path":"","obj_type":2,"children":[{"name":".env","path":".env","obj_type":3,"is_simple":false},{"name":".gitignore","path":".gitignore","obj_type":3,"is_simple":false},{"name":"CHANGES","path":"CHANGES","obj_type":3,"is_simple":false},{"name":"cn-lambda-compose","path":"cn-lambda-compose","obj_type":3,"is_simple":false},{"name":"cn-lambda-compose-dis","path":"cn-lambda-compose-dis","obj_type":3,"is_simple":false},{"name":"configs","path":"configs/","obj_type":2,"children":[],"is_simple":false},{"name":"docker-compose-distributed.yml","path":"docker-compose-distributed.yml","obj_type":3,"is_simple":false},{"name":"docker-compose-editorserver.yml","path":"docker-compose-editorserver.yml","obj_type":3,"is_simple":false},{"name":"docker-compose.yml","path":"docker-compose.yml","obj_type":3,"is_simple":false},{"name":"docs","path":"docs/","obj_type":2,"children":[],"is_simple":false},{"name":"jaas.conf","path":"jaas.conf","obj_type":3,"is_simple":false},{"name":"lambda-compose","path":"lambda-compose","obj_type":3,"is_simple":false},{"name":"lambda-compose-dis","path":"lambda-compose-dis","obj_type":3,"is_simple":false},{"name":"lambda-compose-editorserver","path":"lambda-compose-editorserver","obj_type":3,"is_simple":false},{"name":"scripts","path":"scripts/","obj_type":2,"children":[],"is_simple":false},{"name":"thirdparty","path":"thirdparty/","obj_type":2,"children":[],"is_simple":false},{"name":"tools","path":"tools/","obj_type":2,"children":[],"is_simple":false},{"name":"upgrade","path":"upgrade","obj_type":3,"is_simple":false}],"is_simple":false}
`);

export default json;
6 changes: 5 additions & 1 deletion kibana-extra/castro/public/components/main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import {
EuiAccordion,
EuiCodeBlock,
EuiCode,
EuiSpacer
EuiSpacer,
EuiButton
} from "@elastic/eui";

import { Link } from 'react-router-dom';

import { Commit, Entry } from '../../../../../model/build/swagger-code-tsClient/api';
import FileCode from './FileCode';
import Code from './code';
Expand Down Expand Up @@ -58,6 +61,7 @@ export class Main extends React.Component<MainProps, MainState> {
<EuiTitle size="l">
<h1>Hello {title}!</h1>
</EuiTitle>
<EuiButton><Link to="/codebrowsing">browsing code</Link></EuiButton>
</EuiPageHeader>
<EuiPageBody>
<EuiPageContent>
Expand Down
67 changes: 65 additions & 2 deletions kibana-extra/castro/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,16 @@ highlights@^3.1.1:
underscore-plus "^1.5.1"
yargs "^4.7.1"

history@^4.7.2:
version "4.7.2"
resolved "https://registry.yarnpkg.com/history/-/history-4.7.2.tgz#22b5c7f31633c5b8021c7f4a8a954ac139ee8d5b"
dependencies:
invariant "^2.2.1"
loose-envify "^1.2.0"
resolve-pathname "^2.2.0"
value-equal "^0.4.0"
warning "^3.0.0"

hmac-drbg@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"
Expand Down Expand Up @@ -2428,7 +2438,7 @@ interpret@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614"

invariant@^2.0.0, invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2:
invariant@^2.0.0, invariant@^2.2.0, invariant@^2.2.1, invariant@^2.2.2, invariant@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
dependencies:
Expand Down Expand Up @@ -2707,6 +2717,10 @@ is-windows@^1.0.1, is-windows@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"

isarray@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"

isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
Expand Down Expand Up @@ -3007,7 +3021,7 @@ longest@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"

loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.0, loose-envify@^1.3.1:
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.0, loose-envify@^1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
dependencies:
Expand Down Expand Up @@ -3673,6 +3687,12 @@ path-parse@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"

path-to-regexp@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
dependencies:
isarray "0.0.1"

path-type@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441"
Expand Down Expand Up @@ -3946,6 +3966,29 @@ react-redux@^5.0.7:
loose-envify "^1.1.0"
prop-types "^15.6.0"

react-router-dom@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-4.3.1.tgz#4c2619fc24c4fa87c9fd18f4fb4a43fe63fbd5c6"
dependencies:
history "^4.7.2"
invariant "^2.2.4"
loose-envify "^1.3.1"
prop-types "^15.6.1"
react-router "^4.3.1"
warning "^4.0.1"

react-router@^4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-4.3.1.tgz#aada4aef14c809cb2e686b05cee4742234506c4e"
dependencies:
history "^4.7.2"
hoist-non-react-statics "^2.5.0"
invariant "^2.2.4"
loose-envify "^1.3.1"
path-to-regexp "^1.7.0"
prop-types "^15.6.1"
warning "^4.0.1"

react-virtualized@^9.18.5:
version "9.19.1"
resolved "http://registry.npm.taobao.org/react-virtualized/download/react-virtualized-9.19.1.tgz#84b53253df2d9df61c85ce037141edccc70a73fd"
Expand Down Expand Up @@ -4154,6 +4197,10 @@ resolve-options@^1.1.0:
dependencies:
value-or-function "^3.0.0"

resolve-pathname@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-2.2.0.tgz#7e9ae21ed815fd63ab189adeee64dc831eefa879"

resolve-url@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
Expand Down Expand Up @@ -4921,6 +4968,10 @@ validate-npm-package-license@^3.0.1:
spdx-correct "^3.0.0"
spdx-expression-parse "^3.0.0"

value-equal@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.4.0.tgz#c5bdd2f54ee093c04839d71ce2e4758a6890abc7"

value-or-function@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/value-or-function/-/value-or-function-3.0.0.tgz#1c243a50b595c1be54a754bfece8563b9ff8d813"
Expand Down Expand Up @@ -5016,6 +5067,18 @@ walkdir@0.0.11:
version "0.0.11"
resolved "https://registry.yarnpkg.com/walkdir/-/walkdir-0.0.11.tgz#a16d025eb931bd03b52f308caed0f40fcebe9532"

warning@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/warning/-/warning-3.0.0.tgz#32e5377cb572de4ab04753bdf8821c01ed605b7c"
dependencies:
loose-envify "^1.0.0"

warning@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/warning/-/warning-4.0.1.tgz#66ce376b7fbfe8a887c22bdf0e7349d73d397745"
dependencies:
loose-envify "^1.0.0"

watchpack@^1.4.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.0.tgz#4bc12c2ebe8aa277a71f1d3f14d685c7b446cd00"
Expand Down
2 changes: 2 additions & 0 deletions lsp-proxy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist

0 comments on commit eecfcf8

Please sign in to comment.