Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions assets/js/admin/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const styles = {
loading: { textAlign: 'center', padding: '40px 0' },
pagination: { display: 'flex', alignItems: 'center', gap: 8, marginTop: 12, justifyContent: 'flex-end' },
paginationInfo: { fontSize: 13, color: '#50575e' },
badgeBase: { display: 'inline-block', padding: '1px 6px', borderRadius: 3, fontSize: 12, lineHeight: '18px', textDecoration: 'none' },
badgeBase: { display: 'inline-block', padding: '1px 6px', borderRadius: 3, fontSize: 'inherit', lineHeight: '14px', textDecoration: 'none' },
badgeChannel: { background: '#e7f0f7', color: '#1e4d78' },
badgeApp: { background: '#f0e7f7', color: '#4d1e78' },
noItems: { textAlign: 'center', padding: 20, color: '#646970' },
Expand Down Expand Up @@ -523,6 +523,12 @@ function LogRow( { item, params, onFilter } ) {
) }
{ author.role && <br /> }
{ author.role && <small>{ author.role }</small> }
{ source.app_name && (
<>
<br />
<small><SourceBadge type="app">{ source.app_name }</SourceBadge></small>
</>
) }
</td>
<td>
{ source.channel_label && (
Expand All @@ -539,12 +545,6 @@ function LogRow( { item, params, onFilter } ) {
<br />
</>
) }
{ source.app_name && (
<>
<SourceBadge type="app">{ source.app_name }</SourceBadge>
<br />
</>
) }
{ source.ip && (
<FilterLink filterKey="filter_ip" value={ source.ip } params={ params } onFilter={ onFilter }>
{ source.ip }
Expand Down
9 changes: 5 additions & 4 deletions classes/class-aal-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ public function admin_capture_action( $list_table ) {
$result = $query->query( $query_args );

$columns = array(
'date' => __( 'Date', 'aryo-activity-log' ),
'author' => __( 'User', 'aryo-activity-log' ),
'source' => __( 'Source', 'aryo-activity-log' ),
'type' => __( 'Topic', 'aryo-activity-log' ),
'date' => __( 'Date', 'aryo-activity-log' ),
'author' => __( 'User', 'aryo-activity-log' ),
'app_password' => __( 'App Password', 'aryo-activity-log' ),
'source' => __( 'Source', 'aryo-activity-log' ),
'type' => __( 'Topic', 'aryo-activity-log' ),
'label' => __( 'Context', 'aryo-activity-log' ),
'description' => __( 'Meta', 'aryo-activity-log' ),
'action' => __( 'Action', 'aryo-activity-log' ),
Expand Down
15 changes: 9 additions & 6 deletions classes/class-aal-log-presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public static function to_export_row( $item, $columns ) {
$row[ $column ] = isset( $user->display_name ) ? $user->display_name : 'unknown';
break;

case 'app_password':
if ( AAL_Maintenance::is_schema_ready( '1.1' ) && ! empty( $item->request_source ) ) {
$parsed = AAL_API::parse_request_source( $item->request_source );
$row[ $column ] = $parsed['app_name'];
} else {
$row[ $column ] = '';
}
break;

case 'source':
if ( AAL_Maintenance::is_schema_ready( '1.1' ) && ! empty( $item->request_source ) ) {
$row[ $column ] = self::format_source_label_plain( $item->request_source );
Expand Down Expand Up @@ -277,12 +286,6 @@ private static function format_source_label_plain( $raw ) {
$parts[] = $channel_labels[ $parsed['channel'] ];
}

if ( ! empty( $parsed['app_name'] ) ) {
$parts[] = 'App Password: ' . $parsed['app_name'];
} elseif ( false !== strpos( $raw, 'app:' ) ) {
$parts[] = 'App Password';
}

return implode( '; ', $parts );
}
}
45 changes: 45 additions & 0 deletions tests/phpunit/test-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,49 @@ public function test_export_row_ip_empty_source_when_no_request_source() {
$this->assertSame( '192.168.1.1', $row['ip'] );
$this->assertSame( '', $row['source'] );
}

public function test_export_row_app_password_column_with_app() {
$columns = [
'app_password' => 'App Password',
'source' => 'Source',
];

$item = (object) [
'hist_ip' => '',
'request_source' => 'rest|app:My App',
'hist_time' => time(),
'user_id' => 0,
'object_type' => 'Posts',
'object_subtype' => 'post',
'object_name' => 'hello',
'action' => 'updated',
];

$row = AAL_Log_Presenter::to_export_row( $item, $columns );

$this->assertSame( 'My App', $row['app_password'] );
$this->assertStringNotContainsString( 'App Password', $row['source'] );
}

public function test_export_row_app_password_column_without_app() {
$columns = [
'app_password' => 'App Password',
'source' => 'Source',
];

$item = (object) [
'hist_ip' => '',
'request_source' => 'rest',
'hist_time' => time(),
'user_id' => 0,
'object_type' => 'Posts',
'object_subtype' => 'post',
'object_name' => 'hello',
'action' => 'updated',
];

$row = AAL_Log_Presenter::to_export_row( $item, $columns );

$this->assertSame( '', $row['app_password'] );
}
}
Loading