1515 * limitations under the License.
1616 */
1717import React from 'react' ;
18- import { ConfigProvider , Table , Button , DatePicker , Form , Icon , Pagination , Input } from '@alicloud/console-components' ;
18+ import { ConfigProvider , Table , Button , DatePicker , Form , Icon , Pagination , Input , Dialog , Message } from '@alicloud/console-components' ;
1919import Actions , { LinkButton } from '@alicloud/console-components-actions' ;
2020import { withRouter } from 'react-router-dom' ;
2121import Page from '@/components/Page' ;
2222import { GlobalProps } from '@/module' ;
2323import styled , { css } from 'styled-components' ;
24- import getData , { GlobalLockParam } from '@/service/globalLockInfo' ;
24+ import getData , { checkData , deleteData , GlobalLockParam } from '@/service/globalLockInfo' ;
2525import PropTypes from 'prop-types' ;
2626import moment from 'moment' ;
2727
2828import './index.scss' ;
29+ import { get } from "lodash" ;
30+ import { enUsKey , getCurrentLanguage } from "@/reducers/locale" ;
2931
3032const { RangePicker } = DatePicker ;
3133const FormItem = Form . Item ;
@@ -37,7 +39,7 @@ type GlobalLockInfoState = {
3739 globalLockParam : GlobalLockParam ;
3840}
3941
40- class GlobalLockInfo extends React . Component < GlobalProps , GlobalLockInfoState > {
42+ class GlobalLockInfo extends React . Component < GlobalProps , GlobalLockInfoState > {
4143 static displayName = 'GlobalLockInfo' ;
4244
4345 static propTypes = {
@@ -148,12 +150,53 @@ type GlobalLockInfoState = {
148150 this . search ( ) ;
149151 }
150152
153+ deleteCell = ( val : string , index : number , record : any ) => {
154+ const { locale = { } } = this . props ;
155+ const {
156+ deleteGlobalLockTitle
157+ } = locale ;
158+ let width = getCurrentLanguage ( ) === enUsKey ? '120px' : '80px'
159+ return (
160+ < Actions style = { { width : width } } >
161+ < Button onClick = { ( ) => {
162+ let addWarnning = ''
163+ Dialog . confirm ( {
164+ title : 'Confirm' ,
165+ content : 'Are you sure you want to delete the global lock' ,
166+ onOk : ( ) => {
167+ checkData ( record ) . then ( ( rsp ) => {
168+ addWarnning = rsp . data ? 'The branch transactions may be affected' : ''
169+ Dialog . confirm ( {
170+ title : 'Warnning' ,
171+ content : < div dangerouslySetInnerHTML = { { __html : 'Dirty write problem exists' + '<br>' + addWarnning } } /> ,
172+ onOk : ( ) => {
173+ deleteData ( record ) . then ( ( ) => {
174+ Message . success ( "Delete success" )
175+ this . search ( )
176+ } ) . catch ( ( rsp ) => {
177+ Message . error ( get ( rsp , 'data.message' ) )
178+ } )
179+ }
180+ } )
181+ } ) . catch ( ( rsp ) => {
182+ Message . error ( get ( rsp , 'data.message' ) )
183+ } )
184+ }
185+ } ) ;
186+ } } >
187+ { deleteGlobalLockTitle }
188+ </ Button >
189+ </ Actions > )
190+ }
191+
192+
151193 render ( ) {
152194 const { locale = { } } = this . props ;
153195 const { title, subTitle, createTimeLabel,
154196 inputFilterPlaceholder,
155197 searchButtonLabel,
156198 resetButtonLabel,
199+ operateTitle,
157200 } = locale ;
158201 return (
159202 < Page
@@ -221,27 +264,28 @@ type GlobalLockInfoState = {
221264 </ Form >
222265 { /* global lock table */ }
223266 < div >
224- < Table dataSource = { this . state . list } loading = { this . state . loading } >
225- < Table . Column title = "xid" dataIndex = "xid" />
226- < Table . Column title = "transactionId" dataIndex = "transactionId" />
227- < Table . Column title = "branchId" dataIndex = "branchId" />
228- < Table . Column title = "resourceId" dataIndex = "resourceId" />
229- < Table . Column title = "tableName" dataIndex = "tableName" />
230- < Table . Column title = "pk" dataIndex = "pk" />
231- < Table . Column title = "rowKey" dataIndex = "rowKey" />
232- < Table . Column title = "gmtCreate" dataIndex = "gmtCreate" />
233- < Table . Column title = "gmtModified" dataIndex = "gmtModified" />
234- </ Table >
235- < Pagination
236- total = { this . state . total }
237- defaultCurrent = { 1 }
238- current = { this . state . globalLockParam . pageNum }
239- onChange = { this . paginationOnChange }
240- pageSize = { this . state . globalLockParam . pageSize }
241- pageSizeSelector = "dropdown"
242- pageSizeList = { [ 10 , 20 , 30 , 40 , 50 ] }
243- onPageSizeChange = { this . paginationOnPageSizeChange }
244- />
267+ < Table dataSource = { this . state . list } loading = { this . state . loading } >
268+ < Table . Column title = "xid" dataIndex = "xid" />
269+ < Table . Column title = "transactionId" dataIndex = "transactionId" />
270+ < Table . Column title = "branchId" dataIndex = "branchId" />
271+ < Table . Column title = "resourceId" dataIndex = "resourceId" />
272+ < Table . Column title = "tableName" dataIndex = "tableName" />
273+ < Table . Column title = "pk" dataIndex = "pk" />
274+ < Table . Column title = "rowKey" dataIndex = "rowKey" />
275+ < Table . Column title = "gmtCreate" dataIndex = "gmtCreate" />
276+ < Table . Column title = "gmtModified" dataIndex = "gmtModified" />
277+ < Table . Column title = { operateTitle } cell = { this . deleteCell } />
278+ </ Table >
279+ < Pagination
280+ total = { this . state . total }
281+ defaultCurrent = { 1 }
282+ current = { this . state . globalLockParam . pageNum }
283+ onChange = { this . paginationOnChange }
284+ pageSize = { this . state . globalLockParam . pageSize }
285+ pageSizeSelector = "dropdown"
286+ pageSizeList = { [ 10 , 20 , 30 , 40 , 50 ] }
287+ onPageSizeChange = { this . paginationOnPageSizeChange }
288+ />
245289 </ div >
246290 </ Page >
247291 ) ;
0 commit comments