Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Finish second nav dropdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Segreto committed Oct 8, 2015
1 parent f2c497e commit a231c2a
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 3 deletions.
6 changes: 5 additions & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
margin-right: -21px; /* 20px padding + 1px border */
margin-bottom: 20px;
margin-left: -20px;
padding-right: 20px;
padding-left: 20px;
padding-right: 20px;
}
.dropdown {
padding-bottom: 10px;
padding-top: 10px;
}
.nav-sidebar > .active > a,
.nav-sidebar > .active > a:hover,
Expand Down
38 changes: 36 additions & 2 deletions static_src/components/navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default class Navbar extends React.Component {

render = () => {
var orgName = this.state.currentOrg && this.state.currentOrg.name || '',
orgEls = [];
orgEls = [],
navigation;

orgEls = this.state.orgs.map((org) => {
return {
Expand All @@ -38,12 +39,45 @@ export default class Navbar extends React.Component {
}
});

if (this.state.currentOrg) {
navigation = this._buildNav(this.state.currentOrg);
}

return (
<ul className="nav nav-sidebar">
<li>
<Dropdown title={ orgName } items={ orgEls } />
<Dropdown title='Change Organization' items={ orgEls } />
</li>
{ navigation }
</ul>
);
}

_buildNav = (org) => {
var navEls = [];

navEls.push({
key: 'spaces',
element: <a href={ '#/org/' + org.guid }>Spaces</a>
});

navEls.push({
key: 'marketplace',
element: <a href={ '#/org/' + org.guid + 'marketplace' }>Marketplace</a>
});

navEls.push({
key: 'manage_org',
element: <a href={ '#/org/' + org.guid + 'manage-org' }>Manage Org</a>
});
let navigation = (
<li>
<Dropdown title={ this.state.currentOrg.name.toUpperCase() || '' }
items={ navEls } />
</li>
);

return navigation;
}

};
21 changes: 21 additions & 0 deletions static_src/stores/space_store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

import AppDispatcher from '../dispatcher';
import BaseStore from './base_store.js';
import cfApi from '../util/cf_api.js';

class SpaceStore extends BaseStore {
constructor() {
super();
this._data = [];
}

get(guid) {
return this._data.find((space) => {
return space.guid === guid;
});
}
}

let _SpaceStore = new SpaceStore();

export default _SpaceStore;
40 changes: 40 additions & 0 deletions static_src/test/unit/stores/space_store.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

import '../../global_setup.js';

import AppDispatcher from '../../../dispatcher.js';
import SpaceStore from '../../../stores/space_store.js';
import { spaceActionTypes } from '../../../constants';

describe('SpaceStore', () => {
var sandbox;

beforeEach(() => {
SpaceStore._data = [];
sandbox = sinon.sandbox.create();
});

afterEach(() => {
sandbox.restore();
});

describe('constructor()', () => {
it('should set _data to empty array', () => {
expect(SpaceStore._data).toBeEmptyArray();
});
});

describe('get()', () => {
it('should return the correct space based on guid', () => {
var testSpaces = [
{ guid: 'sp1xxa', name: 'testSpaceA', apps: [] },
{ guid: 'sp1xxb', name: 'testSpaceB', apps: [] }
];

SpaceStore._data = testSpaces;

let actual = SpaceStore.get(testSpaces[0].guid);

expect(actual).toEqual(testSpaces[0]);
});
});
});

0 comments on commit a231c2a

Please sign in to comment.