Skip to content

Commit 04b8fe4

Browse files
committed
Licensed vs Non-Licensed Envs
1 parent 536e7bb commit 04b8fe4

File tree

8 files changed

+459
-98
lines changed

8 files changed

+459
-98
lines changed

client/packages/lowcoder/src/pages/setting/environments/EnvironmentDetail.tsx

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useState} from "react";
1+
import React, {useState, useEffect} from "react";
22
import {
33
Spin,
44
Typography,
@@ -9,13 +9,18 @@ import {
99
Menu,
1010
Button,
1111
Tag,
12+
Result,
1213
} from "antd";
1314
import {
1415
LinkOutlined,
1516
HomeOutlined,
1617
AppstoreOutlined,
1718
UsergroupAddOutlined,
1819
EditOutlined,
20+
CheckCircleOutlined,
21+
CloseCircleOutlined,
22+
ExclamationCircleOutlined,
23+
SyncOutlined,
1924
} from "@ant-design/icons";
2025

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

103+
// Check if environment is not licensed and show restriction message
104+
if (environment.isLicensed === false) {
105+
const getLicenseIcon = () => {
106+
switch (environment.licenseStatus) {
107+
case 'unlicensed':
108+
return <CloseCircleOutlined style={{ color: '#ff4d4f' }} />;
109+
case 'error':
110+
return <ExclamationCircleOutlined style={{ color: '#faad14' }} />;
111+
default:
112+
return <CloseCircleOutlined style={{ color: '#ff4d4f' }} />;
113+
}
114+
};
115+
116+
return (
117+
<div style={{ padding: "24px", flex: 1 }}>
118+
<Result
119+
icon={getLicenseIcon()}
120+
title="Environment Access Restricted"
121+
subTitle={`This environment is not licensed. ${environment.licenseError || 'Please check the license configuration.'}`}
122+
extra={[
123+
<Button
124+
type="primary"
125+
key="back"
126+
onClick={() => history.push("/setting/environments")}
127+
>
128+
Back to Environments
129+
</Button>,
130+
<Button
131+
key="edit"
132+
onClick={handleEditClick}
133+
>
134+
Edit Environment
135+
</Button>
136+
]}
137+
/>
138+
139+
{/* Still allow editing the environment to fix license issues */}
140+
{environment && (
141+
<EditEnvironmentModal
142+
visible={isEditModalVisible}
143+
environment={environment}
144+
onClose={handleCloseModal}
145+
onSave={handleSaveEnvironment}
146+
loading={isUpdating}
147+
/>
148+
)}
149+
</div>
150+
);
151+
}
152+
98153
const breadcrumbItems = [
99154
{
100155
key: 'environments',
@@ -157,6 +212,22 @@ const EnvironmentDetail: React.FC = () => {
157212
{environment.environmentType}
158213
</Tag>
159214
</Descriptions.Item>
215+
<Descriptions.Item label="License Status">
216+
{(() => {
217+
switch (environment.licenseStatus) {
218+
case 'checking':
219+
return <Tag icon={<SyncOutlined spin />} color="blue" style={{ borderRadius: '12px' }}>Checking...</Tag>;
220+
case 'licensed':
221+
return <Tag icon={<CheckCircleOutlined />} color="green" style={{ borderRadius: '12px' }}>Licensed</Tag>;
222+
case 'unlicensed':
223+
return <Tag icon={<CloseCircleOutlined />} color="red" style={{ borderRadius: '12px' }}>Not Licensed</Tag>;
224+
case 'error':
225+
return <Tag icon={<ExclamationCircleOutlined />} color="orange" style={{ borderRadius: '12px' }}>License Error</Tag>;
226+
default:
227+
return <Tag color="default" style={{ borderRadius: '12px' }}>Unknown</Tag>;
228+
}
229+
})()}
230+
</Descriptions.Item>
160231
<Descriptions.Item label="API Key Status">
161232
{environment.environmentApikey ? (
162233
<Tag color="green" style={{ borderRadius: '12px' }}>Configured</Tag>

client/packages/lowcoder/src/pages/setting/environments/EnvironmentsList.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ const EnvironmentsList: React.FC = () => {
4747

4848
// Handle row click to navigate to environment detail
4949
const handleRowClick = (record: Environment) => {
50+
// Prevent navigation for unlicensed environments
51+
if (record.isLicensed === false) {
52+
return;
53+
}
5054
history.push(buildEnvironmentId(record.environmentId));
5155
};
5256

client/packages/lowcoder/src/pages/setting/environments/components/CreateEnvironmentModal.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import { Modal, Form, Input, Select, Switch, Button } from 'antd';
2+
import { Modal, Form, Input, Select, Switch, Button, Alert } from 'antd';
33
import { Environment } from '../types/environment.types';
44

55
const { Option } = Select;
@@ -153,6 +153,14 @@ const CreateEnvironmentModal: React.FC<CreateEnvironmentModalProps> = ({
153153
>
154154
<Switch />
155155
</Form.Item>
156+
157+
<Alert
158+
message="License Information"
159+
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."
160+
type="info"
161+
showIcon
162+
style={{ marginTop: '16px' }}
163+
/>
156164
</Form>
157165
</Modal>
158166
);

0 commit comments

Comments
 (0)