Skip to content

Commit bd96cb8

Browse files
committed
nav bar implementation
Signed-off-by: smarcet <smarcet@gmail.com> Nav bar css tweaks Signed-off-by: smarcet <smarcet@gmail.com> Updated nav bar widget version Signed-off-by: smarcet <smarcet@gmail.com> NavBar css tweaks Signed-off-by: smarcet <smarcet@gmail.com> Nav Bar CSS Tweaks Signed-off-by: smarcet <smarcet@gmail.com> Navbar CSS tweaks Signed-off-by: smarcet <smarcet@gmail.com>
1 parent 0b02645 commit bd96cb8

18 files changed

Lines changed: 2092 additions & 11 deletions

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12.22.11

navbar/_config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+

navbar/ui/package-lock.json

Lines changed: 1683 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

navbar/ui/package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "navbar",
3+
"version": "0.0.1",
4+
"description": "",
5+
"private": true,
6+
"scripts": {
7+
"start": "webpack-dashboard -- node server.js",
8+
"build": "NODE_ENV=production webpack",
9+
"test": "mocha source/js/tests --compilers js:babel-core/register --recursive"
10+
},
11+
"dependencies": {
12+
"array.prototype.find": "^2.0.0",
13+
"array.prototype.findindex": "^2.0.0",
14+
"babel-polyfill": "^6.16.0",
15+
"babel-preset-es2015": "^6.14.0",
16+
"babel-preset-react": "^6.11.1",
17+
"babel-preset-stage-2": "^6.18.0",
18+
"babel-preset-stage-3": "^6.17.0",
19+
"classnames": "^2.1.5",
20+
"dataset": "^0.3.1",
21+
"object-assign": "^4.0.1",
22+
"react": "^16.8.4",
23+
"react-dom": "^16.4.1",
24+
"react-addons-css-transition-group": "^0.14.7",
25+
"react-bootstrap": "^0.28.3",
26+
"react-helmet": "^3.0.1",
27+
"react-redux": "^4.4",
28+
"redux": "^3.0",
29+
"redux-actions": "^0.7.0",
30+
"redux-promise": "^0.5.0",
31+
"redux-thunk": "^1.0.3",
32+
"superagent": "^1.3.0",
33+
"navigation-widget": "^1.0.12"
34+
},
35+
"devDependencies": {}
36+
}

navbar/ui/source/actions.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import {
2+
getRequest,
3+
createAction, startLoading, stopLoading, showMessage,
4+
} from 'openstack-uicore-foundation/lib/methods';
5+
6+
export const RECEIVE_SPONSORED_PROJECTS = 'RECEIVE_SPONSORED_PROJECTS';
7+
export const REQUEST_SPONSORED_PROJECTS = 'REQUEST_SPONSORED_PROJECTS';
8+
9+
export const errorHandler = (err, res) => (dispatch) => {
10+
let code = err.status;
11+
let msg = '';
12+
let error_message = {};
13+
14+
switch (code) {
15+
case 404: {
16+
let messages = err.response.body.messages;
17+
for (var i in messages) {
18+
msg += '- ' + messages[i].message + '<br>';
19+
}
20+
21+
error_message = {
22+
title: 'Not Found',
23+
html: msg,
24+
type: 'error'
25+
};
26+
27+
dispatch(showMessage(error_message));
28+
}
29+
break;
30+
case 412: {
31+
let messages = err.response.body.messages;
32+
for (var i in messages) {
33+
msg += '- ' + messages[i].message + '<br>';
34+
}
35+
36+
error_message = {
37+
title: 'Validation error',
38+
html: msg,
39+
type: 'error'
40+
};
41+
dispatch(showMessage(error_message));
42+
}
43+
break;
44+
default:
45+
error_message = {
46+
title: 'ERROR',
47+
html: 'Server Error',
48+
type: 'error'
49+
};
50+
dispatch(showMessage( error_message ));
51+
}
52+
}
53+
54+
export const fetchAll = () => (dispatch) => {
55+
56+
dispatch(startLoading());
57+
58+
let params = {
59+
page: 1,
60+
per_page: 100,
61+
};
62+
63+
const baseUrl = window.navBarConfig.baseApiUrl;
64+
65+
return getRequest(
66+
null,
67+
createAction(RECEIVE_SPONSORED_PROJECTS),
68+
`${baseUrl}/api/public/v1/sponsored-projects`,
69+
errorHandler
70+
)({})(dispatch).then(() => {
71+
dispatch(stopLoading());
72+
}
73+
);
74+
}
75+
76+

