├── .eslintrc.json
├── .gitignore
├── .prettierrc
├── .travis.yml
├── README.md
├── package.json
├── public
├── favicon.ico
├── images
│ └── Banner9.jpg
├── index.html
├── manifest.json
└── redirect.html
├── screenshot.png
├── src
├── App.css
├── App.js
├── App.test.js
├── __snapshots__
│ └── App.test.js.snap
├── components
│ ├── AgoSearch.js
│ ├── AgoSearch.test.js
│ ├── AppNav.js
│ ├── ExtentsMap.js
│ ├── ExtentsMap.test.js
│ ├── ItemsLayout.js
│ ├── ItemsTable.js
│ ├── ItemsTable.test.js
│ ├── UserMenu.js
│ └── UserMenu.test.js
├── config
│ ├── environment.js
│ └── map.js
├── index.js
├── reducers
│ ├── app.js
│ └── app.test.js
├── routes
│ ├── Home.js
│ └── Items.js
├── serviceWorker.js
├── setupTests.js
└── utils
│ ├── map.js
│ ├── map.test.js
│ ├── search.js
│ ├── search.test.js
│ ├── session.js
│ └── session.test.js
└── yarn.lock
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "react-app",
4 | "prettier/react",
5 | "plugin:prettier/recommended"
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 |
8 | # testing
9 | /coverage
10 |
11 | # production
12 | /build
13 |
14 | # misc
15 | .DS_Store
16 | .env.local
17 | .env.development.local
18 | .env.test.local
19 | .env.production.local
20 |
21 | # logs
22 | npm-debug.log*
23 | yarn-debug.log*
24 | yarn-error.log*
25 |
26 | # app
27 | # this is copied from node_modules by a script
28 | public/auth.umd.min.js
29 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true
3 | }
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "stable"
4 | cache:
5 | directories:
6 | - node_modules
7 | script:
8 | - yarn test
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Create ArcGIS App
2 |
3 | An example of how to use the ArcGIS platform in an application built with [create-react-app].
4 |
5 | 
6 |
7 | [View it live!](https://create-arcgis-app.surge.sh/)
8 |
9 | This application uses [arcgis-rest-js](https://esri.github.io/arcgis-rest-js/) to authenticate users and search for items and the [ArcGIS API for JavaScript](https://developers.arcgis.com/javascript/) (via [esri-loader]) to show the extents of those items on a map.
10 |
11 | This is a [React] port of [ambitious-arcgis-app-2018](https://github.com/mjuniper/ambitious-arcgis-app-2018/). See that repository for more information on the motivation behind this application.
12 |
13 | See [next-arcgis-app](https://github.com/tomwayson/next-arcgis-app) for a port of the same application built with [Next.js](https://nextjs.org/) instead of create-react-app.
14 |
15 | See below for instructions on how to run and modify this application locally after cloning the repository.
16 |
17 | ## Available Scripts
18 |
19 | In the project directory, you can run:
20 |
21 | ### `yarn start`
22 |
23 | Runs the app in the development mode.
24 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
25 |
26 | The page will reload if you make edits.
27 | You will also see any lint errors in the console.
28 |
29 | **NOTE**: in order to see linting rules in your editor, you will need to install eslint globally (i.e. `npm i -g eslint`).
30 |
31 | ### `yarn test`
32 |
33 | Launches the test runner in the interactive watch mode.
34 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
35 |
36 | ### `yarn run build`
37 |
38 | Builds the app for production to the `build` folder.
39 | It correctly bundles React in production mode and optimizes the build for the best performance.
40 |
41 | The build is minified and the filenames include the hashes.
42 | Your app is ready to be deployed!
43 |
44 | ### `yarn run deploy`
45 |
46 | Deploy the built application to https://surge.sh/. You will need to update this script in package.json to point to your own surge domain.
47 |
48 | See the section about [deploying to surge](https://facebook.github.io/create-react-app/docs/deployment#surge-https-surgesh) for more information.
49 |
50 | ### `yarn run eject`
51 |
52 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
53 |
54 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
55 |
56 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
57 |
58 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
59 |
60 | ## Learn More
61 |
62 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
63 |
64 | To learn React, check out the [React documentation](https://reactjs.org/).
65 |
66 | ### Code Splitting
67 |
68 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
69 |
70 | ### Analyzing the Bundle Size
71 |
72 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
73 |
74 | ### Making a Progressive Web App
75 |
76 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
77 |
78 | ### Advanced Configuration
79 |
80 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
81 |
82 | ### Deployment
83 |
84 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
85 |
86 | ### `yarn run build` fails to minify
87 |
88 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
89 |
90 | [create-react-app]: https://facebook.github.io/create-react-app/
91 | [arcgis]: https://www.arcgis.com/
92 | [esri-loader]: https://github.com/Esri/esri-loader
93 | [react]: https://reactjs.org/
94 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "create-arcgis-app",
3 | "version": "0.1.0",
4 | "private": true,
5 | "description": "An example of how to use the ArcGIS platform in an application created with crete-react-app.",
6 | "dependencies": {
7 | "@esri/arcgis-rest-auth": "^2.0.0",
8 | "@esri/arcgis-rest-portal": "^2.0.0",
9 | "@esri/arcgis-rest-request": "^2.0.0",
10 | "bootstrap": "^4.3.1",
11 | "esri-loader": "^2.9.2",
12 | "js-cookie": "^2.2.0",
13 | "react": "^16.8.6",
14 | "react-arcgis-hub": "^0.1.0",
15 | "react-dom": "^16.8.6",
16 | "react-router-dom": "^5.0.0",
17 | "reactstrap": "^8.0.0"
18 | },
19 | "devDependencies": {
20 | "eslint-config-prettier": "^4.2.0",
21 | "eslint-config-react-app": "^4.0.0",
22 | "eslint-plugin-flowtype": "^3.6.1",
23 | "eslint-plugin-import": "^2.17.2",
24 | "eslint-plugin-jsx-a11y": "^6.2.1",
25 | "eslint-plugin-prettier": "^3.0.1",
26 | "eslint-plugin-react": "^7.12.4",
27 | "husky": "^2.1.0",
28 | "jest-dom": "^3.1.4",
29 | "lint-staged": "^8.1.5",
30 | "node-sass": "^4.12.0",
31 | "prettier": "^1.17.0",
32 | "react-scripts": "3.0.0",
33 | "react-testing-library": "^7.0.0"
34 | },
35 | "scripts": {
36 | "start": "react-scripts start",
37 | "prebuild": "npm run copy:auth",
38 | "copy:auth": "cp ./node_modules/@esri/arcgis-rest-auth/dist/umd/auth.umd.min.js ./public/auth.umd.min.js",
39 | "build": "react-scripts build",
40 | "predeploy": "npm run build && mv build/index.html build/200.html",
41 | "deploy": "surge ./build create-arcgis-app.surge.sh",
42 | "test": "react-scripts test",
43 | "eject": "react-scripts eject"
44 | },
45 | "browserslist": [
46 | ">0.2%",
47 | "not dead",
48 | "not ie <= 11",
49 | "not op_mini all"
50 | ],
51 | "husky": {
52 | "hooks": {
53 | "pre-commit": "lint-staged"
54 | }
55 | },
56 | "lint-staged": {
57 | "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
58 | "prettier --single-quote --write",
59 | "git add"
60 | ]
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomwayson/create-arcgis-app/041c84d330f3873f18a3e738f42cea6ecc9fcd2c/public/favicon.ico
--------------------------------------------------------------------------------
/public/images/Banner9.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomwayson/create-arcgis-app/041c84d330f3873f18a3e738f42cea6ecc9fcd2c/public/images/Banner9.jpg
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
10 |
11 |
15 |
16 |
25 | Create ArcGIS App
26 |
27 |
28 |
29 |
30 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "ArcGIS App",
3 | "name": "Ambitious ArcGIS App",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | }
10 | ],
11 | "start_url": ".",
12 | "display": "standalone",
13 | "theme_color": "#000000",
14 | "background_color": "#ffffff"
15 | }
16 |
--------------------------------------------------------------------------------
/public/redirect.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tomwayson/create-arcgis-app/041c84d330f3873f18a3e738f42cea6ecc9fcd2c/screenshot.png
--------------------------------------------------------------------------------
/src/App.css:
--------------------------------------------------------------------------------
1 | /* global styles */
2 | body {
3 | padding-top: 3.5rem;
4 | }
5 |
6 | /* index */
7 | .jumbotron {
8 | background: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)),
9 | url(/images/Banner9.jpg) center top/cover no-repeat;
10 | }
11 |
12 | /* items */
13 | .search-form-inline {
14 | margin-top: 5px;
15 | }
16 |
17 | /* map */
18 | .extents-map {
19 | height: 300px;
20 | }
21 | .extents-map.esri-view {
22 | margin-bottom: 20px;
23 | }
24 |
--------------------------------------------------------------------------------
/src/App.js:
--------------------------------------------------------------------------------
1 | import React, { useReducer, useEffect, useCallback } from 'react';
2 | import { Route } from 'react-router-dom';
3 | import './App.css';
4 | import { signIn, signOut } from './utils/session';
5 | import { actionTypes, appReducer } from './reducers/app';
6 | import AppNav from './components/AppNav';
7 | import UserMenu from './components/UserMenu';
8 | import Home from './routes/Home';
9 | import Items from './routes/Items';
10 |
11 | function App({ previousSession, title }) {
12 | // use a reducer for state to help manage the interdependent
13 | // and asynchronous nature of session and user state
14 | const [state, dispatch] = useReducer(appReducer, {
15 | // TODO: add title to state?
16 | session: previousSession
17 | });
18 | // NOTE: when storing objects like session or user in state
19 | // React uses the Object.is() comparison algorithm to detect changes
20 | // and changes to the object's properties won't trigger a re-render
21 | // which is fine for this application, b/c we don't mutate their properties
22 | const { session, user } = state;
23 | // (re)fetch user info when the session is first initialized or has updated
24 | useEffect(() => {
25 | if (session && !user) {
26 | // fetch user info and make available to the app as state
27 | session.getUser().then(newUser => {
28 | dispatch({ type: actionTypes.setUser, user: newUser });
29 | });
30 | }
31 | }, [session]);
32 | // use memoized callback functions for event handlers
33 | // see: https://reactjs.org/docs/hooks-reference.html#usecallback
34 | const onSignIn = useCallback(() => {
35 | // make session available to the app once the user signs in
36 | signIn().then(newSession => {
37 | dispatch({ type: actionTypes.setSession, session: newSession });
38 | });
39 | // NOTE: I'm not sure if [dispatch] is needed, but the above docs say:
40 | // "every value referenced inside the callback should also appear in the inputs array."
41 | }, [dispatch]);
42 | const onSignOut = useCallback(() => {
43 | // signal to app that the user has signed out by clearing user & session
44 | dispatch({ type: actionTypes.signOut });
45 | // clear the cookie, etc.
46 | signOut();
47 | // NOTE: I'm not sure if [] is needed, but in theory
48 | // it causes this callback to only be created once per component instance
49 | }, []);
50 | // NOTE: we bind the user menu and render it here
51 | // and pass it to the nav menu in order to avoid prop drilling
52 | // see: https://reactjs.org/docs/context.html#before-you-use-context
53 | const userMenu = (
54 |
55 | );
56 | return (
57 | <>
58 |
59 |
60 | {/*
61 | NOTE: we use render instead of component here so that we can pass in the session
62 | to the items route in addition to the other props passed in by react-router
63 | see: https://reacttraining.com/react-router/web/api/Route/render-func
64 | */}
65 | }
69 | />
70 | }
73 | />
74 |