Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* under the License.
*/

import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, useContext } from 'react';
import { styled } from '@mui/material/styles';
import PropTypes from 'prop-types';
import {
Expand All @@ -37,6 +37,7 @@ import LaunchIcon from '@mui/icons-material/Launch';
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router-dom';
import API from 'AppData/api';
import { APIContext } from 'AppComponents/Apis/Details/components/ApiContext';
import Configurations from 'Config';
import Banner from 'AppComponents/Shared/Banner';

Expand Down Expand Up @@ -108,6 +109,9 @@ export default function Credentials(props) {
} = props;

const [pageError, setPageError] = useState(null);
const apiContext = useContext(APIContext);
const currentApi = apiContext?.api;
const isAPIProduct = currentApi?.apiType === API.CONSTS.APIProduct;
const handleChange = (event) => {
const newEndpointConfig = { ...endpointConfig };
newEndpointConfig.access_method = event.target.value;
Expand All @@ -126,12 +130,16 @@ export default function Credentials(props) {
endpointsDispatcher({ action: 'set_awsCredentials', value: newEndpointConfig });
};
const { regions } = Configurations.apis.endpoint.aws;
useEffect(() => {
useEffect(() => {
if (isAPIProduct) {
return;
}

API.getAmznResourceNames(apiId)
.catch((error) => {
setPageError(error.response.body.error);
});
}, []);
}, [apiId, isAPIProduct]);
return (
(<Root>
<Grid item md={12} xs={12}>
Expand Down