Skip to content

Commit 9554b3a

Browse files
committed
refactor(ui): migrate list-table chain to gjs
1 parent 1af6554 commit 9554b3a

27 files changed

Lines changed: 242 additions & 264 deletions

File tree

ui/app/components/fs/browser.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
as |t|
3737
>
3838
<t.head>
39-
<t.sort-by @prop="Name" @class="is-two-thirds">Name</t.sort-by>
40-
<t.sort-by @prop="Size" @class="has-text-right">File Size</t.sort-by>
41-
<t.sort-by @prop="ModTime" @class="has-text-right">Last Modified</t.sort-by>
39+
<t.sortBy @prop="Name" @class="is-two-thirds">Name</t.sortBy>
40+
<t.sortBy @prop="Size" @class="has-text-right">File Size</t.sortBy>
41+
<t.sortBy @prop="ModTime" @class="has-text-right">Last Modified</t.sortBy>
4242
</t.head>
4343
<t.body as |row|>
4444
<Fs::DirectoryEntry

ui/app/components/job-page/parts/children.hbs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@
4545
as |t|
4646
>
4747
<t.head data-test-jobs-header>
48-
<t.sort-by @prop="name">
48+
<t.sortBy @prop="name">
4949
Name
50-
</t.sort-by>
51-
<t.sort-by @prop="submitTime" data-test-jobs-submit-time-header>
50+
</t.sortBy>
51+
<t.sortBy @prop="submitTime" data-test-jobs-submit-time-header>
5252
Submitted At
53-
</t.sort-by>
54-
<t.sort-by @prop="status">
53+
</t.sortBy>
54+
<t.sortBy @prop="status">
5555
Status
56-
</t.sort-by>
56+
</t.sortBy>
5757
<th class="is-3">
5858
Completed Allocations
5959
</th>

ui/app/components/job-page/parts/task-groups.hbs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@
1515
as |t|
1616
>
1717
<t.head>
18-
<t.sort-by @prop="name">
18+
<t.sortBy @prop="name">
1919
Name
20-
</t.sort-by>
21-
<t.sort-by @prop="count">
20+
</t.sortBy>
21+
<t.sortBy @prop="count">
2222
Count
23-
</t.sort-by>
24-
<t.sort-by @prop="queuedOrStartingAllocs" @class="is-3">
23+
</t.sortBy>
24+
<t.sortBy @prop="queuedOrStartingAllocs" @class="is-3">
2525
Allocation Status
26-
</t.sort-by>
27-
<t.sort-by @prop="volumes.length">
26+
</t.sortBy>
27+
<t.sortBy @prop="volumes.length">
2828
Volume
29-
</t.sort-by>
30-
<t.sort-by @prop="reservedCPU">
29+
</t.sortBy>
30+
<t.sortBy @prop="reservedCPU">
3131
Reserved CPU
32-
</t.sort-by>
33-
<t.sort-by @prop="reservedMemory">
32+
</t.sortBy>
33+
<t.sortBy @prop="reservedMemory">
3434
Reserved Memory
35-
</t.sort-by>
36-
<t.sort-by @prop="reservedEphemeralDisk">
35+
</t.sortBy>
36+
<t.sortBy @prop="reservedEphemeralDisk">
3737
Reserved Disk
38-
</t.sort-by>
38+
</t.sortBy>
3939
</t.head>
4040
<t.body as |row|>
4141
<TaskGroupRow

ui/app/components/list-table.gjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright IBM Corp. 2015, 2025
3+
* SPDX-License-Identifier: BUSL-1.1
4+
*/
5+
6+
import Component from '@glimmer/component';
7+
import { hash, concat } from '@ember/helper';
8+
import { or } from 'ember-truth-helpers';
9+
import ListTableSortBy from 'nomad-ui/components/list-table/sort-by';
10+
import ListTableTableBody from 'nomad-ui/components/list-table/table-body';
11+
import ListTableTableHead from 'nomad-ui/components/list-table/table-head';
12+
13+
export default class ListTable extends Component {
14+
// Plan for a future with metadata (e.g., isSelected)
15+
get decoratedSource() {
16+
return (this.args.source || []).map((row) => ({
17+
model: row,
18+
}));
19+
}
20+
21+
<template>
22+
<table class={{concat "table " (or @class "")}}>
23+
{{yield
24+
(hash
25+
head=ListTableTableHead
26+
body=(component ListTableTableBody rows=this.decoratedSource)
27+
sortBy=(component
28+
ListTableSortBy
29+
currentProp=@sortProperty
30+
sortDescending=@sortDescending
31+
)
32+
)
33+
}}
34+
</table>
35+
</template>
36+
}

ui/app/components/list-table.hbs

Lines changed: 0 additions & 16 deletions
This file was deleted.

ui/app/components/list-table.js

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright IBM Corp. 2015, 2025
3+
* SPDX-License-Identifier: BUSL-1.1
4+
*/
5+
6+
import { concat, hash } from '@ember/helper';
7+
import Component from '@glimmer/component';
8+
import SafeLinkTo from 'nomad-ui/components/safe-link-to';
9+
10+
export default class SortBy extends Component {
11+
get isActive() {
12+
return this.args.currentProp === this.args.prop;
13+
}
14+
15+
get shouldSortDescending() {
16+
return !this.isActive || !this.args.sortDescending;
17+
}
18+
19+
<template>
20+
<th
21+
class={{concat
22+
(if @class (concat @class " ") "")
23+
"is-selectable "
24+
(if this.isActive "is-active " "")
25+
(if @sortDescending "desc" "asc")
26+
}}
27+
title={{@title}}
28+
>
29+
<SafeLinkTo
30+
@query={{hash
31+
sortProperty=@prop
32+
sortDescending=this.shouldSortDescending
33+
}}
34+
data-test-sort-by={{@prop}}
35+
>
36+
{{yield}}
37+
</SafeLinkTo>
38+
</th>
39+
</template>
40+
}

ui/app/components/list-table/sort-by.hbs

Lines changed: 0 additions & 14 deletions
This file was deleted.

ui/app/components/list-table/sort-by.js

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Copyright IBM Corp. 2015, 2025
3+
* SPDX-License-Identifier: BUSL-1.1
4+
*/
5+
6+
const TableBody = <template>
7+
<tbody class={{@class}}>
8+
{{#each @rows as |row index|}}
9+
{{yield row index}}
10+
{{/each}}
11+
</tbody>
12+
</template>;
13+
14+
export default TableBody;

0 commit comments

Comments
 (0)