Skip to content

Commit

Permalink
Update manager mode (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamy-CS authored Oct 2, 2024
2 parents 91399c2 + a4ed19a commit 612cf9e
Show file tree
Hide file tree
Showing 17 changed files with 624 additions and 273 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/entry-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class CreateEntry extends Component<CreateEntryProp, CreateEntryState> {
//user prefered option
localAgentsIdList[0] = this.state.parentIdManualEntryOption;
//default option
localAgentsIdList[1] = prefix + this.props.globalDebugServerInfo.svid_chain[0].id.trust_domain + "/spire/server";
localAgentsIdList[1] = prefix + this.props.globalServerInfo.trustDomain + "/spire/server";

//agents
let agentEntriesDict: { [key: string]: EntriesList[]; } | undefined = this.SpiffeHelper.getAgentsEntries(this.props.globalAgentsList, this.props.globalEntriesList)
Expand Down
26 changes: 23 additions & 3 deletions frontend/src/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ type NavigationBarProp = {
spireDebugServerInfoUpdateFunc: (globalDebugServerInfo: DebugServerInfo) => void,
// dispatches a payload for an Error Message/ Success Message of an executed function as a string and has a return type of void
tornjakMessageFunc: (globalErrorMessage: string) => void,
// the selected server for manager mode
globalServerSelected: string,
// tornjak error messege
globalErrorMessage: string,
}

type NavigationBarState = {}
Expand Down Expand Up @@ -89,9 +93,18 @@ class NavigationBar extends Component<NavigationBarProp, NavigationBarState> {
}
}
}
this.TornjakApi.populateLocalTornjakServerInfo(this.props.tornjakServerInfoUpdateFunc, this.props.tornjakMessageFunc);
this.TornjakApi.populateLocalTornjakDebugServerInfo(this.props.spireDebugServerInfoUpdateFunc, this.props.tornjakMessageFunc);
this.TornjakApi.populateServerInfo(this.props.globalTornjakServerInfo, this.props.serverInfoUpdateFunc);
if (IsManager) {
if (this.props.globalServerSelected !== "" && (this.props.globalErrorMessage === "OK" || this.props.globalErrorMessage === "")) {
// this.TornjakApi.populateAgentsUpdate(this.props.globalServerSelected, this.props.agentsListUpdateFunc, this.props.tornjakMessageFunc)
// this.TornjakApi.populateEntriesUpdate(this.props.globalServerSelected, this.props.entriesListUpdateFunc, this.props.tornjakMessageFunc)
// this.TornjakApi.refreshSelectorsState(this.props.globalServerSelected, this.props.agentworkloadSelectorInfoFunc);
// this.setState({ selectedServer: this.props.globalServerSelected });
}
} else {
this.TornjakApi.populateLocalTornjakServerInfo(this.props.tornjakServerInfoUpdateFunc, this.props.tornjakMessageFunc);
this.TornjakApi.populateLocalTornjakDebugServerInfo(this.props.spireDebugServerInfoUpdateFunc, this.props.tornjakMessageFunc);
this.TornjakApi.populateServerInfo(this.props.globalTornjakServerInfo, this.props.serverInfoUpdateFunc);
}
}

render() {
Expand Down Expand Up @@ -152,6 +165,11 @@ class NavigationBar extends Component<NavigationBarProp, NavigationBarState> {
<h5>ADMIN PORTAL</h5>
</div>
}
{IsManager &&
<div className="manager-toolbar-header">
<h5>MANAGER PORTAL</h5>
</div>
}
{IsManager && managerNavs}
</div>
</div>
Expand Down Expand Up @@ -188,6 +206,8 @@ const mapStateToProps = (state: RootState) => ({
globalServerInfo: state.servers.globalServerInfo,
globalDebugServerInfo: state.servers.globalDebugServerInfo,
globalTornjakServerInfo: state.servers.globalTornjakServerInfo,
globalServerSelected: state.servers.globalServerSelected,
globalErrorMessage: state.tornjak.globalErrorMessage,
})

export default connect(
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/select-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import axios from 'axios';
import GetApiServerUri from './helpers';
import IsManager from './is_manager';
import TornjakApi from './tornjak-api-helpers';
import './style.css';

import {
serverSelectedFunc,
Expand All @@ -17,6 +18,7 @@ import {
import { RootState } from 'redux/reducers';
import {
AgentsList,
ServersList,
ServerInfo,
TornjakServerInfo,
DebugServerInfo,
Expand All @@ -27,7 +29,7 @@ type SelectServerProp = {
// tornjak server debug info of the selected server
globalDebugServerInfo: DebugServerInfo,
// dispatches a payload for the list of available servers and their basic info as array of strings and has a return type of void
serversListUpdateFunc: (globalServersList: Array<string>) => void,
serversListUpdateFunc: (globalServersList: ServersList[]) => void,
// dispatches a payload for the server selected in the redux state as a string and has a return type of void
serverSelectedFunc: (globalServerSelected: string) => void,
// dispatches a payload for the server trust domain and nodeAttestorPlugin and has a return type of void
Expand All @@ -43,7 +45,7 @@ type SelectServerProp = {
// tornjak server info of the selected server
globalTornjakServerInfo: TornjakServerInfo,
// list of avialable servers
globalServersList: Array<string>,
globalServersList: ServersList[],
// error/ success messege returned for a specific function
globalErrorMessage: string,
}
Expand Down Expand Up @@ -134,7 +136,7 @@ class SelectServer extends Component<SelectServerProp, SelectServerState> {

render() {
let managerServerSelector = (
<div id="server-dropdown-div">
<div className="server-select-dropdown">
<label id="server-dropdown">Choose a Server</label>
<div className="servers-drp-dwn">
<select name="servers" id="servers" onChange={this.onServerSelect}>
Expand Down
251 changes: 0 additions & 251 deletions frontend/src/components/server-management.js

This file was deleted.

Loading

0 comments on commit 612cf9e

Please sign in to comment.