Make URLs in the settings viewer clickable, removes deeplinked titles (#1247)

### Changes
- URLs on the config review pages are now links that open in a new tab
- Does not do anything with the `Extra URLs in Scope` field (which we currently render as a regex so left that alone)
- Hides / removes the previously deep-linked but now broken config section rendering.
This commit is contained in:
Henry Wilkinson 2023-10-18 19:20:22 -04:00 committed by GitHub
parent 9a2787f9c4
commit 40da1f8541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,7 +116,6 @@ export class ConfigDetails extends LiteElement {
<section id="crawler-settings" class="mb-8"> <section id="crawler-settings" class="mb-8">
<btrix-section-heading style="--margin: var(--sl-spacing-medium)"> <btrix-section-heading style="--margin: var(--sl-spacing-medium)">
<h4>${msg("Crawler Settings")}</h4> <h4>${msg("Crawler Settings")}</h4>
${this.renderAnchorLink("crawler-settings")}
</btrix-section-heading> </btrix-section-heading>
<btrix-desc-list> <btrix-desc-list>
${when( ${when(
@ -197,7 +196,6 @@ export class ConfigDetails extends LiteElement {
<section id="browser-settings" class="mb-8"> <section id="browser-settings" class="mb-8">
<btrix-section-heading style="--margin: var(--sl-spacing-medium)"> <btrix-section-heading style="--margin: var(--sl-spacing-medium)">
<h4>${msg("Browser Settings")}</h4> <h4>${msg("Browser Settings")}</h4>
${this.renderAnchorLink("browser-settings")}
</btrix-section-heading> </btrix-section-heading>
<btrix-desc-list> <btrix-desc-list>
${this.renderSetting( ${this.renderSetting(
@ -229,7 +227,6 @@ export class ConfigDetails extends LiteElement {
<section id="crawl-scheduling" class="mb-8"> <section id="crawl-scheduling" class="mb-8">
<btrix-section-heading style="--margin: var(--sl-spacing-medium)"> <btrix-section-heading style="--margin: var(--sl-spacing-medium)">
<h4>${msg("Crawl Scheduling")}</h4> <h4>${msg("Crawl Scheduling")}</h4>
${this.renderAnchorLink("crawl-scheduling")}
</btrix-section-heading> </btrix-section-heading>
<btrix-desc-list> <btrix-desc-list>
${this.renderSetting( ${this.renderSetting(
@ -251,7 +248,6 @@ export class ConfigDetails extends LiteElement {
<section id="crawl-metadata" class="mb-8"> <section id="crawl-metadata" class="mb-8">
<btrix-section-heading style="--margin: var(--sl-spacing-medium)"> <btrix-section-heading style="--margin: var(--sl-spacing-medium)">
<h4>${msg("Crawl Metadata")}</h4> <h4>${msg("Crawl Metadata")}</h4>
${this.renderAnchorLink("crawl-metadata")}
</btrix-section-heading> </btrix-section-heading>
<btrix-desc-list> <btrix-desc-list>
${this.renderSetting(msg("Name"), crawlConfig?.name)} ${this.renderSetting(msg("Name"), crawlConfig?.name)}
@ -298,8 +294,21 @@ export class ConfigDetails extends LiteElement {
${this.renderSetting( ${this.renderSetting(
msg("List of URLs"), msg("List of URLs"),
html` html`
<ul class="whitespace-nowrap overflow-x-auto overflow-y-hidden"> <ul>
${this.seeds?.map((seed: Seed) => html`<li>${seed.url}</li>`)} ${this.seeds?.map(
(seed: Seed) =>
html`
<li>
<a
class="text-primary hover:text-indigo-400"
href="${seed.url}"
target="_blank"
rel="noreferrer"
>${seed.url}</a
>
</li>
`
)}
</ul> </ul>
`, `,
true true
@ -325,7 +334,17 @@ export class ConfigDetails extends LiteElement {
const includeUrlList = const includeUrlList =
primarySeedConfig.include || seedsConfig.include || []; primarySeedConfig.include || seedsConfig.include || [];
return html` return html`
${this.renderSetting(msg("Primary Seed URL"), primarySeedUrl, true)} ${this.renderSetting(
msg("Primary Seed URL"),
html`<a
class="text-primary hover:text-indigo-400"
href="${primarySeedUrl}"
target="_blank"
rel="noreferrer"
>${primarySeedUrl}</a
>`,
true
)}
${this.renderSetting( ${this.renderSetting(
msg("Crawl Scope"), msg("Crawl Scope"),
this.scopeTypeLabels[ this.scopeTypeLabels[
@ -372,11 +391,19 @@ export class ConfigDetails extends LiteElement {
msg("List of Additional URLs"), msg("List of Additional URLs"),
additionalUrlList?.length additionalUrlList?.length
? html` ? html`
<ul class="whitespace-nowrap overflow-x-auto overflow-y-hidden"> <ul>
${additionalUrlList.map( ${additionalUrlList.map((seed) => {
(seed) => const seedUrl = typeof seed === "string" ? seed : seed.url;
html`<li>${typeof seed === "string" ? seed : seed.url}</li>` return html`<li>
)} <a
class="text-primary hover:text-indigo-400"
href="${seedUrl}"
target="_blank"
rel="noreferrer"
>${seedUrl}</a
>
</li>`;
})}
</ul> </ul>
` `
: msg("None"), : msg("None"),
@ -385,19 +412,6 @@ export class ConfigDetails extends LiteElement {
`; `;
}; };
private renderAnchorLink(id: string) {
if (!this.anchorLinks) return;
const currentUrl = window.location.href;
return html`
<btrix-copy-button
style="font-size: 1rem;"
value=${`${currentUrl.replace(window.location.hash, "")}#${id}`}
name="link-45deg"
content=${msg("Copy Link to Section")}
></btrix-copy-button>
`;
}
private renderSetting(label: string, value: any, breakAll?: boolean) { private renderSetting(label: string, value: any, breakAll?: boolean) {
let content = value; let content = value;