Skip to content

Commit

Permalink
Merge pull request #240 from natgeosociety/develop
Browse files Browse the repository at this point in the history
merge develop
  • Loading branch information
iacoshoria committed Oct 19, 2020
2 parents daf8dbc + edc3097 commit a26f8dc
Show file tree
Hide file tree
Showing 109 changed files with 1,903 additions and 1,727 deletions.
3 changes: 1 addition & 2 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
["@semantic-release/git", {
"assets": ["package.json", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}],
"@semantic-release/github"
}]
],
"branches": [
{ "name": "master" }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ yarn start --scope @marapp/earth-map
Initialize the dependencies and link any cross-dependencies between the modules.

```
yarn install && yarn bootstrap
yarn bootstrap
```

Bootstrap the packages in the current Lerna repo. Installs all of their dependencies and links any cross-dependencies.
Expand Down
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,18 @@
"@natgeosociety/marapp-uikit": "^1.0.11",
"assert": "^2.0.0",
"axios": "^0.18.0",
"axios-cache-adapter": "^2.3.0",
"basic-auth": "^2.0.1",
"classnames": "^2.2.6",
"d3-ease": "^1.0.5",
"d3-geo": "^1.11.3",
"deck.gl": "7.3.6",
"delay": "^4.1.0",
"flat": "^5.0.2",
"iframe-resizer": "^3.6.6",
"flat": "^5.0.2",
"json2csv": "^5.0.3",
"jsona": "^1.4.0",
"layer-manager": "^3.0.6",
"localforage": "^1.7.3",
"localforage-memoryStorageDriver": "^0.9.2",
"lodash": "^4.17.11",
"luma.gl": "7.3.2",
"moment": "^2.24.0",
"ngs-app-config": "git+ssh://git@github.com:natgeosociety/ngs-app-config.git#v1.0.16",
"node-sass": "^4.11.0",
"photo-sphere-viewer": "3.5.1",
"prop-types": "^15.6.2",
Expand All @@ -47,6 +41,7 @@
"react-dom": "^16.8.6",
"react-fast-compare": "^2.0.4",
"react-iframe-resizer-super": "^0.2.2",
"react-hook-form": "^4.8.2",
"react-map-gl": "^5.0.7",
"react-markdown": "^4.0.8",
"react-modal": "^3.8.1",
Expand Down Expand Up @@ -75,8 +70,7 @@
"vega-lib": "^4.4.0",
"viewport-mercator-project": "6.1.1",
"vizzuality-components": "^3.0.1",
"vizzuality-redux-tools": "^4.0.2",
"wri-json-api-serializer": "^1.0.1"
"vizzuality-redux-tools": "^4.0.2"
},
"devDependencies": {
"@babel/cli": "^7.2.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/earth-admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $marapp-primary-font: 'Primary font';
$marapp-secondary-font: 'Secondary font';
$marapp-icon-font: 'icon-font';

$marapp-color-sucess: #hex;
$marapp-color-success: #hex;
$marapp-color-error: #hex;

$marapp-primary-color: #hex;
Expand Down
2 changes: 1 addition & 1 deletion packages/earth-admin/gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const wrapRootElement = ({ element }) => (
onSuccessHook={onSuccessHook}
onFailureHook={onFailureHook}
useRefreshTokens={true}
cacheLocation={'localstorage'}
cacheLocation={'memory'}
>
{element}
</Auth0Provider>
Expand Down
2 changes: 1 addition & 1 deletion packages/earth-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"gatsby-plugin-typescript": "^2.1.15",
"jshint": "^2.11.0",
"lodash": "^4.17.15",
"query-string": "^6.13.5",
"query-string-encode": "^1.0.1",
"react": "^16.11.0",
"react-codemirror2": "^7.1.0",
"react-dom": "^16.11.0",
"react-helmet": "^6.1.0",
"react-hook-form": "^4.8.2",
"swr": "^0.3.2",
"ts-jsonapi": "^2.1.2",
"url-join": "^4.0.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/earth-admin/src/auth/auth0.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const Auth0Provider = ({

if (isAuthenticated) {
const accessToken = await auth0FromHook.getTokenSilently();
onSuccessHook({ token: accessToken });
onSuccessHook({ accessToken, authClient: auth0FromHook });

const idToken = await auth0FromHook.getUser();

Expand Down Expand Up @@ -180,7 +180,7 @@ export const Auth0Provider = ({
* grant and the refresh token from the cache.
* @param options
*/
const getToken = useCallback(
const getAccessToken = useCallback(
(options: GetTokenSilentlyOptions = {} as any) => {
return client.getTokenSilently && client.getTokenSilently(options);
},
Expand Down Expand Up @@ -213,7 +213,7 @@ export const Auth0Provider = ({
logout,
userData,
getUser,
getToken,
getAccessToken,
setIsLoading,
setupUserOrg: setSelectedGroup,
getPermissions,
Expand Down
21 changes: 17 additions & 4 deletions packages/earth-admin/src/auth/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@
specific language governing permissions and limitations under the License.
*/

import { Auth0Client } from '@auth0/auth0-spa-js';
import axios from 'axios';

import {
reqNoopInterceptor,
resErrorInterceptor,
resSuccessInterceptor,
} from '@marapp/earth-shared';

import { routeToPage } from '../utils';

/**
Expand All @@ -34,10 +41,16 @@ export const onRedirectCallback = (targetUrl: string) => {
* Configure behaviour in case of successful login.
* @param params
*/
export const onSuccessHook = (params: any = {}) => {
const token = params.token;
if (token) {
axios.defaults.headers.common.Authorization = `Bearer ${token}`;
export const onSuccessHook = (params: { accessToken?: string; authClient?: Auth0Client } = {}) => {
if (params.accessToken) {
axios.defaults.headers.common.Authorization = `Bearer ${params.accessToken}`;
}
if (params.authClient) {
axios.interceptors.request.use(reqNoopInterceptor());
axios.interceptors.response.use(
resSuccessInterceptor(),
resErrorInterceptor({ authClient: params.authClient })
);
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/earth-admin/src/auth/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface Auth0 {
logout?(o?: LogoutOptions): void;
login?(o?: BaseLoginOptions): void;
getUser?(o?: GetUserOptions): void;
getToken?(o?: GetTokenWithPopupOptions): void;
getAccessToken?(o?: GetTokenWithPopupOptions): Promise<string>;
setupUserOrg?(o?: string): void;
setIsLoading(boolean): void;
getPermissions?(type: string[]): boolean;
Expand Down
26 changes: 12 additions & 14 deletions packages/earth-admin/src/components/data-listing/DataListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,6 @@ const DataListing = (props: DataListingProps) => {
} = props;
const { selectedGroup } = useAuth0();

const renderItem = (index) => {
const item = data[index];
return (
<div key={`${index}-${item.slug}`}>
{React.createElement(childComponent, {
item,
categoryUrl,
selectedItem,
})}
</div>
);
};

return (
<>
{searchValueAction && (
Expand All @@ -101,7 +88,18 @@ const DataListing = (props: DataListingProps) => {
awaitMore={awaitMore}
pageSize={pageSize}
itemCount={data.length}
renderItem={renderItem}
renderItem={(index) => {
const item = data[index];
return (
<div key={item.slug}>
{React.createElement(childComponent, {
item,
categoryUrl,
selected: selectedItem === item.id,
})}
</div>
);
}}
onIntersection={onIntersection}
{...otherProps}
/>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ import { LinkWithOrg } from '@app/components/link-with-org';
interface DataListProps {
categoryUrl: string;
item: { name: string; id: string; slug: string };
selectedItem: string;
selected: boolean;
}

const DefaultListItem = (props: DataListProps) => {
const { categoryUrl, item, selectedItem } = props;
const { categoryUrl, item, selected } = props;

return (
<LinkWithOrg
to={`/${categoryUrl}/${item.id}`}
className={classnames(
'marapp-qa-listitem ng-data-link ng-display-block ng-padding-medium-horizontal ng-padding-small-vertical',
{
'ng-data-link-selected': selectedItem === item.id,
'ng-data-link-selected': selected,
}
)}
>
Expand Down
1 change: 0 additions & 1 deletion packages/earth-admin/src/components/data-listing/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@
*/

export { DefaultListItem } from './default-list-item';
export { Auth0ListItem } from './auth0-list-item';
export { default as DataListing } from './DataListing';
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ import React from 'react';
import { Modal } from '@marapp/earth-shared';

import { useAuth0 } from '@app/auth/auth0';
import {
deleteDashboards,
deleteLayer,
deleteOrganization,
deletePlace,
deleteUser,
deleteWidgets,
} from '@app/services';
import DashboardsService from '@app/services/dashboards';
import LayersService from '@app/services/layers';
import OrganizationsService from '@app/services/organizations';
import PlacesService from '@app/services/places';
import UsersService from '@app/services/users';
import WidgetsService from '@app/services/widgets';

interface IProps {
id: string;
Expand Down Expand Up @@ -64,27 +62,27 @@ export const DeleteConfirmation = (props: IProps) => {
try {
switch (navigateRoute) {
case 'dashboards': {
await deleteDashboards(id, selectedGroup);
await DashboardsService.deleteDashboards(id, { group: selectedGroup });
break;
}
case 'layers': {
await deleteLayer(id, selectedGroup);
await LayersService.deleteLayer(id, { group: selectedGroup });
break;
}
case 'places': {
await deletePlace(id, selectedGroup);
await PlacesService.deletePlace(id, { group: selectedGroup });
break;
}
case 'widgets': {
await deleteWidgets(id, selectedGroup);
await WidgetsService.deleteWidgets(id, { group: selectedGroup });
break;
}
case 'users': {
await deleteUser(id, selectedGroup);
await UsersService.deleteUser(id, { group: selectedGroup });
break;
}
case 'organizations': {
await deleteOrganization(id);
await OrganizationsService.deleteOrganization(id);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import React, { useContext, useState } from 'react';
import { AuthzGuards } from '@marapp/earth-shared';

import { useAuth0 } from '@app/auth/auth0';
import { calculateForPlace } from '@app/services';
import { PlaceMetricsProps } from '@app/pages-client/places/model';
import MetricsService from '@app/services/metrics';
import { Auth0Context } from '@app/utils/contexts';

import { PlaceMetricsProps } from '../../../pages-client/places/model';
import './styles.scss';

export default function Metrics(props: PlaceMetricsProps) {
Expand All @@ -47,7 +47,7 @@ export default function Metrics(props: PlaceMetricsProps) {
e.stopPropagation();
try {
handleServerErrors(false);
await calculateForPlace(placeID, metricId, selectedGroup);
await MetricsService.calculateForPlace(placeID, metricId, { group: selectedGroup });
setLoading(true);
} catch (error) {
handleServerErrors(error.data.errors);
Expand Down
Loading

0 comments on commit a26f8dc

Please sign in to comment.