navbar/ui/source/app.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react'
2+
import NavigationWidget from 'navigation-widget/dist';
3+
import 'navigation-widget/dist/index.css';
4+
//import ProjectsData from "./data.json";
5+
import {connect} from "react-redux";
6+
import {
7+
fetchAll,
8+
9+
} from "./actions";
10+
11+
class App extends React.Component {
12+
13+
componentDidMount() {
14+
let {projects, fetchAll} = this.props;
15+
if(!projects.length) {
16+
fetchAll();
17+
}
18+
}
19+
20+
render(){
21+
22+
let {projects} = this.props;
23+
24+
if(!projects.length) return null;
25+
26+
const widgetProps = {
27+
projects: projects,
28+
currentProject: window.navBarConfig.currentProject,
29+
containerClass: "container",
30+
};
31+
32+
return (
33+
<NavigationWidget {...widgetProps} />
34+
);
35+
}
36+
}
37+
38+
const mapStateToProps = (state) => ({
39+
...state
40+
})
41+
42+
export default connect (
43+
mapStateToProps,
44+
{
45+
fetchAll,
46+
}
47+
)(App);
48+

navbar/ui/source/data.json

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
[{
2+
"id": 1,
3+
"created": 1630500453,
4+
"last_edited": 1630500453,
5+
"name": "OpenInfra Foundation",
6+
"description": "",
7+
"slug": "openinfra-foundation",
8+
"is_active": true,
9+
"nav_bar_title": "An OpenInfra Project",
10+
"should_show_on_nav_bar": true,
11+
"learn_more_link": "https://openinfra.dev/learn_more",
12+
"learn_more_text": "Learn More Test",
13+
"site_url": "https://openinfra.dev/",
14+
"logo_url": "https://object-storage.public.mtl1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-assets-dev/sponsored-projects/1/logos/osf.svg",
15+
"sponsorship_types": [1, 2, 3, 4, 5, 6]
16+
}, {
17+
"id": 2,
18+
"created": 1657636447,
19+
"last_edited": 1657636447,
20+
"name": "Airship",
21+
"description": "<p>Automated cloud provisioning and life cycle management </p>",
22+
"slug": "airship",
23+
"is_active": true,
24+
"nav_bar_title": "Airship",
25+
"should_show_on_nav_bar": true,
26+
"learn_more_link": "https://www.airshipit.org/",
27+
"learn_more_text": "About AirShip",
28+
"site_url": "https://www.airshipit.org/",
29+
"logo_url": "https://object-storage.public.mtl1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-assets-dev/sponsored-projects/2/logos/images1.png",
30+
"sponsorship_types": []
31+
}, {
32+
"id": 3,
33+
"created": 1657658595,
34+
"last_edited": 1657658595,
35+
"name": "Kata Containers",
36+
"description": "<p>Secure, lightweight, virtualized containers</p>",
37+
"slug": "kata-containers",
38+
"is_active": true,
39+
"nav_bar_title": "Kata Containers",
40+
"should_show_on_nav_bar": true,
41+
"learn_more_link": "https://katacontainers.io/",
42+
"learn_more_text": "About Kata Containers",
43+
"site_url": "https://katacontainers.io/",
44+
"logo_url": "https://object-storage.public.mtl1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-assets-dev/sponsored-projects/3/logos/1-6w7oXmCt9YgOy1J06savyA.png",
45+
"sponsorship_types": []
46+
}, {
47+
"id": 4,
48+
"created": 1657658720,
49+
"last_edited": 1657658720,
50+
"name": "OpenStack",
51+
"description": "<p>Programmable infrastructure for VMs, containers and bare metal</p>",
52+
"slug": "openstack",
53+
"is_active": true,
54+
"nav_bar_title": "OpenStack",
55+
"should_show_on_nav_bar": true,
56+
"learn_more_link": "https://www.openstack.org/",
57+
"learn_more_text": "About OpenStack",
58+
"site_url": "https://www.openstack.org/",
59+
"logo_url": "https://object-storage.public.mtl1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-assets-dev/sponsored-projects/4/logos/download9.png",
60+
"sponsorship_types": []
61+
}, {
62+
"id": 5,
63+
"created": 1657658844,
64+
"last_edited": 1657658844,
65+
"name": "OpenInfra Labs",
66+
"description": "<p>Connecting open source projects to production</p>",
67+
"slug": "openinfra-labs",
68+
"is_active": true,
69+
"nav_bar_title": "OpenInfra Labs",
70+
"should_show_on_nav_bar": true,
71+
"learn_more_link": "https://openinfralabs.org/",
72+
"learn_more_text": "About OpenInfra Labs",
73+
"site_url": "https://openinfralabs.org/",
74+
"logo_url": "https://object-storage.public.mtl1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-assets-dev/sponsored-projects/5/logos/download-11.png",
75+
"sponsorship_types": []
76+
}, {
77+
"id": 6,
78+
"created": 1657658939,
79+
"last_edited": 1657658939,
80+
"name": "StarlingX",
81+
"description": "<p>Cloud computing for ultra-low latency applications</p>",
82+
"slug": "starlingx",
83+
"is_active": true,
84+
"nav_bar_title": "StarlingX",
85+
"should_show_on_nav_bar": true,
86+
"learn_more_link": "https://www.starlingx.io/",
87+
"learn_more_text": "About StarlingX",
88+
"site_url": "https://www.starlingx.io/",
89+
"logo_url": "https://object-storage.public.mtl1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-assets-dev/sponsored-projects/6/logos/android-chrome-192x192.png",
90+
"sponsorship_types": []
91+
}, {
92+
"id": 7,
93+
"created": 1657659020,
94+
"last_edited": 1657659020,
95+
"name": "Zuul",
96+
"description": "<p>CI/CD platform for gating changes across repos</p>",
97+
"slug": "zuul",
98+
"is_active": true,
99+
"nav_bar_title": "Zuul",
100+
"should_show_on_nav_bar": true,
101+
"learn_more_link": "https://zuul-ci.org/",
102+
"learn_more_text": "About Zuul",
103+
"site_url": "https://zuul-ci.org/",
104+
"logo_url": "https://object-storage.public.mtl1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-assets-dev/sponsored-projects/7/logos/android-chrome-192x192-1.png",
105+
"sponsorship_types": []
106+
}]

