Skip to content

Commit

Permalink
Merge pull request #7 from taban03/development
Browse files Browse the repository at this point in the history
Added description and version on the Dashboard
  • Loading branch information
lamgibrcom authored Oct 15, 2019
2 parents d06a067 + 70741dd commit 040a68a
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 112 deletions.
35 changes: 35 additions & 0 deletions frontend/src/actions/catalog-tile-actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
FETCH_TILES_STOP,
FETCH_TILES_SUCCESS,
} from '../constants/catalog-tile-constants';
import { ZOWE_VERSION_ERROR, ZOWE_VERSION_SUCCESS } from '../constants/zowe-versions-contants';

const fetchRetryToastId = 9998;

Expand Down Expand Up @@ -53,3 +54,37 @@ export function fetchTilesStart(id) {
payload: id,
};
}

export function fetchZoweVersionSuccess(version) {
return {
type: ZOWE_VERSION_SUCCESS,
version,
};
}

export function fetchZoweVersionError(error) {
return {
type: ZOWE_VERSION_ERROR,
error,
};
}

export function fetchZoweVersion(zoweVersion) {
return dispatch => {
const url = `https://localhost:80/api/v1/ui/catalogs/version/${zoweVersion}/info`;
fetch(url)
.then(res => res.json())
.then(res => {
console.log(res);
if (res.error) {
console.log('ERRRORE');
throw res.error;
}
dispatch(fetchZoweVersionSuccess(res));
return res.versions;
})
.catch(error => {
dispatch(fetchZoweVersionError(error));
});
};
}
51 changes: 24 additions & 27 deletions frontend/src/actions/fetch-versions-actions.jsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
import { ZOWE_VERSIONS_SUCCESS, ZOWE_VERSIONS_ERROR } from '../constants/zowe-versions-contants';


export function fetchZoweVersionsSuccess(versions) {
return {
type: ZOWE_VERSIONS_SUCCESS,
versions: versions
};
return {
type: ZOWE_VERSIONS_SUCCESS,
versions,
};
}

export function fetchZoweVersionsError(error) {
return {
type: ZOWE_VERSIONS_ERROR,
error: error
}
return {
type: ZOWE_VERSIONS_ERROR,
error,
};
}

export function fetchVersions() {
return dispatch => {
fetch('https://localhost:80/api/v1/ui/catalogs/versions')
.then(res => res.json())
.then(res => {
console.log(res)
if(res.error) {
console.log("ERRRORE")
throw(res.error);
}
dispatch(fetchZoweVersionsSuccess(res))
return res.versions;
})
.catch(error => {
dispatch(fetchZoweVersionsError(error));
})
}

return dispatch => {
fetch('https://localhost:80/api/v1/ui/catalogs/versions')
.then(res => res.json())
.then(res => {
console.log(res);
if (res.error) {
console.log('ERRRORE');
throw res.error;
}
dispatch(fetchZoweVersionsSuccess(res));
return res.versions;
})
.catch(error => {
dispatch(fetchZoweVersionsError(error));
});
};
}

111 changes: 57 additions & 54 deletions frontend/src/components/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,68 @@ import './Dashboard.css';
import Tile from '../Tile/Tile';
import Spinner from '../Spinner/Spinner';
import formatError from '../Error/ErrorFormatter';
import TextArea from 'mineral-ui/TextArea';

