1
0
Fork 0

Fix theme npm link

This commit is contained in:
Chocobozzz 2021-01-11 10:46:02 +01:00
parent fcb7712228
commit 078b4716cd
No known key found for this signature in database
GPG key ID: 583A612D890159BE
5 changed files with 22 additions and 6 deletions

View file

@ -18,7 +18,7 @@
<my-global-icon iconName="home"></my-global-icon>
</a>
<a class="plugin-icon" target="_blank" rel="noopener noreferrer" [href]="'https://www.npmjs.com/package/peertube-plugin-' + plugin.name" i18n-title title="Plugin homepage (new window)">
<a class="plugin-icon" target="_blank" rel="noopener noreferrer" [href]="getPluginOrThemeHref(plugin.name)" i18n-title title="Plugin homepage (new window)">
<my-global-icon iconName="npm"></my-global-icon>
</a>

View file

@ -149,6 +149,10 @@ export class PluginListInstalledComponent implements OnInit {
return [ '/admin', 'plugins', 'show', this.pluginService.nameToNpmName(plugin.name, plugin.type) ]
}
getPluginOrThemeHref (name: string) {
return this.pluginApiService.getPluginOrThemeHref(this.pluginType, name)
}
private getUpdatingKey (plugin: PeerTubePlugin) {
return plugin.name + plugin.type
}

View file

@ -41,7 +41,7 @@
<my-global-icon iconName="home"></my-global-icon>
</a>
<a class="plugin-icon" target="_blank" rel="noopener noreferrer" [href]="'https://www.npmjs.com/package/peertube-plugin-' + plugin.name" i18n-title title="Plugin npm package (new window)">
<a class="plugin-icon" target="_blank" rel="noopener noreferrer" [href]="getPluginOrThemeHref(plugin.name)" i18n-title title="Plugin npm package (new window)">
<my-global-icon iconName="npm"></my-global-icon>
</a>

View file

@ -39,13 +39,13 @@ export class PluginSearchComponent implements OnInit {
private searchSubject = new Subject<string>()
constructor (
private pluginService: PluginApiService,
private pluginApiService: PluginApiService,
private notifier: Notifier,
private confirmService: ConfirmService,
private router: Router,
private route: ActivatedRoute
) {
this.pluginTypeOptions = this.pluginService.getPluginTypeOptions()
this.pluginTypeOptions = this.pluginApiService.getPluginTypeOptions()
}
ngOnInit () {
@ -83,7 +83,7 @@ export class PluginSearchComponent implements OnInit {
loadMorePlugins () {
this.isSearching = true
this.pluginService.searchAvailablePlugins(this.pluginType, this.pagination, this.sort, this.search)
this.pluginApiService.searchAvailablePlugins(this.pluginType, this.pagination, this.sort, this.search)
.subscribe(
res => {
this.isSearching = false
@ -115,6 +115,10 @@ export class PluginSearchComponent implements OnInit {
return !!this.installing[plugin.npmName]
}
getPluginOrThemeHref (name: string) {
return this.pluginApiService.getPluginOrThemeHref(this.pluginType, name)
}
async install (plugin: PeerTubePluginIndex) {
if (this.installing[plugin.npmName]) return
@ -126,7 +130,7 @@ export class PluginSearchComponent implements OnInit {
this.installing[plugin.npmName] = true
this.pluginService.install(plugin.npmName)
this.pluginApiService.install(plugin.npmName)
.subscribe(
() => {
this.installing[plugin.npmName] = false

View file

@ -134,6 +134,14 @@ export class PluginApiService {
.pipe(catchError(res => this.restExtractor.handleError(res)))
}
getPluginOrThemeHref (type: PluginType, name: string) {
const typeString = type === PluginType.PLUGIN
? 'plugin'
: 'theme'
return `https://www.npmjs.com/package/peertube-${typeString}-${name}`
}
private translateSettingsLabel (npmName: string, res: RegisteredServerSettings): Observable<RegisteredServerSettings> {
return this.pluginService.translationsObservable
.pipe(