Skip to content

Commit

Permalink
Auto redirect docs links
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Jan 6, 2025
1 parent b51af51 commit 722ea3a
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 7 deletions.
20 changes: 20 additions & 0 deletions src/plugins/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,26 @@ export class MusicAssistantApi {
return undefined;
}

public getDocumentationAddress(org_address: string) {
// substitute the org_address with the correct documentation address
if (!org_address.includes("music-assistant.io/")) return org_address;
org_address = org_address.replace("/stable", "").replace("/beta", "");
if (
this.serverInfo.value?.server_version.includes("b") ||
this.serverInfo.value?.server_version == "0.0.0"
) {
return org_address.replace(
"music-assistant.io/",
"music-assistant.io/beta/",
);
} else {
return org_address.replace(
"music-assistant.io/",
"music-assistant.io/stable/",
);
}
}

public getProviderManifest(
provider_domain_or_instance_id: string,
): ProviderManifest | undefined {
Expand Down
6 changes: 5 additions & 1 deletion src/views/settings/AddProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@
<v-card-subtitle v-if="api.providerManifests[domain].documentation">
<b>{{ $t("settings.need_help_setup_provider") }} </b>&nbsp;
<a
:href="api.providerManifests[domain].documentation"
:href="
api.getDocumentationAddress(
api.providerManifests[domain].documentation!,
)
"
target="_blank"
>{{ $t("settings.check_docs") }}</a
>
Expand Down
6 changes: 5 additions & 1 deletion src/views/settings/CoreConfigs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ const onMenu = function (evt: Event, item: CoreConfig) {
label: "settings.documentation",
labelArgs: [],
action: () => {
openLinkInNewTab(api.providerManifests[item.domain].documentation!);
openLinkInNewTab(
api.getDocumentationAddress(
api.providerManifests[item.domain].documentation!,
),
);
},
icon: "mdi-bookshelf",
disabled: !api.providerManifests[item.domain].documentation,
Expand Down
6 changes: 5 additions & 1 deletion src/views/settings/EditCoreConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
>
<b>{{ $t("settings.need_help_setup_provider") }} </b>&nbsp;
<a
:href="api.providerManifests[config.domain].documentation"
:href="
api.getDocumentationAddress(
api.providerManifests[config.domain].documentation!,
)
"
target="_blank"
>{{ $t("settings.check_docs") }}</a
>
Expand Down
6 changes: 5 additions & 1 deletion src/views/settings/EditPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
>{{ api.getProviderManifest(config.provider)?.name }}
<a
v-if="api.getProviderManifest(config.provider)?.documentation"
:href="api.getProviderManifest(config.provider)?.documentation"
:href="
api.getDocumentationAddress(
api.getProviderManifest(config.provider)?.documentation!,
)
"
target="_blank"
>
[{{ $t("settings.check_docs") }}]</a
Expand Down
6 changes: 5 additions & 1 deletion src/views/settings/EditProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
>
<b>{{ $t("settings.need_help_setup_provider") }} </b>&nbsp;
<a
:href="api.providerManifests[config.domain].documentation"
:href="
api.getDocumentationAddress(
api.providerManifests[config.domain].documentation!,
)
"
target="_blank"
>{{ $t("settings.check_docs") }}</a
>
Expand Down
5 changes: 4 additions & 1 deletion src/views/settings/Players.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ const onMenu = function (evt: Event, playerConfig: PlayerConfig) {
labelArgs: [],
action: () => {
openLinkInNewTab(
api.getProviderManifest(playerConfig!.provider)?.documentation || "",
api.getDocumentationAddress(
api.getProviderManifest(playerConfig!.provider)?.documentation ||
"",
),
);
},
icon: "mdi-bookshelf",
Expand Down
6 changes: 5 additions & 1 deletion src/views/settings/Providers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ const onMenu = function (evt: Event, item: ProviderConfig) {
label: "settings.documentation",
labelArgs: [],
action: () => {
openLinkInNewTab(api.providerManifests[item.domain].documentation!);
openLinkInNewTab(
api.getDocumentationAddress(
api.providerManifests[item.domain].documentation!,
),
);
},
icon: "mdi-bookshelf",
disabled: !api.providerManifests[item.domain].documentation,
Expand Down

0 comments on commit 722ea3a

Please sign in to comment.