web: update to new formatting rules, make eslint warnings fail ci
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { gettext } from "django";
|
||||
import { customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
import { CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
import { until } from "lit-html/directives/until";
|
||||
import { AdminOverview } from "../api/admin_overview";
|
||||
import { DefaultClient } from "../api/client";
|
||||
@ -17,7 +17,7 @@ export class AggregateCard extends LitElement {
|
||||
@property()
|
||||
headerLink?: string;
|
||||
|
||||
static get styles() {
|
||||
static get styles(): CSSResult[] {
|
||||
return COMMON_STYLES;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ export class AdminOverviewPage extends LitElement {
|
||||
@property()
|
||||
data?: AdminOverview;
|
||||
|
||||
static get styles() {
|
||||
static get styles(): CSSResult[] {
|
||||
return COMMON_STYLES;
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ export class FlowShellCard extends LitElement {
|
||||
async updateCard(data: Response): Promise<void> {
|
||||
switch (data.type) {
|
||||
case ResponseType.redirect:
|
||||
window.location.assign(data.to!);
|
||||
window.location.assign(data.to || "");
|
||||
break;
|
||||
case ResponseType.template:
|
||||
this.flowBody = data.body;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { css, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
import { Application } from "../api/application";
|
||||
import { PBResponse } from "../api/client";
|
||||
import { COMMON_STYLES } from "../common/styles";
|
||||
@ -9,7 +9,7 @@ export class ApplicationViewPage extends LitElement {
|
||||
@property()
|
||||
apps?: PBResponse<Application>;
|
||||
|
||||
static get styles() {
|
||||
static get styles(): CSSResult[] {
|
||||
return COMMON_STYLES.concat(
|
||||
css`
|
||||
img.pf-icon {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { css, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
// @ts-ignore
|
||||
import CodeMirrorStyle from "codemirror/lib/codemirror.css";
|
||||
// @ts-ignore
|
||||
@ -61,15 +61,16 @@ export const ROUTES: Route[] = [
|
||||
|
||||
class RouteMatch {
|
||||
route: Route;
|
||||
arguments?: RegExpExecArray;
|
||||
arguments: { [key: string]: string; };
|
||||
fullUrl?: string;
|
||||
|
||||
constructor(route: Route) {
|
||||
this.route = route;
|
||||
this.arguments = {};
|
||||
}
|
||||
|
||||
render(): TemplateResult {
|
||||
return this.route.render(this.arguments!.groups || {});
|
||||
return this.route.render(this.arguments);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
@ -85,7 +86,7 @@ export class RouterOutlet extends LitElement {
|
||||
@property()
|
||||
defaultUrl?: string;
|
||||
|
||||
static get styles() {
|
||||
static get styles(): CSSResult[] {
|
||||
return [
|
||||
CodeMirrorStyle,
|
||||
CodeMirrorTheme,
|
||||
@ -110,7 +111,7 @@ export class RouterOutlet extends LitElement {
|
||||
navigate(): void {
|
||||
let activeUrl = window.location.hash.slice(1, Infinity);
|
||||
if (activeUrl === "") {
|
||||
activeUrl = this.defaultUrl!;
|
||||
activeUrl = this.defaultUrl || "/";
|
||||
window.location.hash = `#${activeUrl}`;
|
||||
console.debug(`passbook/router: set to ${window.location.hash}`);
|
||||
return;
|
||||
@ -121,7 +122,7 @@ export class RouterOutlet extends LitElement {
|
||||
const match = route.url.exec(activeUrl);
|
||||
if (match != null) {
|
||||
matchedRoute = new RouteMatch(route);
|
||||
matchedRoute.arguments = match;
|
||||
matchedRoute.arguments = match.groups || {};
|
||||
matchedRoute.fullUrl = activeUrl;
|
||||
console.debug(`passbook/router: found match ${matchedRoute}`);
|
||||
return true;
|
||||
@ -136,7 +137,7 @@ export class RouterOutlet extends LitElement {
|
||||
</pb-site-shell>`
|
||||
);
|
||||
matchedRoute = new RouteMatch(route);
|
||||
matchedRoute.arguments = route.url.exec(activeUrl)!;
|
||||
matchedRoute.arguments = route.url.exec(activeUrl)?.groups || {};
|
||||
matchedRoute.fullUrl = activeUrl;
|
||||
}
|
||||
this.current = matchedRoute;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { css, customElement, html, LitElement, property } from "lit-element";
|
||||
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
// @ts-ignore
|
||||
import BullseyeStyle from "@patternfly/patternfly/layouts/Bullseye/bullseye.css";
|
||||
// @ts-ignore
|
||||
@ -19,7 +19,7 @@ export class SiteShell extends LitElement {
|
||||
@property()
|
||||
loading = false;
|
||||
|
||||
static get styles() {
|
||||
static get styles(): CSSResult[] {
|
||||
return [
|
||||
css`
|
||||
:host,
|
||||
@ -44,7 +44,7 @@ export class SiteShell extends LitElement {
|
||||
];
|
||||
}
|
||||
|
||||
loadContent() {
|
||||
loadContent(): void {
|
||||
if (!this._url) {
|
||||
return;
|
||||
}
|
||||
@ -60,7 +60,11 @@ export class SiteShell extends LitElement {
|
||||
})
|
||||
.then((r) => r.text())
|
||||
.then((t) => {
|
||||
this.querySelector("[slot=body]")!.innerHTML = t;
|
||||
const bodySlot = this.querySelector("[slot=body]");
|
||||
if (!bodySlot) {
|
||||
return;
|
||||
}
|
||||
bodySlot.innerHTML = t;
|
||||
})
|
||||
.then(() => {
|
||||
// Ensure anchors only change the hash
|
||||
@ -73,12 +77,13 @@ export class SiteShell extends LitElement {
|
||||
const qs = url.search || "";
|
||||
a.href = `#${url.pathname}${qs}`;
|
||||
} catch (e) {
|
||||
console.debug(`passbook/site-shell: error ${e}`);
|
||||
a.href = `#${a.href}`;
|
||||
}
|
||||
});
|
||||
// Create refresh buttons
|
||||
this.querySelectorAll("[role=pb-refresh]").forEach((rt) => {
|
||||
rt.addEventListener("click", (e) => {
|
||||
rt.addEventListener("click", () => {
|
||||
this.loadContent();
|
||||
});
|
||||
});
|
||||
@ -87,7 +92,7 @@ export class SiteShell extends LitElement {
|
||||
f.addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
const formData = new FormData(f);
|
||||
const qs = new URLSearchParams(<any>(<unknown>formData)).toString();
|
||||
const qs = new URLSearchParams((<any>formData)).toString(); // eslint-disable-line
|
||||
window.location.hash = `#${this._url}?${qs}`;
|
||||
});
|
||||
});
|
||||
@ -97,7 +102,7 @@ export class SiteShell extends LitElement {
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
render(): TemplateResult {
|
||||
return html` ${this.loading ?
|
||||
html`<div class="pf-c-backdrop">
|
||||
<div class="pf-l-bullseye">
|
||||
|
||||
@ -29,10 +29,10 @@ export class ApplicationList extends TablePage<Application> {
|
||||
|
||||
row(item: Application): string[] {
|
||||
return [
|
||||
item.name!,
|
||||
item.slug!,
|
||||
item.provider!.toString(),
|
||||
item.provider!.toString(),
|
||||
item.name,
|
||||
item.slug,
|
||||
item.provider.toString(),
|
||||
item.provider.toString(),
|
||||
`
|
||||
<pb-modal-button href="administration/policies/bindings/${item.pk}/update/">
|
||||
<pb-spinner-button slot="trigger" class="pf-m-secondary">
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { gettext } from "django";
|
||||
import { css, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
import { Application } from "../../api/application";
|
||||
import { DefaultClient, PBResponse } from "../../api/client";
|
||||
import { PolicyBinding } from "../../api/policy_binding";
|
||||
@ -13,7 +13,7 @@ export class BoundPoliciesList extends Table<PolicyBinding> {
|
||||
|
||||
apiEndpoint(page: number): Promise<PBResponse<PolicyBinding>> {
|
||||
return DefaultClient.fetch<PBResponse<PolicyBinding>>(["policies", "bindings"], {
|
||||
target: this.target!,
|
||||
target: this.target || "",
|
||||
ordering: "order",
|
||||
page: page,
|
||||
});
|
||||
@ -62,7 +62,7 @@ export class ApplicationViewPage extends LitElement {
|
||||
@property()
|
||||
application?: Application;
|
||||
|
||||
static get styles(): any[] {
|
||||
static get styles(): CSSResult[] {
|
||||
return COMMON_STYLES.concat(
|
||||
css`
|
||||
img.pf-icon {
|
||||
@ -95,12 +95,10 @@ export class ApplicationViewPage extends LitElement {
|
||||
</div>
|
||||
</div>
|
||||
<div class="pf-c-card__body">
|
||||
${this.application ?
|
||||
html`
|
||||
${this.application ? html`
|
||||
<pb-admin-logins-chart
|
||||
url="${DefaultClient.makeUrl(["core", "applications", this.application?.slug, "metrics"])}">
|
||||
</pb-admin-logins-chart>`
|
||||
: ""}
|
||||
</pb-admin-logins-chart>`: ""}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user