diff --git a/portal-ui/src/screens/Console/License/License.tsx b/portal-ui/src/screens/Console/License/License.tsx index 800628ea0..298054489 100644 --- a/portal-ui/src/screens/Console/License/License.tsx +++ b/portal-ui/src/screens/Console/License/License.tsx @@ -25,12 +25,7 @@ import { containerForHeader } from "../Common/FormComponents/common/styleLibrary import PageHeader from "../Common/PageHeader/PageHeader"; import api from "../../../common/api"; import { ArrowRightLink, HelpIconFilled, LoginMinIOLogo } from "../../../icons"; -import { hasPermission } from "../../../common/SecureComponent"; -import { - CONSOLE_UI_RESOURCE, - IAM_PAGES, - IAM_PAGES_PERMISSIONS, -} from "../../../common/SecureComponent/permissions"; +import { IAM_PAGES } from "../../../common/SecureComponent/permissions"; import LicensePlans from "./LicensePlans"; import { Link } from "react-router-dom"; import PageLayout from "../Common/Layout/PageLayout"; @@ -131,12 +126,6 @@ const License = () => { const [isLicenseConsentOpen, setIsLicenseConsentOpen] = useState(false); - const getSubnetInfo = hasPermission( - CONSOLE_UI_RESOURCE, - IAM_PAGES_PERMISSIONS[IAM_PAGES.LICENSE], - true - ); - const closeModalAndFetchLicenseInfo = () => { setActivateProductModal(false); fetchLicenseInfo(); @@ -164,32 +153,28 @@ const License = () => { if (loadingLicenseInfo) { return; } - if (getSubnetInfo) { - setLoadingLicenseInfo(true); - api - .invoke("GET", `/api/v1/subnet/info`) - .then((res: SubnetInfo) => { - if (res) { - if (res.plan === "STANDARD") { - setCurrentPlanID(1); - } else if (res.plan === "ENTERPRISE") { - setCurrentPlanID(2); - } else { - setCurrentPlanID(1); - } - setLicenseInfo(res); + setLoadingLicenseInfo(true); + api + .invoke("GET", `/api/v1/subnet/info`) + .then((res: SubnetInfo) => { + if (res) { + if (res.plan === "STANDARD") { + setCurrentPlanID(1); + } else if (res.plan === "ENTERPRISE") { + setCurrentPlanID(2); + } else { + setCurrentPlanID(1); } - setClusterRegistered(true); - setLoadingLicenseInfo(false); - }) - .catch(() => { - setClusterRegistered(false); - setLoadingLicenseInfo(false); - }); - } else { - setLoadingLicenseInfo(false); - } - }, [loadingLicenseInfo, getSubnetInfo]); + setLicenseInfo(res); + } + setClusterRegistered(true); + setLoadingLicenseInfo(false); + }) + .catch(() => { + setClusterRegistered(false); + setLoadingLicenseInfo(false); + }); + }, [loadingLicenseInfo]); useEffect(() => { if (initialLicenseLoading) { diff --git a/portal-ui/src/screens/Console/Support/Register.tsx b/portal-ui/src/screens/Console/Support/Register.tsx index cce4eadea..d78504546 100644 --- a/portal-ui/src/screens/Console/Support/Register.tsx +++ b/portal-ui/src/screens/Console/Support/Register.tsx @@ -190,7 +190,10 @@ const Register = ({ classes }: IRegister) => { setLoadingLicenseInfo(false); }) .catch((err: ErrorResponseHandler) => { - if (err.errorMessage !== "License not found") { + if ( + err.detailedError.toLowerCase() !== + "License is not present".toLowerCase() + ) { dispatch(setErrorSnackMessage(err)); } setClusterRegistered(false); diff --git a/restapi/admin_subnet.go b/restapi/admin_subnet.go index ec20b44db..abf20babf 100644 --- a/restapi/admin_subnet.go +++ b/restapi/admin_subnet.go @@ -23,6 +23,7 @@ import ( "fmt" "net/http" "net/url" + "os" xhttp "github.com/minio/console/pkg/http" @@ -307,22 +308,11 @@ func GetSubnetRegisterResponse(session *models.Principal, params subnetApi.Subne func GetSubnetInfoResponse(session *models.Principal, params subnetApi.SubnetInfoParams) (*models.License, *models.Error) { ctx, cancel := context.WithCancel(params.HTTPRequest.Context()) defer cancel() - mAdmin, err := NewMinioAdminClient(session) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - adminClient := AdminClient{Client: mAdmin} - subnetTokens, err := GetSubnetKeyFromMinIOConfig(ctx, adminClient) - if err != nil { - return nil, ErrorWithContext(ctx, err) - } - if subnetTokens.APIKey == "" { - return nil, ErrorWithContext(ctx, ErrLicenseNotFound) - } client := &xhttp.Client{ Client: GetConsoleHTTPClient(), } - licenseInfo, err := subnet.ParseLicense(client, subnetTokens.License) + + licenseInfo, err := subnet.ParseLicense(client, os.Getenv("CONSOLE_SUBNET_LICENSE")) if err != nil { return nil, ErrorWithContext(ctx, err) }