WIP: share rest imlp

This commit is contained in:
Paulo Gustavo Veiga 2021-02-20 09:02:26 -08:00
parent 4908bcc993
commit b7c5ff3940
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 // eslint-disable-next-line @typescript-eslint/no-unused-vars
addMapPermissions(id: number, message: string, permissions: Permission[]): Promise<void> { 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[]> { fetchMapPermissions(id: number): Promise<Permission[]> {

View File

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