Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): 435 truncated table cells #449

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
e660a4f
feat(ui): adding ability to row data with out table
BillyFigueroa Oct 11, 2024
81886a5
feat: adding header and ensuring it's scrollable
BillyFigueroa Oct 11, 2024
9af29e9
refactor: updating application routes and tests
BillyFigueroa Oct 15, 2024
fbd8fbe
fix: fixing pod table tests
BillyFigueroa Oct 15, 2024
dff554e
refactor: updating monitor events table & tests
BillyFigueroa Oct 15, 2024
2515326
refactor: updating workloads deployment and tests
BillyFigueroa Oct 15, 2024
6f6b7c5
fix: correcting lint errors
BillyFigueroa Oct 15, 2024
edd0b88
refactor: updating workloads daemonsets and tests
BillyFigueroa Oct 15, 2024
9c262e8
refactor: updating workloads statefulsets and tests
BillyFigueroa Oct 15, 2024
ee3fdf2
refactor: updating workloads ctronjobs and tests
BillyFigueroa Oct 15, 2024
30b2e3d
refactor: refacotring truncating logic
BillyFigueroa Oct 15, 2024
1a2d6f3
refactor: updating all config routes
BillyFigueroa Oct 15, 2024
0bb606e
refactor: updating all cluster ops routes
BillyFigueroa Oct 15, 2024
8279fc3
Merge branch 'main' into 435-truncated-table-cells
BillyFigueroa Oct 15, 2024
0dace95
refactor: updating all network routes
BillyFigueroa Oct 15, 2024
afd29ca
refactor: updating all storage routes
BillyFigueroa Oct 15, 2024
fb93265
refactor: removing unsed component ref
BillyFigueroa Oct 15, 2024
8cbc5a2
refactor: updating Namespaces and Nodes route
BillyFigueroa Oct 15, 2024
f89d4c5
refactor: updating app.postcss to use classes for non table layout
BillyFigueroa Oct 15, 2024
1e0d0a1
refactor: moving emphasize class to datable for workloads
BillyFigueroa Oct 15, 2024
e484c35
refactor: removing emphasize from all table col defs and moving to da…
BillyFigueroa Oct 15, 2024
f13a3bf
chore: merging main
BillyFigueroa Oct 15, 2024
e365af5
Merge branch 'main' into 435-truncated-table-cells
BillyFigueroa Oct 16, 2024
e4d45db
refactor: updating events table column widths
BillyFigueroa Oct 16, 2024
0d1257d
refactor: updating pods table
BillyFigueroa Oct 16, 2024
a730017
refactor: updating configs
BillyFigueroa Oct 16, 2024
83bb16f
fix: fixing navigation help test
BillyFigueroa Oct 17, 2024
14af135
Merge branch 'main' into 435-truncated-table-cells
BillyFigueroa Oct 17, 2024
e30f8b8
fix: updating e2e tests to pass
BillyFigueroa Oct 17, 2024
103bf57
fix: formatting
BillyFigueroa Oct 17, 2024
d224689
Merge branch 'main' into 435-truncated-table-cells
BillyFigueroa Oct 17, 2024
837d4de
fix: updating front end unit tests
BillyFigueroa Oct 17, 2024
b722618
fix: formatting test
BillyFigueroa Oct 17, 2024
7d71372
fix: updating invalid expect locator
BillyFigueroa Oct 17, 2024
db46503
fix: readding expect dependency
BillyFigueroa Oct 17, 2024
e43dafb
fix: updating test spec
BillyFigueroa Oct 17, 2024
f7c692a
fix: trying to fix local auth test
BillyFigueroa Oct 17, 2024
b82eede
chore: adding expect
BillyFigueroa Oct 17, 2024
da916fd
Merge branch 'main' into 435-truncated-table-cells
BillyFigueroa Oct 21, 2024
46ae8fd
fix: sectioning local-auth tests 1
BillyFigueroa Oct 21, 2024
cf2e9ba
Merge branch 'main' into 435-truncated-table-cells
decleaver Oct 21, 2024
917b93f
local-auth test debugging
decleaver Oct 21, 2024
311e5a9
Merge branch 'main' into 435-truncated-table-cells
BillyFigueroa Oct 22, 2024
4510f26
refactor: making namespace truncate-able
BillyFigueroa Oct 22, 2024
d32d2d8
refactor: making status column truncate-able
BillyFigueroa Oct 22, 2024
4095221
chore: merging main
BillyFigueroa Oct 22, 2024
f252911
fix: re-adding test step
BillyFigueroa Oct 22, 2024
a77d1c5
fix: updating tables with line-clamp
BillyFigueroa Oct 22, 2024
f35fae0
fix: fixing local auth test
BillyFigueroa Oct 22, 2024
e46f831
fix: updating tests
BillyFigueroa Oct 22, 2024
c062f4e
fix: fixing table.spec tests
BillyFigueroa Oct 22, 2024
124d327
Merge branch 'main' into 435-truncated-table-cells
BillyFigueroa Oct 30, 2024
ee2bef1
Merge branch 'main' into 435-truncated-table-cells
BillyFigueroa Nov 4, 2024
12766dd
Adding min width option to the data table
BillyFigueroa Nov 4, 2024
c80fa94
Merge branch 'main' into 435-truncated-table-cells
UncleGedd Nov 4, 2024
08db613
Merge branch 'main' into 435-truncated-table-cells
BillyFigueroa Nov 4, 2024
9f21d6d
Merge branch 'main' into 435-truncated-table-cells
BillyFigueroa Nov 6, 2024
4ed4c63
Adding dynamic min width classes to tailwind config
BillyFigueroa Nov 6, 2024
f83bd0a
Updating tests
BillyFigueroa Nov 6, 2024
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
44 changes: 44 additions & 0 deletions ui/src/app.postcss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,50 @@
.table-scroll-container {
@apply flex-grow overflow-auto;

/* This section is for the refactor from table to non table layout */
svg.sort {
@apply mb-1 ml-1 inline-block h-4 w-4 transform transition duration-300;

&.opacity-100 {
opacity: 1 !important;
}
}

.emphasize {
@apply text-gray-900 dark:text-white;
}

.datatable {
@apply w-full text-left text-sm text-gray-500 dark:text-gray-400;

.thead {
@apply sticky top-0 z-10 bg-gray-50 text-xs uppercase text-gray-700 dark:bg-gray-700 dark:text-gray-400;

.th {
@apply flex whitespace-nowrap px-4 py-3.5;

&:hover {
svg.sort {
@apply opacity-50;
}
}
}
}

.tr {
@apply border-b hover:bg-gray-100 dark:border-gray-600 dark:hover:bg-gray-700;

&.active {
@apply border-solid border-4 bg-gray-100 dark:bg-gray-700/50;
}

.td {
@apply flex px-4 py-2.5 text-left;
}
}
}
/* End of non table layout refactor */

table {
@apply w-full text-left text-sm text-gray-500 dark:text-gray-400;

Expand Down
107 changes: 59 additions & 48 deletions ui/src/lib/components/k8s/DataTable/component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type { KubernetesObject } from '@kubernetes/client-node'
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { Drawer, Link, Tooltip } from '$components'
import { Drawer, Link } from '$components'
import type { Row as NamespaceRow } from '$features/k8s/namespaces/store'
import { type ResourceStoreInterface } from '$features/k8s/types'
import { addToast } from '$features/toast'
Expand All @@ -30,6 +30,8 @@
export let name = ''
export let description = 'No description available'

export let minWidth = 1024

let rows = createStore()
$: ({ namespace, search, searchBy, searchTypes, sortAsc, sortBy, numResources } = rows)

Expand Down Expand Up @@ -143,6 +145,12 @@
stop()
}
})