navbar/ui/source/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*eslint-disable */
2+
import React from 'react';
3+
import { render } from 'react-dom';
4+
import { Provider } from 'react-redux';
5+
const containerId = 'nav_container';
6+
import store from './store';
7+
import App from './app';
8+
9+
document.addEventListener('DOMContentLoaded', function init() {
10+
if (document.getElementById(containerId)) {
11+
render(
12+
<Provider store={store}>
13+
<App />
14+
</Provider>,
15+
document.getElementById(containerId)
16+
);
17+
}
18+
});

navbar/ui/source/reducers.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright 2022 OpenStack Foundation
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
**/
13+
14+
import {RECEIVE_SPONSORED_PROJECTS} from './actions';
15+
16+
export const appReducer = (
17+
state = {
18+
projects:[]
19+
},
20+
action = {}
21+
) => {
22+
switch(action.type){
23+
case RECEIVE_SPONSORED_PROJECTS:
24+
{
25+
const { response } = action.payload;
26+
return {
27+
...state,
28+
projects: response.data,
29+
}
30+
}
31+
break;
32+
33+
default:
34+
return state;
35+
}
36+
};

navbar/ui/source/store.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright 2022 OpenStack Foundation
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
**/
13+
14+
import { createStore, applyMiddleware, combineReducers, compose} from 'redux';
15+
import reduceReducers from 'reduce-reducers';
16+
import thunk from 'redux-thunk';
17+
import { appReducer } from './reducers';
18+
import { genericReducers } from "~core-utils/reducers";
19+
20+
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
21+
22+
let reducer = reduceReducers(appReducer, genericReducers);
23+
const store = createStore(reducer, composeEnhancers(applyMiddleware(thunk)));
24+
25+
export default store;

0 commit comments

Comments
 (0)