mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-11 01:43:23 +01:00
Implement revert
This commit is contained in:
parent
7df6f3744b
commit
ce05cc3d18
@ -1,5 +1,4 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useIntl } from 'react-intl';
|
|
||||||
import Client, { ErrorInfo, MapInfo, BasicMapInfo, NewUser, Label, ChangeHistory } from '..';
|
import Client, { ErrorInfo, MapInfo, BasicMapInfo, NewUser, Label, ChangeHistory } from '..';
|
||||||
|
|
||||||
export default class RestClient implements Client {
|
export default class RestClient implements Client {
|
||||||
@ -42,17 +41,26 @@ export default class RestClient implements Client {
|
|||||||
}
|
}
|
||||||
return new Promise(handler);
|
return new Promise(handler);
|
||||||
}
|
}
|
||||||
revertHistory(id: number, cid: number): Promise<void> {
|
|
||||||
// '/c/restful/maps/${mindmapId}/history'
|
|
||||||
|
|
||||||
throw new Error('Method not implemented.');
|
revertHistory(id: number, hid: number): Promise<void> {
|
||||||
|
const handler = (success: () => void, reject: (error: ErrorInfo) => void) => {
|
||||||
|
axios.post(this.baseUrl + `/maps/${id}/history/${hid}`,
|
||||||
|
null,
|
||||||
|
{ headers: { 'Content-Type': 'text/pain' } }
|
||||||
|
).then(() => {
|
||||||
|
success();
|
||||||
|
}).catch(error => {
|
||||||
|
const errorInfo = this.parseResponseOnError(error.response);
|
||||||
|
reject(errorInfo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return new Promise(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchHistory(id: number): Promise<ChangeHistory[]> {
|
fetchHistory(id: number): Promise<ChangeHistory[]> {
|
||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
renameMap(id: number, basicInfo: BasicMapInfo): Promise<void> {
|
renameMap(id: number, basicInfo: BasicMapInfo): Promise<void> {
|
||||||
throw "Method not implemented yet";
|
throw "Method not implemented yet";
|
||||||
}
|
}
|
||||||
@ -66,8 +74,7 @@ export default class RestClient implements Client {
|
|||||||
const mapId = response.headers.resourceid;
|
const mapId = response.headers.resourceid;
|
||||||
success(mapId);
|
success(mapId);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
const response = error.response;
|
const errorInfo = this.parseResponseOnError(error.response);
|
||||||
const errorInfo = this.parseResponseOnError(response);
|
|
||||||
reject(errorInfo);
|
reject(errorInfo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -137,8 +144,7 @@ export default class RestClient implements Client {
|
|||||||
).then(response => {
|
).then(response => {
|
||||||
success();
|
success();
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
const response = error.response;
|
const errorInfo = this.parseResponseOnError(error.response);
|
||||||
const errorInfo = this.parseResponseOnError(response);
|
|
||||||
reject(errorInfo);
|
reject(errorInfo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -238,8 +244,6 @@ export default class RestClient implements Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private parseResponseOnError = (response: any): ErrorInfo => {
|
private parseResponseOnError = (response: any): ErrorInfo => {
|
||||||
const intl = useIntl();
|
|
||||||
|
|
||||||
let result: ErrorInfo | undefined;
|
let result: ErrorInfo | undefined;
|
||||||
if (response) {
|
if (response) {
|
||||||
const status: number = response.status;
|
const status: number = response.status;
|
||||||
@ -250,7 +254,7 @@ export default class RestClient implements Client {
|
|||||||
case 401:
|
case 401:
|
||||||
case 302:
|
case 302:
|
||||||
this.sessionExpired();
|
this.sessionExpired();
|
||||||
result = { msg: intl.formatMessage({ id: "expired.description", defaultMessage: "Your current session has expired. Please, sign in and try again." }) }
|
result = { msg: "Your current session has expired. Please, sign in and try again." };
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (data) {
|
if (data) {
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormattedMessage, useIntl } from 'react-intl';
|
import { FormattedMessage, useIntl } from 'react-intl';
|
||||||
import { useQueryClient } from 'react-query';
|
|
||||||
import { useSelector } from 'react-redux';
|
|
||||||
import { Card, List, ListItem, Paper, Typography } from '@material-ui/core';
|
import { Card, List, ListItem, Paper, Typography } from '@material-ui/core';
|
||||||
|
|
||||||
|
|
||||||
import Client, { ErrorInfo } from '../../../../client';
|
import { ErrorInfo } from '../../../../client';
|
||||||
import { activeInstance } from '../../../../redux/clientSlice';
|
|
||||||
import BaseDialog from '../base-dialog';
|
import BaseDialog from '../base-dialog';
|
||||||
import { fetchMapById, SimpleDialogProps } from '..';
|
import { fetchMapById, SimpleDialogProps } from '..';
|
||||||
import { useStyles } from './style';
|
import { useStyles } from './style';
|
||||||
|
Loading…
Reference in New Issue
Block a user