const shouldTruncate = (classes: string = '') => {
const hasLineClamp = classes.split(' ').filter((cls) => cls.match(/^line-clamp/))

return hasLineClamp?.length > 0 ? '' : 'truncate'
}
</script>

{#if resource}
Expand All @@ -161,18 +169,21 @@
{:else}
<span class="dark:text-gray-500 pl-2" data-testid="table-header-results">({$numResources})</span>
{/if}

<div class="relative group">
<Information class="ml-2 w-4 h-4 text-gray-400" />
<div class="tooltip tooltip-right min-w-72">
<div class="whitespace-normal">{description}</div>
</div>
</div>
</div>

<div class="table-filter-section">
<div class="relative lg:w-96">
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
<Search class="h-5 w-5 text-gray-400" />
</div>

<input
type="text"
name="input-search"
Expand All @@ -183,6 +194,7 @@
bind:value={$search}
/>
</div>

<button
id="filterDropdownButton"
data-dropdown-toggle="filterDropdown"
Expand All @@ -194,6 +206,7 @@
{$searchBy}
<ChevronDown class="ml-2 h-4 w-4 text-gray-400" />
</button>

<div id="filterDropdown" class="z-10 hidden w-48 rounded-lg bg-white p-3 shadow dark:bg-gray-700">
<h6 class="mb-3 text-sm font-medium text-gray-900 dark:text-white">Search By</h6>
<ul class="space-y-2 text-sm" aria-labelledby="filterDropdownButton">
Expand All @@ -214,7 +227,9 @@
{/each}
</ul>
</div>

<div class="flex-grow"></div>

<div>
{#if isNamespaced}
<select id="stream" bind:value={$namespace} data-testid="table-filter-namespace-select">
Expand All @@ -229,46 +244,46 @@
{/if}
</div>
</div>

<div class="table-scroll-container">
<table>
<thead>
<tr>
{#each columns as [header, style]}
<th>
<button on:click={() => rows.sortByKey(header)}>
{header.replaceAll('_', ' ')}
<div class={`datatable min-w-[${minWidth}px]`}>
<div class="thead">
<div class="flex items-center">
{#each columns as [header, style], idx}
<div class={`th ${style} ${idx === 0 ? 'emphasize' : ''}`}>
<button class="flex font-bold" on:click={() => rows.sortByKey(header)}>
{header.replaceAll('_', ' ').toUpperCase()}
<ChevronUp
class="sort
{style || ''}
{$sortAsc ? 'rotate-180' : ''}
{$sortBy === header ? 'opacity-100' : 'opacity-0'}"
/>
</button>
</th>
</div>
{/each}
</tr>
</thead>
<tbody>
{#if $rows.length === 0 && isFiltering}
<tr class="!pointer-events-none !border-b-0">
<td class="text-center" colspan="9">No matching entries found</td>
</tr>
{:else if $rows.length === 0}
<tr class="!pointer-events-none !border-b-0">
<td class="text-center" colspan="9">No resources found</td>
</tr>
<!--This case only happens when returning an error when a CRD does not exist in the cluster-->
{:else if typeof $rows[0].resource === 'string'}
<tr class="!pointer-events-none !border-b-0">
<td class="text-center" colspan="9">
The CRD for the resources you are trying to view does not exist in the cluster.
<br />
Install CRD and refresh page to view resources.
</td>
</tr>
{:else}
{#each $rows as row}
<tr
</div>
</div>

{#if $rows.length === 0 && isFiltering}
<div class="!pointer-events-none !border-b-0 flex h-12 justify-center items-center">
<span>No matching entries found</span>
</div>
{:else if $rows.length === 0}
<div class="!pointer-events-none !border-b-0 flex h-12 justify-center items-center">
<span>No resources found</span>
</div>
<!--This case only happens when returning an error when a CRD does not exist in the cluster-->
{:else if typeof $rows[0].resource === 'string'}
<div class="!pointer-events-none !border-b-0 flex h-12 justify-center items-center">
<p>The CRD for the resources you are trying to view does not exist in the cluster.</p>
<p>Install CRD and refresh page to view resources.</p>
</div>
{:else}
{#each $rows as row}
<div class="tr">
<button
class="w-full flex items-center"
id={row.resource.metadata?.uid}
on:click={() =>
!disableRowClick && row.resource.metadata?.uid && goto(`${baseURL}/${row.resource.metadata?.uid}`)}
Expand All @@ -278,8 +293,8 @@
{#each columns as [key, style, modifier], idx}
<!-- Check object to avoid issues with `false` values -->
{@const value = Object.hasOwn(row.table, key) ? row.table[key] : ''}
<td
class={style || ''}
<div
class={`td ${style} ${idx === 0 ? 'emphasize' : ''}`}
data-testid={typeof value !== 'object'
? `${value}-testid-${idx + 1}`
: `object-test-id-${idx + 1}`}
Expand All @@ -299,26 +314,22 @@
{:else if key === 'namespace'}
<button
on:click|stopPropagation={() => namespace.set(value)}
class="text-blue-600 dark:text-blue-500 hover:underline pr-4 text-left"
class="text-blue-600 dark:text-blue-500 hover:underline text-left truncate"
>
{value}
</button>
{:else if style?.includes('truncate')}
<Tooltip title={value}>
<div class={`w-full ${style}`}>
{value}
</div>
</Tooltip>
{:else}
{value.text || (value === 0 ? '0' : value) || '-'}
<div class={`w-full text-left ${shouldTruncate(style)}`}>
{value.text || (value === 0 ? '0' : value) || '-'}
</div>
{/if}
</td>
</div>
{/each}
</tr>
{/each}
{/if}
</tbody>
</table>
</button>
</div>
{/each}
{/if}
</div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/lib/components/k8s/Status/component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</script>

{#if status}
<span class={statusClass}>
<span class={`${statusClass} truncate`}>
{status}
</span>
{:else}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

import { createStore, type Columns } from './store'

export let columns: Columns = [['url', 'emphasize', 'link-external'], ['namespace'], ['status'], ['age']]
export let columns: Columns = [
['url', 'w-3/12', 'link-external'],
['namespace', 'w-3/12'],
['status', 'w-3/12'],
['age', 'w-3/12'],
]

const name = 'Application Endpoints'
const description = 'Application Endpoints are exposed by the UDS Operator via a UDS Package CR.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ suite('StatefulsetTable Component', () => {

testK8sTableWithDefaults(Component, {
createStore,
columns: [['url', 'emphasize', 'link-external'], ['namespace'], ['status'], ['age']],
columns: [
['url', 'w-3/12', 'link-external'],
['namespace', 'w-3/12'],
['status', 'w-3/12'],
['age', 'w-3/12'],
],
name,
description,
disableRowClick: true,
Expand Down
14 changes: 7 additions & 7 deletions ui/src/lib/features/k8s/applications/packages/component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import { createStore, type Columns } from './store'

export let columns: Columns = [
['name', 'emphasize'],
['version'],
['description', 'italic'],
['arch'],
['flavor'],
['components'],
['age'],
['name', 'w-1/12'],
['version', ' w-1/12'],
['description', 'italic w-5/12'],
['arch', ' w-1/12'],
['flavor', ' w-1/12'],
['components', ' w-2/12'],
['age', ' w-1/12'],
]
const name = 'Application Packages'
const description = 'Packages are either UDS or Zarf packages that are deployed in the cluster.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ suite('LimitRangesTable Component', () => {
testK8sTableWithDefaults(Component, {
createStore,
columns: [
['name', 'emphasize'],
['version'],
['description', 'italic'],
['arch'],
['flavor'],
['components'],
['age'],
['name', 'w-1/12'],
['version', ' w-1/12'],
['description', 'italic w-5/12'],
['arch', ' w-1/12'],
['flavor', ' w-1/12'],
['components', ' w-2/12'],
['age', ' w-1/12'],
],
name,
description,
Expand Down
16 changes: 8 additions & 8 deletions ui/src/lib/features/k8s/cluster-ops/hpa/component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import { createStore, type Columns } from './store'

export let columns: Columns = [
['name', 'emphasize'],
['namespace'],
['metrics'],
['min_pods'],
['max_pods'],
['replicas'],
['age'],
['status'],
['name', 'w-2/12'],
['namespace', 'w-2/12'],
['metrics', 'w-2/12'],
['min_pods', 'w-1/12'],
['max_pods', 'w-1/12'],
['replicas', 'w-1/12'],
['age', 'w-1/12'],
['status', 'w-2/12'],
]

const name = 'HorizontalPodAutoscalers'
Expand Down
16 changes: 8 additions & 8 deletions ui/src/lib/features/k8s/cluster-ops/hpa/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ suite('PriorityClassesTable Component', () => {
testK8sTableWithDefaults(Component, {
createStore,
columns: [
['name', 'emphasize'],
['namespace'],
['metrics'],
['min_pods'],
['max_pods'],
['replicas'],
['age'],
['status'],
['name', 'w-2/12'],
['namespace', 'w-2/12'],
['metrics', 'w-2/12'],
['min_pods', 'w-1/12'],
['max_pods', 'w-1/12'],
['replicas', 'w-1/12'],
['age', 'w-1/12'],
['status', 'w-2/12'],
],
name,
description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

import { createStore, type Columns } from './store'

export let columns: Columns = [['name', 'emphasize'], ['namespace'], ['age']]
export let columns: Columns = [
['name', 'w-4/12'],
['namespace', 'w-4/12'],
['age', 'w-4/12'],
]
const name = 'LimitRanges'
const description = resourceDescriptions[name]
</script>
Expand Down
Loading
Loading