Skip to content

[Feat] Add Environments Manually #1712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 26, 2025
Prev Previous commit
Next Next commit
Licensed vs Non-Licensed Envs
  • Loading branch information
iamfaran committed May 26, 2025
commit 04b8fe4113b9f00a26afa3b86ef8b0865a19e624
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState} from "react";
import React, {useState, useEffect} from "react";
import {
Spin,
Typography,
Expand All @@ -9,13 +9,18 @@ import {
Menu,
Button,
Tag,
Result,
} from "antd";
import {
LinkOutlined,
HomeOutlined,
AppstoreOutlined,
UsergroupAddOutlined,
EditOutlined,
CheckCircleOutlined,
CloseCircleOutlined,
ExclamationCircleOutlined,
SyncOutlined,
} from "@ant-design/icons";

import { useSingleEnvironmentContext } from "./context/SingleEnvironmentContext";
Expand Down Expand Up @@ -95,6 +100,56 @@ const EnvironmentDetail: React.FC = () => {
);
}

// Check if environment is not licensed and show restriction message
if (environment.isLicensed === false) {
const getLicenseIcon = () => {
switch (environment.licenseStatus) {
case 'unlicensed':
return <CloseCircleOutlined style={{ color: '#ff4d4f' }} />;
case 'error':
return <ExclamationCircleOutlined style={{ color: '#faad14' }} />;
default:
return <CloseCircleOutlined style={{ color: '#ff4d4f' }} />;
}
};

return (
<div style={{ padding: "24px", flex: 1 }}>
<Result
icon={getLicenseIcon()}
title="Environment Access Restricted"
subTitle={`This environment is not licensed. ${environment.licenseError || 'Please check the license configuration.'}`}
extra={[
<Button
type="primary"
key="back"
onClick={() => history.push("/setting/environments")}
>
Back to Environments
</Button>,
<Button
key="edit"
onClick={handleEditClick}
>
Edit Environment
</Button>
]}
/>

{/* Still allow editing the environment to fix license issues */}
{environment && (
<EditEnvironmentModal
visible={isEditModalVisible}
environment={environment}
onClose={handleCloseModal}
onSave={handleSaveEnvironment}
loading={isUpdating}
/>
)}
</div>
);
}

const breadcrumbItems = [
{
key: 'environments',
Expand Down Expand Up @@ -157,6 +212,22 @@ const EnvironmentDetail: React.FC = () => {
{environment.environmentType}
</Tag>
</Descriptions.Item>
<Descriptions.Item label="License Status">
{(() => {
switch (environment.licenseStatus) {
case 'checking':
return <Tag icon={<SyncOutlined spin />} color="blue" style={{ borderRadius: '12px' }}>Checking...</Tag>;
case 'licensed':
return <Tag icon={<CheckCircleOutlined />} color="green" style={{ borderRadius: '12px' }}>Licensed</Tag>;
case 'unlicensed':
return <Tag icon={<CloseCircleOutlined />} color="red" style={{ borderRadius: '12px' }}>Not Licensed</Tag>;
case 'error':
return <Tag icon={<ExclamationCircleOutlined />} color="orange" style={{ borderRadius: '12px' }}>License Error</Tag>;
default:
return <Tag color="default" style={{ borderRadius: '12px' }}>Unknown</Tag>;
}
})()}
</Descriptions.Item>
<Descriptions.Item label="API Key Status">
{environment.environmentApikey ? (
<Tag color="green" style={{ borderRadius: '12px' }}>Configured</Tag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ const EnvironmentsList: React.FC = () => {

// Handle row click to navigate to environment detail
const handleRowClick = (record: Environment) => {
// Prevent navigation for unlicensed environments
if (record.isLicensed === false) {
return;
}
history.push(buildEnvironmentId(record.environmentId));
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Modal, Form, Input, Select, Switch, Button } from 'antd';
import { Modal, Form, Input, Select, Switch, Button, Alert } from 'antd';
import { Environment } from '../types/environment.types';

const { Option } = Select;
Expand Down Expand Up @@ -153,6 +153,14 @@ const CreateEnvironmentModal: React.FC<CreateEnvironmentModalProps> = ({
>
<Switch />
</Form.Item>

<Alert
message="License Information"
description="After creating the environment, the system will automatically check the license status. Make sure the API service URL and API key are correctly configured for license validation."
type="info"
showIcon
style={{ marginTop: '16px' }}
/>
</Form>
</Modal>
);
Expand Down
Loading