From 888b937630a2c3c9ae7f6f004788a4ffb0285958 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 20 Feb 2021 09:02:26 -0800 Subject: [PATCH] WIP: share rest imlp --- .../src/classes/client/rest-client/index.ts | 19 ++++++++++++++++++- .../maps-page/action-chooser/index.tsx | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/webapp/src/classes/client/rest-client/index.ts b/packages/webapp/src/classes/client/rest-client/index.ts index 8288e974..2677886f 100644 --- a/packages/webapp/src/classes/client/rest-client/index.ts +++ b/packages/webapp/src/classes/client/rest-client/index.ts @@ -16,7 +16,24 @@ export default class RestClient implements Client { } // eslint-disable-next-line @typescript-eslint/no-unused-vars addMapPermissions(id: number, message: string, permissions: Permission[]): Promise { - throw new Error('Method not implemented.'); + const handler = (success: () => void, reject: (error: ErrorInfo) => void) => { + axios.put(`${this.baseUrl}/c/restful/maps/${id}/collabs/`, + { + messasge: message, + collaborations: permissions + }, + { headers: { 'Content-Type': 'application/json' } } + ).then(() => { + // All was ok, let's sent to success page ...; + success(); + }).catch(error => { + const errorInfo = this.parseResponseOnError(error.response); + reject(errorInfo); + }); + } + return new Promise(handler); + + } fetchMapPermissions(id: number): Promise { diff --git a/packages/webapp/src/components/maps-page/action-chooser/index.tsx b/packages/webapp/src/components/maps-page/action-chooser/index.tsx index 3fc3d804..b988d599 100644 --- a/packages/webapp/src/components/maps-page/action-chooser/index.tsx +++ b/packages/webapp/src/components/maps-page/action-chooser/index.tsx @@ -97,7 +97,7 @@ const ActionChooser = (props: ActionProps): React.ReactElement => { - {role != 'viewer' && + {role == 'owner' && @@ -106,7 +106,7 @@ const ActionChooser = (props: ActionProps): React.ReactElement => { } - {role != 'viewer' && + {role == 'owner' &&