WIP: share rest imlp

This commit is contained in:
Paulo Gustavo Veiga 2021-02-20 09:02:26 -08:00
parent 95379f7b4f
commit 888b937630
2 changed files with 20 additions and 3 deletions

View File

@ -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<void> {
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<Permission[]> {

View File

@ -97,7 +97,7 @@ const ActionChooser = (props: ActionProps): React.ReactElement => {
<FormattedMessage id="action.print" defaultMessage="Print" />
</MenuItem>
{role != 'viewer' &&
{role == 'owner' &&
<MenuItem onClick={handleOnClose('publish')}>
<ListItemIcon>
<PublicOutlinedIcon />
@ -106,7 +106,7 @@ const ActionChooser = (props: ActionProps): React.ReactElement => {
</MenuItem>
}
{role != 'viewer' &&
{role == 'owner' &&
<MenuItem onClick={handleOnClose('share')}>
<ListItemIcon>
<ShareOutlinedIcon />