-
-
Notifications
You must be signed in to change notification settings - Fork 909
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
web: provide simple tables for API-less displays #11028
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
d208dc3
web: fix Flash of Unstructured Content while SearchSelect is loading …
kensternberg-authentik f2f4d09
web: comment on state management in API layer, move file to point to …
kensternberg-authentik 014f43b
web: test for flash of unstructured content
kensternberg-authentik 5a8bffa
web: interim commit of the basic sortable & selectable table.
kensternberg-authentik 05443e8
Merge branch 'web/bug/search-select-flouc-issue' into web/element/ak-…
kensternberg-authentik 8cb0381
web: added basic unit testing to API-free tables
kensternberg-authentik a551c76
Merge branch 'main' into web/element/ak-select-table
kensternberg-authentik 198dc69
web: finalize testing for tables
kensternberg-authentik 484ebe9
Provide unit test accessibility to Firefox and Safari; wrap calls to …
kensternberg-authentik a83bc34
Merge branch 'main' into web/element/ak-select-table
kensternberg-authentik 32e7c5f
web: repeat is needed to make sure sub-elements move around correctly…
kensternberg-authentik e780182
Merge branch 'main' into web/element/ak-select-table
kensternberg-authentik 55c6e24
Merge branch 'main' into web/element/ak-select-table
kensternberg-authentik 741c051
web: update api-less tables
kensternberg-authentik bbff6f0
Merge branch 'main' into web/element/ak-select-table
kensternberg-authentik 0c75209
web: rollback dependabot "upgrade" that broke testing
kensternberg-authentik 705f096
web: small fixes for wdio and lint
kensternberg-authentik b95d3d3
Merge branch 'web/bug/fix-wdio-and-lint' into web/element/ak-select-t…
kensternberg-authentik 325b1df
web: not sure where all these getElement() additions come from; did I…
kensternberg-authentik e71e875
Merge branch 'main' into web/bug/fix-wdio-and-lint
kensternberg-authentik ed7c1b9
package-lock.json update
kensternberg-authentik 0fcf1eb
web: small fixes for wdio and lint
kensternberg-authentik 2aad79b
Forgot to run prettier.
kensternberg-authentik 4302787
Merge branch 'main' into web/bug/fix-wdio-and-lint
kensternberg-authentik 5101689
web: small fixes for elements and forms
kensternberg-authentik a9bb71a
Merge branch 'web/bug/fix-wdio-and-lint' into web/element/ak-select-t…
kensternberg-authentik 2b34e26
Merge branch 'web/update/small-upgrades' into web/element/ak-select-t…
kensternberg-authentik 9e1731d
Prettier had opinions
kensternberg-authentik 0e91519
Merge branch 'main' into web/element/ak-select-table
kensternberg-authentik 931798d
Some lint over-eagerness.
kensternberg-authentik ac6984f
Merge branch 'main' into web/element/ak-select-table
kensternberg-authentik dbcf778
Updated after build.
kensternberg-authentik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { bound } from "@goauthentik/elements/decorators/bound"; | ||
|
||
import { html } from "lit"; | ||
import { classMap } from "lit/directives/class-map.js"; | ||
|
||
// Because TableColumn isn't a component, it won't be the dispatch target and it won't have an | ||
// identity beyond the host passed in, so we must include with the event a payload that identifies | ||
// the source TableColumn in some way. | ||
// | ||
export class TableSortEvent extends Event { | ||
static readonly eventName = "tablesort"; | ||
public value: string; | ||
constructor(value: string) { | ||
super(TableSortEvent.eventName, { composed: true, bubbles: true }); | ||
this.value = value; | ||
} | ||
} | ||
|
||
/** | ||
* class TableColumn | ||
* | ||
* This is a helper class for rendering the contents of a table column header. | ||
* | ||
* ## Events | ||
* | ||
* - @fires tablesort: when the header is clicked, if the host is not undefined | ||
* | ||
*/ | ||
export class TableColumn { | ||
/** | ||
* The text to show in the column header | ||
*/ | ||
value: string; | ||
|
||
/** | ||
* If not undefined, the element that will first receive the `tablesort` event | ||
*/ | ||
host?: HTMLElement; | ||
|
||
/** | ||
* If not undefined, show the sort indicator, and indicate the sort state | ||
*/ | ||
orderBy?: string; | ||
|
||
constructor(value: string, orderBy?: string, host?: HTMLElement) { | ||
this.value = value; | ||
this.orderBy = orderBy; | ||
if (host) { | ||
this.host = host; | ||
} | ||
} | ||
|
||
@bound | ||
private onSort() { | ||
if (this.host && this.orderBy) { | ||
this.host.dispatchEvent(new TableSortEvent(this.orderBy)); | ||
} | ||
} | ||
|
||
private sortIndicator(orderBy: string) { | ||
// prettier-ignore | ||
switch(orderBy) { | ||
case this.orderBy: return "fa-long-arrow-alt-down"; | ||
case `-${this.orderBy}`: return "fa-long-arrow-alt-up"; | ||
default: return "fa-arrows-alt-v"; | ||
} | ||
} | ||
|
||
private sortButton(orderBy: string) { | ||
return html` <button class="pf-c-table__button" @click=${this.onSort}> | ||
<div class="pf-c-table__button-content"> | ||
<span part="column-text" class="pf-c-table__text">${this.value}</span> | ||
<span part="column-sort" class="pf-c-table__sort-indicator"> | ||
<i class="fas ${this.sortIndicator(orderBy)}"></i> | ||
</span> | ||
</div> | ||
</button>`; | ||
} | ||
|
||
public render(orderBy?: string) { | ||
const isSelected = orderBy === this.orderBy || orderBy === `-${this.orderBy}`; | ||
|
||
const classes = { | ||
"pf-c-table__sort": Boolean(this.host && this.orderBy), | ||
"pf-m-selected": Boolean(this.host && isSelected), | ||
}; | ||
|
||
return html`<td | ||
part="column-item" | ||
role="columnheader" | ||
scope="col" | ||
class="${classMap(classes)}" | ||
> | ||
${orderBy && this.orderBy ? this.sortButton(orderBy) : html`${this.value}`} | ||
</td>`; | ||
} | ||
} | ||
|
||
declare global { | ||
interface GlobalEventHandlersEventMap { | ||
[TableSortEvent.eventName]: TableSortEvent; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linter for package.json itself was somehow missed.