export default class Dashboard extends Component {
componentDidMount() {
const { fetchTilesStart, clearService } = this.props;
clearService();
fetchTilesStart();
}
componentDidMount() {
const { fetchTilesStart, clearService, fetchZoweVersion } = this.props;
clearService();
fetchTilesStart();
fetchZoweVersion(this.props.newversion);
}

componentWillUnmount() {
const { fetchTilesStop, clear } = this.props;
clear();
fetchTilesStop();
}
componenWillUnmount() {
const { fetchTilesStop, clear } = this.props;
clear();
fetchTilesStop();
}

handleSearch = value => {
const { filterText } = this.props;
filterText(value);
};
handleSearch = value => {
const { filterText } = this.props;
filterText(value);
};

render() {
const { tiles, history, searchCriteria, isLoading, fetchTilesError, fetchTilesStop } = this.props;
const hasSearchCriteria = searchCriteria !== undefined && searchCriteria !== null && searchCriteria.length > 0;
const hasTiles = !fetchTilesError && tiles && tiles.length > 0;
let error = null;
if (fetchTilesError !== undefined && fetchTilesError !== null) {
fetchTilesStop();
error = formatError(fetchTilesError);
}
return (
<div>
<Spinner isLoading={isLoading} />
{fetchTilesError && (
<div className="no-tiles-container">
<br />
<br />
<Text element="h3">Tile details could not be retrieved, the following error was returned:</Text>
{error}
</div>
)}
{!fetchTilesError && (
<div className="apis">
<div className="grid-container">
<div className="filtering-container">
<Shield title="Search Bar is broken !">
<SearchCriteria placeholder="Search for Zowe components" doSearch={this.handleSearch} />
</Shield>
<h2 className="api-heading">Available Zowe components</h2>
</div>
{hasTiles && tiles.map(tile => <Tile key={tile.id} tile={tile} history={history} />)}
{!hasTiles &&
hasSearchCriteria && (
<Text id="search_no_results" element="h4" color="#1d5bbf">
No tiles found matching search criteria
</Text>
)}
</div>
</div>
render() {
const { tiles, history, searchCriteria, isLoading, fetchTilesError, fetchTilesStop, fetchZoweVersion } = this.props;
const hasSearchCriteria = searchCriteria !== undefined && searchCriteria !== null && searchCriteria.length > 0;
const hasTiles = !fetchTilesError && tiles && tiles.length > 0;
let error = null;
if (fetchTilesError !== undefined && fetchTilesError !== null) {
fetchTilesStop();
error = formatError(fetchTilesError);
}
return (
<div>
<Spinner isLoading={isLoading} />
{fetchTilesError && (
<div className="no-tiles-container">
<br />
<br />
<Text element="h3">Tile details could not be retrieved, the following error was returned:</Text>
{error}
</div>
)}
{!fetchTilesError && (
<div className="apis">
<div className="grid-container">
<div className="filtering-container">
<Shield title="Search Bar is broken !">
<SearchCriteria placeholder="Search for Zowe components" doSearch={this.handleSearch} />
</Shield>
<h2 className="api-heading">Components List for Zowe {this.props.newversion}</h2>
<TextArea defaultValue={this.props.zoweVersion.description} readOnly />
</div>
{hasTiles && tiles.map(tile => <Tile key={tile.id} tile={tile} history={history} />)}
{!hasTiles &&
hasSearchCriteria && (
<Text id="search_no_results" element="h4" color="#1d5bbf">
No tiles found matching search criteria
</Text>
)}
</div>
);
}
</div>
)}
</div>
);
}
}
4 changes: 4 additions & 0 deletions frontend/src/components/Dashboard/DashboardContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
fetchTilesStart,
fetchTilesSuccess,
fetchTilesStop,
fetchZoweVersion,
} from '../../actions/catalog-tile-actions';
import { clearService } from '../../actions/selected-service-actions';
import { filterText, clear } from '../../actions/filter-actions';
Expand All @@ -17,6 +18,8 @@ const mapStateToProps = state => ({
tiles: getVisibleTiles(state.tilesReducer.tiles, state.filtersReducer.text),
fetchTilesError: state.tilesReducer.error,
isLoading: loadingSelector(state),
zoweVersion: state.zoweVersionReducer.zoweVersion,
newversion: state.updateTileReducer.newversion,
});

const mapDispatchToProps = {
Expand All @@ -27,6 +30,7 @@ const mapDispatchToProps = {
fetchTilesStop,
filterText,
clear,
fetchZoweVersion,
};

export default connect(
Expand Down
36 changes: 13 additions & 23 deletions frontend/src/components/Header/HeaderContainer.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@
import { connect } from 'react-redux';
import Header from './Header';
import {
fetchZoweVersionsSuccess,
fetchZoweVersionsError,
fetchVersions,
} from '../../actions/fetch-versions-actions';
import { fetchZoweVersionsSuccess, fetchZoweVersionsError, fetchVersions } from '../../actions/fetch-versions-actions';

import {
updateVersionSuccess,
updateVersionError,
} from '../../actions/update-version-actions';
import { updateVersionSuccess, updateVersionError } from '../../actions/update-version-actions';

const mapStateToProps = state => ({
versions: state.zoweVersionsReducer.versions,
error: state.zoweVersionsReducer.error,
newversion: state.updateTileReducer.newversion,
versions: state.zoweVersionsReducer.versions,
error: state.zoweVersionsReducer.error,
newversion: state.updateTileReducer.newversion,
});

const mapDispatchToProps = {
fetchZoweVersionsSuccess,
fetchZoweVersionsError,
fetchVersions,
updateVersionSuccess,
updateVersionError,
}
fetchZoweVersionsSuccess,
fetchZoweVersionsError,
fetchVersions,
updateVersionSuccess,
updateVersionError,
};

export default connect(
mapStateToProps,
mapDispatchToProps,
mapStateToProps,
mapDispatchToProps
)(Header);



2 changes: 2 additions & 0 deletions frontend/src/constants/zowe-versions-contants.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line import/prefer-default-export
export const ZOWE_VERSIONS_SUCCESS = 'ZOWE_VERSIONS_SUCCESS';
export const ZOWE_VERSIONS_ERROR = 'ZOWE_VERSIONS_ERROR';
export const ZOWE_VERSION_SUCCESS = 'ZOWE_VERSION_SUCCESS';
export const ZOWE_VERSION_ERROR = 'ZOWE_VERSION_ERROR';
18 changes: 10 additions & 8 deletions frontend/src/reducers/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import authenticationReducer from './authentication.reducer';
import selectedServiceReducer from './selected-service-reducer';
import zoweVersionsReducer from './zowe-versions-reducer';
import updateTileReducer from './update-tiles-reducer';
import zoweVersionReducer from './zowe-version-reducer';

const reducers = {
filtersReducer,
tilesReducer,
loadingReducer,
errorReducer,
authenticationReducer,
selectedServiceReducer,
zoweVersionsReducer,
updateTileReducer,
filtersReducer,
tilesReducer,
loadingReducer,
errorReducer,
authenticationReducer,
selectedServiceReducer,
zoweVersionsReducer,
updateTileReducer,
zoweVersionReducer,
};

// eslint-disable-next-line import/prefer-default-export
Expand Down
25 changes: 25 additions & 0 deletions frontend/src/reducers/zowe-version-reducer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ZOWE_VERSION_SUCCESS, ZOWE_VERSION_ERROR } from '../constants/zowe-versions-contants';

const zoweDefaultState = {
zoweVersion: '1.5.0',
};

export const zoweVersionReducer = (state = zoweDefaultState, action) => {
console.log(action.type);
switch (action.type) {
case ZOWE_VERSION_SUCCESS:
return {
...state,
zoweVersion: action.version,
};
case ZOWE_VERSION_ERROR:
return {
...state,
error: action.error,
};
default:
return state;
}
};

export default zoweVersionReducer;

0 comments on commit 040a68a

Please sign in to comment.