mirror of
https://github.com/nathonius/obsidian-github-link.git
synced 2026-07-22 09:20:25 +00:00
Merge pull request #127 from nathonius/feat/126/external-link
✨ feat: #126 Add toggle for external link
This commit is contained in:
commit
50f2e7b14a
5 changed files with 19 additions and 10 deletions
|
|
@ -71,12 +71,12 @@ describe("GithubLinkPlugin", () => {
|
|||
test.each<{ stored: Partial<GithubLinkPluginSettings>; name: string }>([
|
||||
{ stored: { cacheIntervalSeconds: 69 }, name: "cacheIntervalSeconds" },
|
||||
{ stored: { defaultPageSize: 69 }, name: "defaultPageSize" },
|
||||
{ stored: { tagTooltips: true }, name: "tagTooltips" },
|
||||
{ stored: { tagTooltips: false }, name: "tagTooltips" },
|
||||
{ stored: { tagTooltips: !DEFAULT_SETTINGS.tagTooltips }, name: "tagTooltips" },
|
||||
{ stored: { minRequestSeconds: 69 }, name: "minRequestSeconds" },
|
||||
{ stored: { logLevel: LogLevel.Debug }, name: "logLevel" },
|
||||
{ stored: { showPagination: !DEFAULT_SETTINGS.showPagination }, name: "showPagination" },
|
||||
{ stored: { showRefresh: !DEFAULT_SETTINGS.showRefresh }, name: "showRefresh" },
|
||||
{ stored: { showExternalLink: !DEFAULT_SETTINGS.showExternalLink }, name: "showExternalLink" },
|
||||
])("should merge stored and default settings ($name)", async ({ stored }) => {
|
||||
plugin = new GithubLinkPlugin(app, manifest);
|
||||
mockedPlugin(plugin).data = { settings: stored };
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ export class GithubLinkPlugin extends Plugin {
|
|||
defaultAccount: data.defaultAccount ?? PluginSettings.defaultAccount,
|
||||
showPagination: data.showPagination ?? PluginSettings.showPagination,
|
||||
showRefresh: data.showRefresh ?? PluginSettings.showRefresh,
|
||||
showExternalLink: data.showExternalLink ?? PluginSettings.showExternalLink,
|
||||
};
|
||||
const newData: GithubLinkPluginData = {
|
||||
cache: data.cache ?? PluginData.cache,
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ export class GithubQuery {
|
|||
columns = columns.map((c) => c.toLowerCase());
|
||||
|
||||
// Render
|
||||
this.renderFooter(this.params, this.result, this.resultMeta, tableWrapper);
|
||||
this.renderFooter(this.params, this.resultMeta, tableWrapper);
|
||||
this.renderHeader(table, queryType, columns);
|
||||
this.renderBody(table, queryType, columns, this.result);
|
||||
}
|
||||
|
|
@ -140,17 +140,12 @@ export class GithubQuery {
|
|||
}
|
||||
}
|
||||
|
||||
private renderFooter(
|
||||
params: QueryParams,
|
||||
result: TableResult,
|
||||
meta: PaginationMeta | null,
|
||||
parent: HTMLElement,
|
||||
): void {
|
||||
private renderFooter(params: QueryParams, meta: PaginationMeta | null, parent: HTMLElement): void {
|
||||
const footer = parent.createDiv({ cls: "github-link-table-footer" });
|
||||
|
||||
// Add external link to footer if available
|
||||
const externalLink = this.getExternalLink(params);
|
||||
if (externalLink) {
|
||||
if (externalLink && PluginSettings.showExternalLink) {
|
||||
footer.createEl("a", {
|
||||
cls: "github-link-table-footer-external-link",
|
||||
text: "View on GitHub",
|
||||
|
|
|
|||
|
|
@ -95,6 +95,17 @@ export class GithubLinkPluginSettingsTab extends PluginSettingTab {
|
|||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Show external link")
|
||||
.setDesc("When using a custom query, an 'Open on GitHub' link can be added to view the results there.")
|
||||
.addToggle((toggle) => {
|
||||
toggle.setValue(PluginSettings.showExternalLink);
|
||||
toggle.onChange((value) => {
|
||||
PluginSettings.showExternalLink = value;
|
||||
void this.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Show refresh button")
|
||||
.setDesc("Add a refresh button to tables to manually skip the cache.")
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ export interface GithubLinkPluginSettings {
|
|||
defaultPageSize: number;
|
||||
showPagination: boolean;
|
||||
showRefresh: boolean;
|
||||
showExternalLink: boolean;
|
||||
logLevel: LogLevel;
|
||||
tagTooltips: boolean;
|
||||
tagShowPRMergeable: boolean;
|
||||
|
|
@ -33,6 +34,7 @@ export const DEFAULT_SETTINGS: GithubLinkPluginSettings = {
|
|||
defaultPageSize: 10,
|
||||
showPagination: true,
|
||||
showRefresh: true,
|
||||
showExternalLink: true,
|
||||
logLevel: LogLevel.Error,
|
||||
tagTooltips: false,
|
||||
tagShowPRMergeable: false,
|
||||
|
|
|
|||
Loading…
Reference in a new issue