-
Notifications
You must be signed in to change notification settings - Fork 139
/
index.js
82 lines (77 loc) · 1.79 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* External dependencies
*/
import React from 'react';
import { numberFormat } from 'i18n-calypso';
/**
* Internal dependencies
*/
import StatusColumn from './status';
import SourceColumn from './source';
import getCode from './code';
import GroupColumn from './group';
import EditRedirect from 'component/redirect-edit';
import { Modal } from 'wp-plugin-components';
import getMatchType from './match-type';
import HttpCheck from 'component/http-check';
import { getMatches, getActions } from 'component/redirect-edit/constants';
export default function getColumns( row, rowParams, disabled, defaultFlags, group ) {
const { last_access, hits, position, match_type, action_type } = row;
const { rowMode, setRowMode } = rowParams;
if ( rowMode === 'edit' ) {
return <EditRedirect item={ row } onCancel={ () => setRowMode( false ) } />;
}
return [
{
name: 'status',
content: <StatusColumn row={ row } />,
},
{
name: 'source',
content: (
<>
<SourceColumn
row={ row }
table={ rowParams.table }
filters={ rowParams.table.filterBy }
defaultFlags={ defaultFlags }
/>
{ rowMode === 'check' && (
<Modal onClose={ () => setRowMode( null ) }>
<HttpCheck item={ row } />
</Modal>
) }
</>
),
alwaysDisplay: true,
},
{
name: 'match_type',
content: getMatchType( match_type, getMatches() ),
},
{
name: 'action_type',
content: getMatchType( action_type, getActions() ),
},
{
name: 'code',
content: getCode( row ),
},
{
name: 'group',
content: <GroupColumn row={ row } group={ group } />,
},
{
name: 'position',
content: numberFormat( position, 0 ),
},
{
name: 'last_count',
content: numberFormat( hits, 0 ),
},
{
name: 'last_access',
content: last_access,
},
];
}