Skip to content

Commit

Permalink
Merge pull request #115 from Microsoft/demo-redmond
Browse files Browse the repository at this point in the history
Demo Redmond Features To Be Brought to Dev
  • Loading branch information
trevorNgo committed Mar 15, 2019
2 parents 10f9adb + 2aae437 commit b6a0e6f
Show file tree
Hide file tree
Showing 303 changed files with 3,431 additions and 2,376 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,4 @@ ASALocalRun/
.Trashes
ehthumbs.db
Thumbs.db
.github
2 changes: 1 addition & 1 deletion mocks/materialui-multi-page/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Project Acorn</title>
</head>
<body>
<noscript>
Expand Down
110 changes: 55 additions & 55 deletions mocks/materialui-multi-page/server/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,70 @@ var router = express.Router();
/*
* Include this block of code if list and mongo are selected
*/
// var mongoService = require("../mongo/mongoService");
var mongoService = require("../mongo/mongoService");

// router.get(constants.endpoint, function(req, res) {
// mongoService.get(req, res);
// });
router.get(constants.endpoint, function(req, res) {
mongoService.get(req, res);
});

// router.post(constants.endpoint, function(req, res) {
// mongoService.create(req, res);
// });
router.post(constants.endpoint, function(req, res) {
mongoService.create(req, res);
});

// router.delete(constants.endpoint + "/:_id", function(req, res) {
// mongoService.destroy(req, res);
// });
router.delete(constants.endpoint + "/:_id", function(req, res) {
mongoService.destroy(req, res);
});

/*
* Include the following code if list is selected but Cosmos is not
*/
var listItems = [
{
text:
"Lorem id sint aliqua tempor tempor sit. Ad dolor dolor ut nulla mollit dolore non eiusmod Lorem tempor nisi cillum minim. Dolore fugiat consectetur laborum laboris labore sit veniam deserunt id dolor laboris ad veniam.",
_id: 1
},
{
text:
"Lorem id sint aliqua tempor tempor sit. Ad dolor dolor ut nulla mollit dolore non eiusmod Lorem tempor nisi cillum minim. Dolore fugiat consectetur laborum laboris labore sit veniam deserunt id dolor laboris ad veniam.",
_id: 2
}
];
// var listItems = [
// {
// text:
// "Lorem id sint aliqua tempor tempor sit. Ad dolor dolor ut nulla mollit dolore non eiusmod Lorem tempor nisi cillum minim. Dolore fugiat consectetur laborum laboris labore sit veniam deserunt id dolor laboris ad veniam.",
// _id: 1
// },
// {
// text:
// "Lorem id sint aliqua tempor tempor sit. Ad dolor dolor ut nulla mollit dolore non eiusmod Lorem tempor nisi cillum minim. Dolore fugiat consectetur laborum laboris labore sit veniam deserunt id dolor laboris ad veniam.",
// _id: 2
// }
// ];

router.get(constants.endpoint, function(req, res) {
try {
res.json(listItems);
} catch (err) {
res.status.send(500).send(err);
}
});
// router.get(constants.endpoint, function(req, res) {
// try {
// res.json(listItems);
// } catch (err) {
// res.status.send(500).send(err);
// }
// });

router.post(constants.endpoint, function(req, res) {
try {
let listItem = {
text: req.body.text,
_id: req.body._id
};
listItems.unshift(listItem);
res.json(listItem);
} catch (err) {
res.status(500).send(err);
}
});
// router.post(constants.endpoint, function(req, res) {
// try {
// let listItem = {
// text: req.body.text,
// _id: req.body._id
// };
// listItems.unshift(listItem);
// res.json(listItem);
// } catch (err) {
// res.status(500).send(err);
// }
// });

router.delete(constants.endpoint + "/:_id", function(req, res) {
try {
const { _id } = req.params;
var index = listItems.findIndex(listItem => listItem._id == _id);
if (index > -1) {
listItems.splice(index, 1);
res.json({ _id: Number(_id), text: "This commented was deleted" });
} else {
res.status(404).send("Could not find item with id:" + _id);
}
} catch (err) {
res.status(500).send(err);
}
});
// router.delete(constants.endpoint + "/:_id", function(req, res) {
// try {
// const { _id } = req.params;
// var index = listItems.findIndex(listItem => listItem._id == _id);
// if (index > -1) {
// listItems.splice(index, 1);
// res.json({ _id: Number(_id), text: "This commented was deleted" });
// } else {
// res.status(404).send("Could not find item with id:" + _id);
// }
// } catch (err) {
// res.status(500).send(err);
// }
// });

