-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Plugins to NavBar * fix: No plugins message
- Loading branch information
Showing
10 changed files
with
154 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import React, { ReactNode } from "react"; | ||
import { ServiceFactory } from "../../factories/serviceFactory"; | ||
import { AuthService } from "../../services/authService"; | ||
import AsyncComponent from "../components/layout/AsyncComponent"; | ||
import TabPanel from "../components/layout/TabPanel"; | ||
import Participation from "../components/plugins/Participation"; | ||
import Spammer from "../components/plugins/Spammer"; | ||
import "./Plugins.scss"; | ||
import { PluginsState } from "./PluginsState"; | ||
|
||
/** | ||
* Plugins panel. | ||
*/ | ||
class Plugins extends AsyncComponent<unknown, PluginsState> { | ||
/** | ||
* The auth service. | ||
*/ | ||
private readonly _authService: AuthService; | ||
|
||
/** | ||
* Create a new instance of Plugins. | ||
* @param props The props. | ||
*/ | ||
constructor(props: unknown) { | ||
super(props); | ||
|
||
this._authService = ServiceFactory.get<AuthService>("auth"); | ||
|
||
this.state = { | ||
plugins: [] | ||
}; | ||
} | ||
|
||
/** | ||
* The component did mount. | ||
*/ | ||
public async componentDidMount(): Promise<void> { | ||
super.componentDidMount(); | ||
|
||
const plugins = []; | ||
|
||
if (this._authService.isLoggedIn()) { | ||
const pluginDetailsSpammer = Spammer.pluginDetails(); | ||
if (pluginDetailsSpammer) { | ||
plugins.push(pluginDetailsSpammer); | ||
} | ||
const pluginDetailsParticipation = Participation.pluginDetails(); | ||
if (pluginDetailsParticipation) { | ||
plugins.push(pluginDetailsParticipation); | ||
} | ||
} | ||
|
||
if (plugins.length > 0) { | ||
this.setState({ | ||
activeTab: plugins[0].title | ||
}); | ||
} | ||
|
||
this.setState({ | ||
plugins | ||
}); | ||
} | ||
|
||
/** | ||
* Render the component. | ||
* @returns The node to render. | ||
*/ | ||
public render(): ReactNode { | ||
return ( | ||
<div className="plugins"> | ||
<div className="content"> | ||
{this.state.plugins.length === 0 && ( | ||
<p className="margin-t-s"> | ||
No plugins enabled which are supported by the dashboard.<br /> | ||
More information about managing plugins can be found on the | ||
{" "} | ||
<a | ||
target="_blank" | ||
rel="noreferrer" | ||
href="https://wiki.iota.org/hornet/post_installation/managing_a_node#plugins" | ||
> | ||
Hornet Developer Documentation. | ||
</a> | ||
</p> | ||
)} | ||
<TabPanel | ||
tabs={this.state.plugins.map(p => p.title)} | ||
activeTab={this.state.activeTab ? this.state.activeTab : ""} | ||
onTabChanged={activeTab => { | ||
this.setState({ | ||
activeTab | ||
}); | ||
}} | ||
> | ||
{this.state.plugins.map((p, idx) => ( | ||
<div data-label={p.title} key={idx}> | ||
{p.settings} | ||
</div> | ||
))} | ||
|
||
</TabPanel> | ||
</div> | ||
</div > | ||
); | ||
} | ||
} | ||
|
||
export default Plugins; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ReactNode } from "react"; | ||
|
||
export interface PluginsState { | ||
|
||
/** | ||
* The active tab. | ||
*/ | ||
activeTab?: string; | ||
|
||
/** | ||
* Plugins. | ||
*/ | ||
plugins: { | ||
title: string; | ||
description: string; | ||
settings: ReactNode; | ||
}[]; | ||
} |
Oops, something went wrong.