Skip to content

Commit

Permalink
update delete and post apis
Browse files Browse the repository at this point in the history
Signed-off-by: MohammedAbdi <[email protected]>
  • Loading branch information
mamy-CS committed Sep 11, 2024
1 parent d78eb26 commit 179f773
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/agent-create-join-token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { serverSelectedFunc } from 'redux/actions';
import { RootState } from 'redux/reducers';
import { ToastContainer } from "react-toastify"
import { showResponseToast, showToast } from './error-api';
import apiEndpoints from './apiConfig';

type CreateJoinTokenProp = {
globalServerSelected: string,
Expand Down Expand Up @@ -102,7 +103,7 @@ class CreateJoinToken extends Component<CreateJoinTokenProp, CreateJoinTokenStat

getApiTokenEndpoint(): string {
if (!IsManager) {
return GetApiServerUri('/api/agent/createjointoken')
return GetApiServerUri(apiEndpoints.spireJoinTokenApi)
} else if (IsManager && this.state.selectedServer !== "") {
return GetApiServerUri('/manager-api/agent/createjointoken') + "/" + this.state.selectedServer
} else {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/cluster-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
TornjakServerInfo
} from './types'
import { showResponseToast, showToast } from './error-api';
// import apiEndpoints from './apiConfig';
import apiEndpoints from './apiConfig';

type ClusterCreateProp = {
// dispatches a payload for the server trust domain and nodeAttestorPlugin as a ServerInfoType and has a return type of void
Expand Down Expand Up @@ -206,7 +206,7 @@ class ClusterCreate extends Component<ClusterCreateProp, ClusterCreateState> {

getApiEntryCreateEndpoint(): string {
if (!IsManager) {
return GetApiServerUri('/api/tornjak/clusters/create')
return GetApiServerUri(apiEndpoints.tornjakClustersApi)
} else if (IsManager && this.state.selectedServer !== "") {
return GetApiServerUri('/manager-api/tornjak/clusters/create') + "/" + this.state.selectedServer
} else {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/cluster-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
DebugServerInfo,
} from './types';
import { showResponseToast, showToast } from './error-api';
import apiEndpoints from './apiConfig';

type ClusterEditProp = {
// tornjak server debug info of the selected server
Expand Down Expand Up @@ -259,7 +260,7 @@ class ClusterEdit extends Component<ClusterEditProp, ClusterEditState> {

getApiEntryCreateEndpoint(): string {
if (!IsManager) {
return GetApiServerUri('/api/tornjak/clusters/edit')
return GetApiServerUri(apiEndpoints.tornjakClustersApi)
}
if (IsManager && this.state.selectedServer !== "") {
return GetApiServerUri('/manager-api/tornjak/clusters/edit') + "/" + this.state.selectedServer
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/entry-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import EntryExpiryFeatures from './entry-expiry-features';
import CreateEntryJson from './entry-create-json';
import { ToastContainer } from "react-toastify"
import { showResponseToast, showToast } from './error-api';
import apiEndpoints from './apiConfig';
// import PropTypes from "prop-types"; // needed for testing will be removed on last pr

type CreateEntryProp = {
Expand Down Expand Up @@ -573,7 +574,7 @@ class CreateEntry extends Component<CreateEntryProp, CreateEntryState> {

getApiEntryCreateEndpoint(): string {
if (!IsManager) {
return GetApiServerUri('/api/entry/create')
return GetApiServerUri(apiEndpoints.spireEntriesApi)
}
if (IsManager && this.state.selectedServer !== "") {
return GetApiServerUri('/manager-api/entry/create') + "/" + this.state.selectedServer
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/tables/agents-list-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AgentsList, AgentsWorkLoadAttestorInfo } from "components/types";
import { DenormalizedRow } from "carbon-components-react";
import { RootState } from "redux/reducers";
import { showResponseToast } from "components/error-api";
import apiEndpoints from 'components/apiConfig';

// AgentListTable takes in
// listTableData: agents data to be rendered on table
Expand Down Expand Up @@ -99,7 +100,7 @@ class AgentsListTable extends React.Component<AgentsListTableProp, AgentsListTab
endpoint = GetApiServerUri('/manager-api/agent/delete') + "/" + this.props.globalServerSelected;

} else {
endpoint = GetApiServerUri('/api/agent/delete');
endpoint = GetApiServerUri(apiEndpoints.spireAgentsApi);
}

if (selectedRows !== undefined && selectedRows.length !== 0) {
Expand Down Expand Up @@ -138,7 +139,7 @@ class AgentsListTable extends React.Component<AgentsListTableProp, AgentsListTab
endpoint = GetApiServerUri('/manager-api/agent/ban') + "/" + this.props.globalServerSelected

} else {
endpoint = GetApiServerUri('/api/agent/ban')
endpoint = GetApiServerUri(apiEndpoints.spireAgentsBanApi)
}

if (selectedRows === undefined || !selectedRows) return ""
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/tables/clusters-list-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ClustersList } from "components/types";
import { DenormalizedRow } from "carbon-components-react";
import { RootState } from "redux/reducers";
import { showResponseToast } from "components/error-api";
import apiEndpoints from 'components/apiConfig';

// ClusterListTable takes in
// listTableData: clusters data to be rendered on table
Expand Down Expand Up @@ -95,7 +96,7 @@ class ClustersListTable extends React.Component<ClustersListTableProp, ClustersL
endpoint = GetApiServerUri('/manager-api/tornjak/clusters/delete') + "/" + this.props.globalServerSelected

} else {
endpoint = GetApiServerUri('/api/tornjak/clusters/delete')
endpoint = GetApiServerUri(apiEndpoints.tornjakClustersApi)
}

if (!selectedRows) return ""
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/tables/entries-list-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { RootState } from "redux/reducers";
import { DenormalizedRow } from "carbon-components-react";
import { saveAs } from "file-saver";
import { showResponseToast } from "components/error-api";
import apiEndpoints from 'components/apiConfig';

// EntriesListTable takes in
// listTableData: entries data to be rendered on table
Expand Down Expand Up @@ -88,7 +89,7 @@ class EntriesListTable extends React.Component<EntriesListTableProp, EntriesList
if (IsManager) {
endpoint = GetApiServerUri('/manager-api/entry/delete') + "/" + this.props.globalServerSelected
} else {
endpoint = GetApiServerUri('/api/entry/delete')
endpoint = GetApiServerUri(apiEndpoints.spireEntriesApi)
}
if (selectedRows.length !== 0) {
for (let i = 0; i < selectedRows.length; i++) {
Expand Down

0 comments on commit 179f773

Please sign in to comment.