module.exports = router;
2 changes: 2 additions & 0 deletions mocks/materialui-multi-page/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import List from "./components/List";
import NavBar from "./components/NavBar";
import MasterDetail from "./components/MasterDetail";
import Grid from "./components/Grid";
import Blank from "./components/Blank";
import { CssBaseline } from "@material-ui/core";

class App extends Component {
Expand All @@ -16,6 +17,7 @@ class App extends Component {
<Route path="/list" component={List} />
<Route path="/masterdetail" component={MasterDetail} />
<Route path="/grid" component={Grid} />
<Route path="/blank" component={Blank} />
</Switch>
</React.Fragment>
);
Expand Down
12 changes: 12 additions & 0 deletions mocks/materialui-multi-page/src/components/Blank/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React, { Component } from "react";
import { withStyles } from "@material-ui/core/styles";

const styles = theme => ({});

class index extends Component {
render() {
return <div />;
}
}

export default withStyles(styles)(index);
8 changes: 4 additions & 4 deletions mocks/materialui-multi-page/src/components/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class index extends Component {
};

//Only include if list is selected and cosmos db is not selected
this._id = 3;
// this._id = 3;

this.endpoint = "/api/listItems";
this.handleWarningClose = this.handleWarningClose.bind(this);
Expand Down Expand Up @@ -63,8 +63,8 @@ class index extends Component {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
text: this.state.multilineTextField,
_id: this._id // Only include if list is selected and cosmos db is not selected
text: this.state.multilineTextField
// _id: this._id // Only include if list is selected and cosmos db is not selected
})
})
.then(response => {
Expand All @@ -87,7 +87,7 @@ class index extends Component {
);

// Only include if list is selected and cosmos db is not selected
this._id++;
// this._id++;
}

handleChange(event, name) {
Expand Down
1 change: 1 addition & 0 deletions mocks/materialui-multi-page/src/components/NavBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function index(props) {
<Button href="/masterdetail">Master Detail</Button>
<Button href="/list">List</Button>
<Button href="/grid">Grid</Button>
<Button href="/blank">Blank</Button>
</Toolbar>
</AppBar>
</React.Fragment>
Expand Down
2 changes: 1 addition & 1 deletion src/client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Project Acorn</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
95 changes: 76 additions & 19 deletions src/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { HashRouter as Router, Route } from "react-router-dom";
import * as Redux from "redux";

import LeftSidebar from "./components/LeftSidebar";
import PageDetails from "./components/PageDetails";
import SelectFrameworks from "./components/SelectFrameworks";
import SelectPages from "./components/SelectPages";
import SelectWebApp from "./components/SelectWebApp";
Expand All @@ -20,24 +21,32 @@ import { ROUTES } from "./utils/constants";
import { getVSCodeApi } from "./actions/getVSCodeApi";
import { loadWizardContentAction } from "./actions/loadWizardContent";
import { logIntoAzureAction } from "./actions/logIntoAzure";
import { updateOutputPathAction } from "./actions/updateProjectNameAndPath";
import { setAccountAvailability } from "./actions/setAccountAvailability";
import appStyles from "./appStyles.module.css";
import AzureLogin from "./containers/AzureLogin";
import EngineAPIService from "./services/EngineAPIService";

import { getSubscriptionData } from "./actions/subscriptionData";

interface IDispatchProps {
updateOutputPath: (outputPath: string) => any;
getVSCodeApi: () => void;
loadWizardContent: () => void;
logIntoAzure: (email: string) => void;
logIntoAzure: (email: string, subscriptions: []) => void;
saveSubscriptionData: (subscriptionData: any) => void;
setCosmosResourceAccountNameAvailability: (isAvailable: any) => any;
}

type Props = IDispatchProps
type Props = IDispatchProps;

class App extends React.Component<Props> {
public static defaultProps = {
getVSCodeApi: () => {},
loadWizardContent: () => {},
logIntoAzure: () => {},
saveSubscriptionData: () => {},
updateOutputPath: () => {},
setCosmosResourceAccountNameAvailability: () => {}
};

public componentDidMount() {
Expand All @@ -49,38 +58,77 @@ class App extends React.Component<Props> {
window.addEventListener("message", event => {
const message = event.data;
switch (message.command) {
case "getOutputPath":
if (message.payload != null && message.payload.outputPath != null) {
this.props.updateOutputPath(
message.payload.outputPath.substring(
1,
message.payload.outputPath.length
)
);
}
return;
case "login":
// email will be null or undefined if login didn't work correctly
if (message.email != null) {
this.props.logIntoAzure(message.email);
if (message.payload != null) {
this.props.logIntoAzure(
message.payload.email,
message.payload.subscriptions
);
}
return;
case "subscriptionData":
// Expect resource groups and locations on this request
// Receive resource groups and locations
// and update redux (resourceGroups, locations)
if (message.payload != null) {
this.props.saveSubscriptionData({
locations: message.payload.locations,
resourceGroups: message.payload.resourceGroups
});
}
return;

return;

case "name-cosmos":
// Receive input validation
// and update redux (boolean, string)
this.props.setCosmosResourceAccountNameAvailability({
isAvailable: message.payload.isAvailable,
message: message.message
});
return;
}
})
});
}

public render() {
return (
<Router>
<div>
<Header />
{/*<ReviewAndGenerate />*/}
<div className={appStyles.container}>
<CosmosResourceModal />
<div className={appStyles.leftView}>
<LeftSidebar sidebarItems={leftSidebarData} />
</div>
<LeftSidebar sidebarItems={leftSidebarData} />
<div className={appStyles.centerView}>
<Route path={ROUTES.PAGE_DETAILS} component={PageDetails} />
<Route path={ROUTES.AZURE_LOGIN} component={AzureLogin} />
<Route path={ROUTES.REVIEW_AND_GENERATE} component={ReviewAndGenerate} />
<Route path={ROUTES.SELECT_FRAMEWORKS} component={SelectFrameworks} />
<Route
path={ROUTES.REVIEW_AND_GENERATE}
component={ReviewAndGenerate}
/>
<Route
path={ROUTES.SELECT_FRAMEWORKS}
component={SelectFrameworks}
/>
<Route path={ROUTES.SELECT_PAGES} component={SelectPages} />
<Route path={ROUTES.SELECT_PROJECT_TYPE} component={SelectWebApp} />
<Route
path={ROUTES.SELECT_PROJECT_TYPE}
component={SelectWebApp}
/>
<Route exact={true} path="/" component={Welcome} />
</div>
<div className={appStyles.rightView}>
<RightSidebar />
</div>
<RightSidebar />
</div>
<Footer />
</div>
Expand All @@ -96,9 +144,18 @@ const mapDispatchToProps = (dispatch: Redux.Dispatch<any>): IDispatchProps => ({
loadWizardContent: () => {
dispatch(loadWizardContentAction());
},
logIntoAzure: (email: string) => {
dispatch(logIntoAzureAction(email));
logIntoAzure: (email: string, subscriptions: []) => {
dispatch(logIntoAzureAction({ email, subscriptions }));
},
saveSubscriptionData: (subscriptionData: any) => {
dispatch(getSubscriptionData(subscriptionData));
},
updateOutputPath: (outputPath: string) => {
dispatch(updateOutputPathAction(outputPath));
},
setCosmosResourceAccountNameAvailability: (isAvailable: boolean) => {
dispatch(setAccountAvailability(isAvailable));
}
});

export default connect(
Expand Down
2 changes: 1 addition & 1 deletion src/client/src/actions/getBackendFrameworks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getFrameworks } from "./getFrameworks";
import * as Actions from "./types";

const getBackendFrameworksSuccess = (frameworks: any) => ({
export const getBackendFrameworksSuccess = (frameworks: any) => ({
type: Actions.GET_BACKEND_FRAMEWORKS_SUCCESS,
payload: frameworks
});
Expand Down
Loading

0 comments on commit b6a0e6f

Please sign in to comment.