mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-26 13:48:33 +02:00
fix: read unleash version from ui-config (#219)
This commit is contained in:
parent
d7ae641274
commit
0d3cbd8294
@ -1,8 +1,8 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`renders correctly with details 1`] = `
|
exports[`renders correctly with empty version 1`] = `
|
||||||
<react-mdl-FooterSection
|
<react-mdl-FooterSection
|
||||||
logo="Unleash 1.1.0"
|
logo="Unleash "
|
||||||
type="bottom"
|
type="bottom"
|
||||||
>
|
>
|
||||||
<small>
|
<small>
|
||||||
@ -15,9 +15,9 @@ exports[`renders correctly with details 1`] = `
|
|||||||
</react-mdl-FooterSection>
|
</react-mdl-FooterSection>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`renders correctly with empty api details 1`] = `
|
exports[`renders correctly with ui-config 1`] = `
|
||||||
<react-mdl-FooterSection
|
<react-mdl-FooterSection
|
||||||
logo="Unleash "
|
logo="Unleash 1.1.0"
|
||||||
type="bottom"
|
type="bottom"
|
||||||
>
|
>
|
||||||
<small>
|
<small>
|
||||||
|
@ -5,28 +5,36 @@ import renderer from 'react-test-renderer';
|
|||||||
|
|
||||||
jest.mock('react-mdl');
|
jest.mock('react-mdl');
|
||||||
|
|
||||||
const uiConfig = {
|
test('renders correctly with empty version', () => {
|
||||||
slogan: 'We are the best!',
|
const uiConfig = {
|
||||||
environment: 'test',
|
name: 'Unleash',
|
||||||
};
|
slogan: 'We are the best!',
|
||||||
|
environment: 'test',
|
||||||
|
version: '',
|
||||||
|
};
|
||||||
|
|
||||||
test('renders correctly with empty api details', () => {
|
const tree = renderer.create(<ShowApiDetailsComponent uiConfig={uiConfig} />).toJSON();
|
||||||
const tree = renderer
|
|
||||||
.create(<ShowApiDetailsComponent fetchAll={jest.fn()} apiDetails={{}} uiConfig={uiConfig} />)
|
|
||||||
.toJSON();
|
|
||||||
expect(tree).toMatchSnapshot();
|
expect(tree).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('renders correctly with details', () => {
|
test('renders correctly with ui-config', () => {
|
||||||
const tree = renderer
|
const uiConfig = {
|
||||||
.create(<ShowApiDetailsComponent fetchAll={jest.fn()} apiDetails={{ version: '1.1.0' }} uiConfig={uiConfig} />)
|
name: 'Unleash',
|
||||||
.toJSON();
|
slogan: 'We are the best!',
|
||||||
|
environment: 'test',
|
||||||
|
version: '1.1.0',
|
||||||
|
};
|
||||||
|
|
||||||
|
const tree = renderer.create(<ShowApiDetailsComponent uiConfig={uiConfig} />).toJSON();
|
||||||
expect(tree).toMatchSnapshot();
|
expect(tree).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('renders correctly without uiConfig', () => {
|
test('renders correctly without uiConfig', () => {
|
||||||
const tree = renderer
|
const uiConfig = {
|
||||||
.create(<ShowApiDetailsComponent fetchAll={jest.fn()} apiDetails={{ version: '1.1.0' }} uiConfig={{}} />)
|
name: 'Unleash',
|
||||||
.toJSON();
|
version: '1.1.0',
|
||||||
|
};
|
||||||
|
|
||||||
|
const tree = renderer.create(<ShowApiDetailsComponent uiConfig={uiConfig} />).toJSON();
|
||||||
expect(tree).toMatchSnapshot();
|
expect(tree).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
@ -4,21 +4,14 @@ import { FooterSection } from 'react-mdl';
|
|||||||
|
|
||||||
class ShowApiDetailsComponent extends Component {
|
class ShowApiDetailsComponent extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
apiDetails: PropTypes.object.isRequired,
|
|
||||||
uiConfig: PropTypes.object.isRequired,
|
uiConfig: PropTypes.object.isRequired,
|
||||||
fetchAll: PropTypes.func.isRequired,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.props.fetchAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const version = this.props.apiDetails.version || '';
|
const { slogan, environment, version, name } = this.props.uiConfig;
|
||||||
const { slogan, environment } = this.props.uiConfig;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FooterSection type="bottom" logo={`Unleash ${version}`}>
|
<FooterSection type="bottom" logo={`${name} ${version}`}>
|
||||||
<small>{environment ? `(${environment})` : ''}</small>
|
<small>{environment ? `(${environment})` : ''}</small>
|
||||||
<br />
|
<br />
|
||||||
<small>{slogan}</small>
|
<small>{slogan}</small>
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import ShowApiDetailsComponent from './show-api-details-component';
|
import ShowApiDetailsComponent from './show-api-details-component';
|
||||||
import { fetchAll } from '../../store/api/actions';
|
|
||||||
|
|
||||||
const mapDispatchToProps = {
|
const mapDispatchToProps = {};
|
||||||
fetchAll,
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
apiDetails: state.api.toJS(),
|
|
||||||
uiConfig: state.uiConfig.toJS(),
|
uiConfig: state.uiConfig.toJS(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ class AuthComponent extends React.Component {
|
|||||||
unsecureLogin={this.props.unsecureLogin}
|
unsecureLogin={this.props.unsecureLogin}
|
||||||
authDetails={authDetails}
|
authDetails={authDetails}
|
||||||
fetchFeatureToggles={this.props.fetchFeatureToggles}
|
fetchFeatureToggles={this.props.fetchFeatureToggles}
|
||||||
|
fetchUIConfig={this.props.fetchUIConfig}
|
||||||
history={this.props.history}
|
history={this.props.history}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -7,6 +7,7 @@ class SimpleAuthenticationComponent extends React.Component {
|
|||||||
authDetails: PropTypes.object.isRequired,
|
authDetails: PropTypes.object.isRequired,
|
||||||
unsecureLogin: PropTypes.func.isRequired,
|
unsecureLogin: PropTypes.func.isRequired,
|
||||||
fetchFeatureToggles: PropTypes.func.isRequired,
|
fetchFeatureToggles: PropTypes.func.isRequired,
|
||||||
|
fetchUIConfig: PropTypes.func.isRequired,
|
||||||
history: PropTypes.object.isRequired,
|
history: PropTypes.object.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ class SimpleAuthenticationComponent extends React.Component {
|
|||||||
this.props
|
this.props
|
||||||
.unsecureLogin(path, user)
|
.unsecureLogin(path, user)
|
||||||
.then(this.props.fetchFeatureToggles)
|
.then(this.props.fetchFeatureToggles)
|
||||||
|
.then(this.props.fetchUIConfig)
|
||||||
.then(() => this.props.history.push(`/`));
|
.then(() => this.props.history.push(`/`));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
import { throwIfNotSuccess, headers } from './helper';
|
|
||||||
|
|
||||||
const URI = 'api';
|
|
||||||
|
|
||||||
function fetchAll() {
|
|
||||||
return fetch(URI, { headers, credentials: 'include' })
|
|
||||||
.then(throwIfNotSuccess)
|
|
||||||
.then(response => response.json());
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
fetchAll,
|
|
||||||
};
|
|
@ -1,18 +0,0 @@
|
|||||||
import apiReducer from '../index';
|
|
||||||
import { RECIEVE_API_DETAILS } from '../actions';
|
|
||||||
|
|
||||||
test('should have inital state', () => {
|
|
||||||
const store = apiReducer(undefined, {});
|
|
||||||
expect(store.toJS()).toEqual({});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should have new state', () => {
|
|
||||||
const store = apiReducer(undefined, { type: RECIEVE_API_DETAILS, value: { version: '1.1.1' } });
|
|
||||||
expect(store.toJS()).toEqual({ version: '1.1.1' });
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should have updated state', () => {
|
|
||||||
const inital = apiReducer(undefined, { type: RECIEVE_API_DETAILS, value: { version: '1.1.1' } });
|
|
||||||
const store = apiReducer(inital, { type: RECIEVE_API_DETAILS, value: { version: '1.2.1' } });
|
|
||||||
expect(store.toJS()).toEqual({ version: '1.2.1' });
|
|
||||||
});
|
|
@ -1,24 +0,0 @@
|
|||||||
import api from '../../data/api';
|
|
||||||
|
|
||||||
export const RECIEVE_API_DETAILS = 'RECIEVE_API_DETAILS';
|
|
||||||
export const ERROR_RECIEVE_API_DETAILS = 'ERROR_RECIEVE_API_DETAILS';
|
|
||||||
|
|
||||||
export const RECEIVE_APPLICATION = 'RECEIVE_APPLICATION';
|
|
||||||
|
|
||||||
const recieveApiDetails = json => ({
|
|
||||||
type: RECIEVE_API_DETAILS,
|
|
||||||
value: json,
|
|
||||||
});
|
|
||||||
|
|
||||||
const errorRecieveApiDetails = (statusCode, type = ERROR_RECIEVE_API_DETAILS) => ({
|
|
||||||
type,
|
|
||||||
statusCode,
|
|
||||||
});
|
|
||||||
|
|
||||||
export function fetchAll() {
|
|
||||||
return dispatch =>
|
|
||||||
api
|
|
||||||
.fetchAll()
|
|
||||||
.then(json => dispatch(recieveApiDetails(json)))
|
|
||||||
.catch(error => dispatch(errorRecieveApiDetails(error)));
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
import { Map } from 'immutable';
|
|
||||||
import { RECIEVE_API_DETAILS } from './actions';
|
|
||||||
|
|
||||||
const store = (state = new Map(), action) => {
|
|
||||||
switch (action.type) {
|
|
||||||
case RECIEVE_API_DETAILS:
|
|
||||||
state = new Map(action.value);
|
|
||||||
return state;
|
|
||||||
default:
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default store;
|
|
@ -9,7 +9,6 @@ import error from './error-store';
|
|||||||
import clientInstances from './client-instance-store';
|
import clientInstances from './client-instance-store';
|
||||||
import settings from './settings';
|
import settings from './settings';
|
||||||
import user from './user';
|
import user from './user';
|
||||||
import api from './api';
|
|
||||||
import applications from './application';
|
import applications from './application';
|
||||||
import uiConfig from './ui-config';
|
import uiConfig from './ui-config';
|
||||||
import context from './context';
|
import context from './context';
|
||||||
@ -27,7 +26,6 @@ const unleashStore = combineReducers({
|
|||||||
user,
|
user,
|
||||||
applications,
|
applications,
|
||||||
uiConfig,
|
uiConfig,
|
||||||
api,
|
|
||||||
context,
|
context,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -18,7 +18,9 @@ Object {
|
|||||||
"value": "GitHub",
|
"value": "GitHub",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"name": "Unleash",
|
||||||
"slogan": "The enterprise ready feature toggle service.",
|
"slogan": "The enterprise ready feature toggle service.",
|
||||||
|
"version": "3.x",
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -40,7 +42,9 @@ Object {
|
|||||||
"value": "GitHub",
|
"value": "GitHub",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"name": "Unleash",
|
||||||
"slogan": "hello",
|
"slogan": "hello",
|
||||||
|
"version": "3.x",
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -62,6 +66,8 @@ Object {
|
|||||||
"value": "GitHub",
|
"value": "GitHub",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"name": "Unleash",
|
||||||
"slogan": "The enterprise ready feature toggle service.",
|
"slogan": "The enterprise ready feature toggle service.",
|
||||||
|
"version": "3.x",
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@ -11,6 +11,8 @@ const UI_CONFIG = `${basePath}:ui_config`;
|
|||||||
|
|
||||||
const DEFAULT = new $Map({
|
const DEFAULT = new $Map({
|
||||||
headerBackground: undefined,
|
headerBackground: undefined,
|
||||||
|
name: 'Unleash',
|
||||||
|
version: '3.x',
|
||||||
environment: '',
|
environment: '',
|
||||||
slogan: 'The enterprise ready feature toggle service.',
|
slogan: 'The enterprise ready feature toggle service.',
|
||||||
links: [
|
links: [
|
||||||
|
Loading…
Reference in New Issue
Block a user