diff --git a/packages/webapp/src/classes/client/index.ts b/packages/webapp/src/classes/client/index.ts
index a2a6f0e9..a54cd408 100644
--- a/packages/webapp/src/classes/client/index.ts
+++ b/packages/webapp/src/classes/client/index.ts
@@ -22,6 +22,8 @@ export type Label = {
iconName: string;
}
+export type Role = 'owner' | 'editor' | 'viewer';
+
export type MapInfo = {
id: number;
starred: boolean;
@@ -33,7 +35,7 @@ export type MapInfo = {
lastModificationTime: string;
description: string;
isPublic: boolean;
- role: 'owner' | 'editor' | 'viewer'
+ role: Role;
}
export type ChangeHistory = {
@@ -64,6 +66,12 @@ export type AccountInfo = {
locale: Locale;
}
+export type Permission = {
+ name?: string;
+ email: string;
+ role: Role;
+}
+
interface Client {
deleteAccount(): Promise
importMap(model: ImportMapInfo): Promise
@@ -72,11 +80,14 @@ interface Client {
deleteMap(id: number): Promise;
renameMap(id: number, basicInfo: BasicMapInfo): Promise;
fetchAllMaps(): Promise;
+ fetchMapPermissions(id: number): Promise;
+ addMapPermissions(id: number, message: string, permissions: Permission[]): Promise;
+
duplicateMap(id: number, basicInfo: BasicMapInfo): Promise;
-
+
updateAccountLanguage(locale: LocaleCode): Promise;
updateAccountPassword(pasword: string): Promise;
- updateAccountInfo(firstname: string,lastname: string): Promise;
+ updateAccountInfo(firstname: string, lastname: string): Promise;
updateStarred(id: number, starred: boolean): Promise;
updateMapToPublic(id: number, starred: boolean): Promise;
diff --git a/packages/webapp/src/classes/client/mock-client/index.ts b/packages/webapp/src/classes/client/mock-client/index.ts
index 09d610f0..56baef53 100644
--- a/packages/webapp/src/classes/client/mock-client/index.ts
+++ b/packages/webapp/src/classes/client/mock-client/index.ts
@@ -1,8 +1,10 @@
-import Client, { AccountInfo, BasicMapInfo, ChangeHistory, ImportMapInfo, Label, MapInfo, NewUser } from '..';
+import Client, { AccountInfo, BasicMapInfo, ChangeHistory, ImportMapInfo, Label, MapInfo, NewUser, Permission } from '..';
import { LocaleCode, localeFromStr } from '../../app-i18n';
+
class MockClient implements Client {
private maps: MapInfo[] = [];
private labels: Label[] = [];
+ private permissionsByMap: Map = new Map();
constructor() {
@@ -22,6 +24,7 @@ class MockClient implements Client {
): MapInfo {
return { id, title, labels, createdBy: creator, creationTime, lastModificationBy: modifiedByUser, lastModificationTime: modifiedTime, starred, description, isPublic, role };
}
+
this.maps = [
createMapInfo(1, true, "El Mapa", [], "Paulo", "2008-06-02T00:00:00Z", "Berna", "2008-06-02T00:00:00Z", "", true, 'owner'),
createMapInfo(11, false, "El Mapa3", [1, 2, 3], "Paulo3", "2008-06-02T00:00:00Z", "Berna", "2008-06-02T00:00:00Z", "", false, 'editor'),
@@ -32,7 +35,28 @@ class MockClient implements Client {
{ id: 1, title: "Red Label", iconName: "", color: 'red' },
{ id: 2, title: "Blue Label", iconName: "", color: 'blue' }
];
+ }
+ addMapPermissions(id: number, message: string, permissions: Permission[]): Promise {
+ let perm = this.permissionsByMap.get(id) || [];
+ perm = perm.concat(permissions);
+ this.permissionsByMap.set(id, perm);
+
+ console.log(`Message ${message}`)
+ return Promise.resolve();
+ }
+
+ fetchMapPermissions(id: number): Promise {
+ let perm = this.permissionsByMap.get(id);
+ if (!perm) {
+ perm = [{
+ name: 'Cosme Sharing',
+ email: 'pepe@gmail.com',
+ role: 'editor'
+ }];
+ this.permissionsByMap.set(id, perm);
+ }
+ return Promise.resolve(perm);
}
deleteAccount(): Promise {
diff --git a/packages/webapp/src/classes/client/rest-client/index.ts b/packages/webapp/src/classes/client/rest-client/index.ts
index 812c94a4..b9835b95 100644
--- a/packages/webapp/src/classes/client/rest-client/index.ts
+++ b/packages/webapp/src/classes/client/rest-client/index.ts
@@ -1,5 +1,5 @@
import axios from 'axios';
-import Client, { ErrorInfo, MapInfo, BasicMapInfo, NewUser, Label, ChangeHistory, AccountInfo, ImportMapInfo } from '..';
+import Client, { ErrorInfo, MapInfo, BasicMapInfo, NewUser, Label, ChangeHistory, AccountInfo, ImportMapInfo, Permission } from '..';
import { LocaleCode, localeFromStr, Locales } from '../../app-i18n';
export default class RestClient implements Client {
@@ -10,6 +10,15 @@ export default class RestClient implements Client {
this.baseUrl = baseUrl;
this.sessionExpired = sessionExpired;
}
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
+ addMapPermissions(id: number, message: string, permissions: Permission[]): Promise {
+ throw new Error('Method not implemented.');
+ }
+
+ fetchMapPermissions(id: number): Promise {
+ throw new Error('Method not implemented.' + id);
+ }
+
deleteAccount(): Promise {
const handler = (success: () => void, reject: (error: ErrorInfo) => void) => {
axios.delete(this.baseUrl + `/c/restful/account`,
diff --git a/packages/webapp/src/components/login-page/index.tsx b/packages/webapp/src/components/login-page/index.tsx
index 1f1febe6..d2a68c85 100644
--- a/packages/webapp/src/components/login-page/index.tsx
+++ b/packages/webapp/src/components/login-page/index.tsx
@@ -24,7 +24,7 @@ const ConfigStatusMessage = ({ enabled = false }: ConfigStatusProps): React.Reac
);
}
- return result ? result : null;
+ return result || null;
}
const LoginError = () => {
diff --git a/packages/webapp/src/components/maps-page/account-menu/index.tsx b/packages/webapp/src/components/maps-page/account-menu/index.tsx
index b31c5ebe..326d3ea5 100644
--- a/packages/webapp/src/components/maps-page/account-menu/index.tsx
+++ b/packages/webapp/src/components/maps-page/account-menu/index.tsx
@@ -32,7 +32,7 @@ const AccountMenu = (): React.ReactElement => {
const account = fetchAccount();
return (
- `}>
+ `}>
diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/index.tsx
index 8dc7e0c6..2e71a9ec 100644
--- a/packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/index.tsx
+++ b/packages/webapp/src/components/maps-page/action-dispatcher/base-dialog/index.tsx
@@ -5,6 +5,7 @@ import { StyledDialog, StyledDialogActions, StyledDialogContent, StyledDialogTit
import GlobalError from "../../../form/global-error";
import DialogContentText from "@material-ui/core/DialogContentText";
import Button from "@material-ui/core/Button";
+import { PaperProps } from "@material-ui/core/Paper";
export type DialogProps = {
onClose: () => void;
@@ -18,10 +19,11 @@ export type DialogProps = {
submitButton?: string;
actionUrl?: string;
maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | false;
+ PaperProps?: Partial;
}
const BaseDialog = (props: DialogProps): React.ReactElement => {
- const { onClose, onSubmit, maxWidth = 'sm' } = props;
+ const { onClose, onSubmit, maxWidth = 'sm', PaperProps } = props;
const handleOnSubmit = (e: React.FormEvent) => {
e.preventDefault();
@@ -31,13 +33,13 @@ const BaseDialog = (props: DialogProps): React.ReactElement => {
}
const description = props.description ? ({props.description}) : null;
-
return (