Skip to content

Commit c87bbf5

Browse files
committed
respond to feedback
1 parent 55f48cc commit c87bbf5

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

extensions/who-is-visiting-this-content/app.R

+44-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,34 @@ full_url <- function(session) {
4444
)
4545
}
4646

47+
content_usage_table_search_method = JS("
48+
function(rows, columnIds, searchValue) {
49+
if (!searchValue) return rows;
50+
51+
const guidPattern = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
52+
const guidMatch = searchValue.match(guidPattern);
53+
const matchGuid = guidMatch ? guidMatch[0].toLowerCase() : null;
54+
const searchLower = searchValue.toLowerCase(); // <-- moved here
55+
56+
return rows.filter(function(row) {
57+
return columnIds.some(function(columnId) {
58+
const value = String(row.values[columnId] || '').toLowerCase();
59+
60+
if (columnId === 'title' && value.includes(searchLower)) {
61+
return true;
62+
}
63+
if (columnId === 'dashboard_url' && value.includes(searchLower)) {
64+
return true;
65+
}
66+
if (columnId === 'content_guid' && matchGuid && value === matchGuid) {
67+
return true;
68+
}
69+
return false;
70+
});
71+
});
72+
}
73+
")
74+
4775
ui <- function(request) {
4876
page_sidebar(
4977
useShinyjs(),
@@ -507,6 +535,11 @@ server <- function(input, output, session) {
507535
pagination = TRUE,
508536
defaultPageSize = 25,
509537
sortable = TRUE,
538+
searchable = TRUE,
539+
searchMethod = content_usage_table_search_method,
540+
language = reactableLang(
541+
searchPlaceholder = "Search by title, URL, or GUID",
542+
),
510543
highlight = TRUE,
511544
defaultSorted = "total_views",
512545
style = list(cursor = "pointer"),
@@ -771,6 +804,11 @@ server <- function(input, output, session) {
771804
selected_content_info()$title
772805
})
773806

807+
output$content_guid <- renderText({
808+
req(selected_content_info())
809+
selected_content_info()$guid
810+
})
811+
774812
output$dashboard_link <- renderUI({
775813
req(selected_content_info())
776814
url <- selected_content_info()$dashboard_url
@@ -903,12 +941,17 @@ server <- function(input, output, session) {
903941
"Usage"
904942
} else {
905943
div(
906-
style = "display: flex; justify-content: space-between; gap: 1rem; align-items: center;",
944+
style = "display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;",
907945
actionButton("clear_content_selection", "Back", icon("arrow-left"), class = "btn btn-sm", style = "white-space: nowrap;"),
908946
span(
909947
"Usage / ",
910948
textOutput("content_title", inline = TRUE)
911949
),
950+
code(
951+
class = "text-muted",
952+
style = "font-family: \"Fira Mono\", Consolas, Monaco, monospace; font-size: 0.875rem;",
953+
textOutput("content_guid", inline = TRUE)
954+
),
912955
uiOutput("dashboard_link")
913956
)
914957
}

extensions/who-is-visiting-this-content/www/styles.css

+1-9
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515
text-decoration-thickness: max(1px, 0.0625rem);
1616
}
1717

18-
/* Styles for the column headers */
19-
.header {
20-
border-bottom: 2px solid #555;
21-
font-size: 0.8125rem;
22-
font-weight: 400;
23-
text-transform: uppercase;
24-
}
25-
2618
/* Bar chart styles */
2719

2820
.bar-cell {
@@ -48,5 +40,5 @@
4840
}
4941

5042
#visit_merge_window_text {
51-
margin-top: -10px !important;
43+
margin-top: -10px;
5244
}

0 commit comments

Comments
 (0)