Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*add({ payload, callback }, { call, select, put }) {
const response = yield call(addGroup, payload);
if (!response) {
return;
}
if (response.code === '0') {
message.success('添加成功');
} else {
message.error(response.msg);
}
// 刷新
const query = yield select(state => state.group.data.query);
yield put({ type: 'fetch', payload: query });
if (callback) callback();
},
callback: () => {
// 清空表单
form.resetFields();
// 提示
message.success('添加成功');
// 关闭弹窗
handleModalVisible();
},
},
copyToClipboard = (text) => {
if (window.clipboardData && window.clipboardData.setData) {
// IE specific code path to prevent textarea being shown while dialog is visible.
// eslint-disable-next-line no-undef
return clipboardData.setData('Text', text);
} else if (document.queryCommandSupported && document.queryCommandSupported('copy')) {
const textarea = document.createElement('textarea');
textarea.textContent = text;
textarea.style.position = 'fixed';
document.body.appendChild(textarea);
textarea.select();
try {
const res = document.execCommand('copy');
message.success(this.props.intl.formatMessage({ id: 'copy_success' }));
return res;
} catch (ex) {
return false;
} finally {
document.body.removeChild(textarea);
}
}
return false;
}
this.props.form.validateFields(async(err, formData) => {
if (!err) {
this.setState({
submitLoading: true
});
const submitForm = { ...formData };
submitForm.project = this.props.pid;
submitForm.mockRule = this.props.getApiRule();
// alert(JSON.stringify(submitForm));
const resp = await http.post('/api/api/add', submitForm);
this.setState({
submitLoading: false
});
if (resp.success) {
let actionType = this.props.apiModalType === 'add' ? '添加' : '修改';
message.success(`${actionType}成功`);
setTimeout(() => {
if (this.props.apiModalType === 'add') this.props.closeModal();
this.props.refreshList();
}, 800);
}
}
});
}
submitComment = async (answer_id, author_id, content) => {
try {
message.loading('Posting', 5)
const res = await apiPost.sendComment('ANSWER_COMMENT', answer_id, author_id, content, this.props.authToken)
const comment = _.get(res, 'data.comment', null)
if (!comment) throw new Error('No comment object available')
this.setState(state => ({
comments: [...state.comments, comment],
commentsReversed: [...state.commentsReversed, comment].reverse(),
}))
message.destroy()
message.success('Your comment has been added')
} catch (error) {
message.destroy()
console.error('[submitComment]', { error })
message.error('Internal server error')
}
}
caseCopy = async caseId=> {
let that = this;
let caseData = await that.props.fetchCaseData(caseId);
let data = caseData.payload.data.data;
data.casename=`${data.casename}_copy`
data._id=null
const res = await axios.post('/api/col/add_case',data);
if (!res.data.errcode) {
message.success('克隆用例成功');
let colId = res.data.data.col_id;
let projectId=res.data.data.project_id;
await this.getList();
this.props.history.push('/project/' + projectId + '/interface/col/' + colId);
this.setState({
visible: false
});
} else {
message.error(res.data.errmsg);
}
};
showDelCaseConfirm = caseId => {
async onInstall(params) {
const result = await this.Http.create(this.url.install, params).toPromise();
if (result) {
message.success('添加成功');
this.onGet();
this.onVisible(false);
} else {
message.error('添加失败');
}
this.onEditLoading(false);
return result;
}
/** 更新数据 */
function resetPasswordReducer(state, action) {
if (action.status === RES_SUCCEED) {
message.success('重置密码成功');
} else {
message.error(action.msg);
}
return {
...state,
};
}