Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add more services in trans
  • Loading branch information
iamfaran committed May 30, 2025
commit f4bca6275d5a71f4e3dcce99c4fd49179ffb21b3
46 changes: 46 additions & 0 deletions client/packages/lowcoder/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2829,6 +2829,22 @@ export const en = {
"inputFieldPlaceholder": "Enter {label}"
},

// Add contact lowcoder modal
"contactLowcoder": {
"title": "Contact Lowcoder Team",
"environmentLabel": "Environment:",
"environmentIdLabel": "Environment ID:",
"deploymentIdLabel": "Deployment ID:",
"loading": "Loading...",
"notAvailable": "Not available",
"unnamedEnvironment": "Unnamed Environment",
"fetchingDeploymentInfo": "Fetching deployment information...",
"unableToLoadContactForm": "Unable to Load Contact Form",
"apiConfigurationError": "Environment API service URL or API key not configured",
"failedToFetchDeploymentId": "Failed to fetch deployment ID",
"ensureProperConfiguration": "Please ensure the environment is properly configured to contact support."
},

"credentialConfirmations": {
"firstConfirmation": {
"title": "Overwrite Credentials Warning",
Expand Down Expand Up @@ -2918,6 +2934,36 @@ export const en = {
"apps": {
"failedToFetchApps": "Failed to fetch apps",
"failedToDeployApp": "Failed to deploy app"
},
"datasources": {
"workspaceIdRequired": "Workspace ID is required",
"apiKeyRequiredToFetchDataSources": "API key is required to fetch data sources",
"apiServiceUrlRequiredToFetchDataSources": "API service URL is required to fetch data sources",
"failedToFetchDataSources": "Failed to fetch data sources",
"failedToDeployDataSource": "Failed to deploy data source"
},
"workspace": {
"failedToFetchWorkspaces": "Failed to fetch workspaces",
"failedToDeployWorkspace": "Failed to deploy workspace"
},
"managedObjects": {
"missingRequiredParameters": "Missing required parameters",
"failedToCheckManagedStatus": "Failed to check managed status",
"failedToSetAsManaged": "Failed to set {{objType}} as managed",
"failedToRemoveFromManaged": "Failed to remove {{objType}} from managed",
"missingEnvironmentId": "Missing environment ID",
"failedToFetchManagedObjects": "Failed to fetch managed objects",
"failedToFetchManagedObject": "Failed to fetch managed object",
"managedObjectNotFound": "Managed object not found for objGid: {{objGid}}"
},
"license": {
"apiServiceUrlRequired": "API service URL is required",
"licenseInformationUnavailable": "License information unavailable",
"licenseCheckTookTooLong": "License check took too long",
"licenseServiceNotAvailable": "License service not available",
"authenticationRequired": "Authentication required - please check API key",
"licenseServiceTemporarilyUnavailable": "License service temporarily unavailable",
"remainingAPICalls": "{{remaining}} remaining ({{used}}/{{total}} used, {{percentage}}%)",
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
import { Modal, Card, Row, Col, Typography, Divider, Spin, Alert } from 'antd';
import { CustomerServiceOutlined, CloudServerOutlined } from '@ant-design/icons';
import { useSelector } from 'react-redux';
import { trans } from 'i18n';
import { Environment } from '../types/environment.types';
import { getEnvironmentDeploymentId } from '../services/environments.service';
import { HubspotModal } from '../../hubspotModal';
Expand Down Expand Up @@ -34,7 +35,7 @@ const ContactLowcoderModal: React.FC<ContactLowcoderModalProps> = ({
const fetchDeploymentId = async () => {
if (!visible || !environment.environmentApiServiceUrl || !environment.environmentApikey) {
if (visible) {
setError('Environment API service URL or API key not configured');
setError(trans('enterprise.environments.contactLowcoder.apiConfigurationError'));
}
return;
}
Expand All @@ -51,7 +52,7 @@ const ContactLowcoderModal: React.FC<ContactLowcoderModalProps> = ({
setShowHubspotModal(true);
} catch (err) {
console.error('Failed to fetch deployment ID:', err);
setError(err instanceof Error ? err.message : 'Failed to fetch deployment ID');
setError(err instanceof Error ? err.message : trans('enterprise.environments.contactLowcoder.failedToFetchDeploymentId'));
} finally {
setIsLoading(false);
}
Expand Down Expand Up @@ -91,7 +92,7 @@ const ContactLowcoderModal: React.FC<ContactLowcoderModalProps> = ({
title={
<div style={{ display: 'flex', alignItems: 'center', gap: '12px' }}>
<CustomerServiceOutlined style={{ fontSize: '20px', color: '#1890ff' }} />
<span style={{ fontSize: '18px', fontWeight: 600 }}>Contact Lowcoder Team</span>
<span style={{ fontSize: '18px', fontWeight: 600 }}>{trans('enterprise.environments.contactLowcoder.title')}</span>
</div>
}
open={visible}
Expand Down Expand Up @@ -119,15 +120,15 @@ const ContactLowcoderModal: React.FC<ContactLowcoderModalProps> = ({
<Col flex={1}>
<div>
<Text strong style={{ fontSize: '16px', color: '#262626' }}>
Environment: {environment.environmentName || 'Unnamed Environment'}
{trans('enterprise.environments.contactLowcoder.environmentLabel')} {environment.environmentName || trans('enterprise.environments.contactLowcoder.unnamedEnvironment')}
</Text>
<br />
<Text style={{ fontSize: '14px', color: '#8c8c8c', fontFamily: 'monospace' }}>
Environment ID: {environment.environmentId}
{trans('enterprise.environments.contactLowcoder.environmentIdLabel')} {environment.environmentId}
</Text>
<br />
<Text style={{ fontSize: '14px', color: '#8c8c8c', fontFamily: 'monospace' }}>
Deployment ID: {isLoading ? 'Loading...' : deploymentId || 'Not available'}
{trans('enterprise.environments.contactLowcoder.deploymentIdLabel')} {isLoading ? trans('enterprise.environments.contactLowcoder.loading') : deploymentId || trans('enterprise.environments.contactLowcoder.notAvailable')}
</Text>
</div>
</Col>
Expand All @@ -148,14 +149,14 @@ const ContactLowcoderModal: React.FC<ContactLowcoderModalProps> = ({
}}>
<Spin size="large" />
<Text style={{ marginTop: '16px', color: '#8c8c8c' }}>
Fetching deployment information...
{trans('enterprise.environments.contactLowcoder.fetchingDeploymentInfo')}
</Text>
</div>
)}

{error && (
<Alert
message="Unable to Load Contact Form"
message={trans('enterprise.environments.contactLowcoder.unableToLoadContactForm')}
description={error}
type="error"
showIcon
Expand All @@ -170,7 +171,7 @@ const ContactLowcoderModal: React.FC<ContactLowcoderModalProps> = ({
fontSize: '14px'
}}>
<CustomerServiceOutlined style={{ fontSize: '48px', marginBottom: '16px', color: '#d9d9d9' }} />
<div>Please ensure the environment is properly configured to contact support.</div>
<div>{trans('enterprise.environments.contactLowcoder.ensureProperConfiguration')}</div>
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// services/dataSources.service.ts
import axios from 'axios';
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
import { trans } from "i18n";
import { DataSource, DataSourceWithMeta } from "../types/datasource.types";
import { getManagedObjects, ManagedObject, ManagedObjectType , transferManagedObject } from "./managed-objects.service";

Expand Down Expand Up @@ -32,15 +33,15 @@ export async function getWorkspaceDataSources(
try {
// Check if required parameters are provided
if (!workspaceId) {
throw new Error('Workspace ID is required');
throw new Error(trans("enterprise.environments.services.datasources.workspaceIdRequired"));
}

if (!apiKey) {
throw new Error('API key is required to fetch data sources');
throw new Error(trans("enterprise.environments.services.datasources.apiKeyRequiredToFetchDataSources"));
}

if (!apiServiceUrl) {
throw new Error('API service URL is required to fetch data sources');
throw new Error(trans("enterprise.environments.services.datasources.apiServiceUrlRequiredToFetchDataSources"));
}

// Set up headers with the Bearer token format
Expand All @@ -64,7 +65,7 @@ export async function getWorkspaceDataSources(
return response.data.data;
} catch (error) {
// Handle and transform error
const errorMessage = error instanceof Error ? error.message : 'Failed to fetch data sources';
const errorMessage = error instanceof Error ? error.message : trans("enterprise.environments.services.datasources.failedToFetchDataSources");
messageInstance.error(errorMessage);
throw error;
}
Expand Down Expand Up @@ -143,7 +144,7 @@ export async function getMergedWorkspaceDataSources(
};
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : "Failed to fetch data sources";
error instanceof Error ? error.message : trans("enterprise.environments.services.datasources.failedToFetchDataSources");
messageInstance.error(errorMessage);
throw error;
}
Expand All @@ -170,7 +171,7 @@ export async function deployDataSource(params: DeployDataSourceParams): Promise<
}
return response.status === 200;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : 'Failed to deploy data source';
const errorMessage = error instanceof Error ? error.message : trans("enterprise.environments.services.datasources.failedToDeployDataSource");
messageInstance.error(errorMessage);
throw error;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from 'axios';
import { trans } from 'i18n';
import { EnvironmentLicense, DetailedLicenseInfo } from '../types/environment.types';

/**
Expand All @@ -15,7 +16,7 @@ export async function checkEnvironmentLicense(
if (!apiServiceUrl) {
return {
isValid: false,
error: 'API service URL is required'
error: trans('enterprise.environments.services.license.apiServiceUrlRequired')
};
}

Expand All @@ -30,7 +31,7 @@ export async function checkEnvironmentLicense(
`${apiServiceUrl}/api/plugins/enterprise/license`,
{
headers,
timeout: 500 // Very short timeout for immediate failure when endpoint doesn't exist
timeout: 1500 // Very short timeout for immediate failure when endpoint doesn't exist
}
);

Expand Down Expand Up @@ -65,17 +66,17 @@ export async function checkEnvironmentLicense(

} catch (error) {
// Determine the specific error type
let errorMessage = 'License information unavailable';
let errorMessage = trans('enterprise.environments.services.license.licenseInformationUnavailable');

if (axios.isAxiosError(error)) {
if (error.code === 'ECONNABORTED') {
errorMessage = 'License check took too long';
errorMessage = trans('enterprise.environments.services.license.licenseCheckTookTooLong');
} else if (error.response?.status === 404) {
errorMessage = 'License service not available';
errorMessage = trans('enterprise.environments.services.license.licenseServiceNotAvailable');
} else if (error.response?.status === 401) {
errorMessage = 'Authentication required - please check API key';
errorMessage = trans('enterprise.environments.services.license.authenticationRequired');
} else if (error.response && error.response.status >= 500) {
errorMessage = 'License service temporarily unavailable';
errorMessage = trans('enterprise.environments.services.license.licenseServiceTemporarilyUnavailable');
}
}

Expand All @@ -96,7 +97,12 @@ export function formatAPICalls(remaining: number, total: number): string {
const used = total - remaining;
const percentage = total > 0 ? Math.round((used / total) * 100) : 0;

return `${remaining.toLocaleString()} remaining (${used.toLocaleString()}/${total.toLocaleString()} used, ${percentage}%)`;
return trans('enterprise.environments.services.license.remainingAPICalls', {
remaining: remaining.toLocaleString(),
used: used.toLocaleString(),
total: total.toLocaleString(),
percentage
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from "axios";
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
import { trans } from "i18n";

// Object types that can be managed
export enum ManagedObjectType {
Expand Down Expand Up @@ -32,7 +33,7 @@ export async function isManagedObject(
): Promise<boolean> {
try {
if (!objGid || !environmentId || !objType) {
throw new Error("Missing required parameters");
throw new Error(trans("enterprise.environments.services.managedObjects.missingRequiredParameters"));
}

const response = await axios.get(`/api/plugins/enterprise/managed-obj`, {
Expand All @@ -50,7 +51,7 @@ export async function isManagedObject(
return false;
}

const errorMessage = error instanceof Error ? error.message : "Failed to check managed status";
const errorMessage = error instanceof Error ? error.message : trans("enterprise.environments.services.managedObjects.failedToCheckManagedStatus");
messageInstance.error(errorMessage);
throw error;
}
Expand All @@ -73,7 +74,7 @@ export async function setManagedObject(
): Promise<boolean> {
try {
if (!objGid || !environmentId || !objType) {
throw new Error("Missing required parameters");
throw new Error(trans("enterprise.environments.services.managedObjects.missingRequiredParameters"));
}

const requestBody = {
Expand All @@ -87,7 +88,7 @@ export async function setManagedObject(

return response.status === 200;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : `Failed to set ${objType} as managed`;
const errorMessage = error instanceof Error ? error.message : trans("enterprise.environments.services.managedObjects.failedToSetAsManaged", { objType });
messageInstance.error(errorMessage);
throw error;
}
Expand All @@ -108,7 +109,7 @@ export async function unsetManagedObject(
): Promise<boolean> {
try {
if (!objGid || !environmentId || !objType) {
throw new Error("Missing required parameters");
throw new Error(trans("enterprise.environments.services.managedObjects.missingRequiredParameters"));
}

const response = await axios.delete(`/api/plugins/enterprise/managed-obj`, {
Expand All @@ -121,7 +122,7 @@ export async function unsetManagedObject(

return response.status === 200;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : `Failed to remove ${objType} from managed`;
const errorMessage = error instanceof Error ? error.message : trans("enterprise.environments.services.managedObjects.failedToRemoveFromManaged", { objType });
messageInstance.error(errorMessage);
throw error;
}
Expand All @@ -134,7 +135,7 @@ export async function getManagedObjects(
): Promise<ManagedObject[]> {
try {
if (!environmentId) {
throw new Error("Missing environment ID");
throw new Error(trans("enterprise.environments.services.managedObjects.missingEnvironmentId"));
}

const response = await axios.get(`/api/plugins/enterprise/managed-obj/list`, {
Expand All @@ -146,7 +147,7 @@ export async function getManagedObjects(

return response.data.data;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : "Failed to fetch managed objects";
const errorMessage = error instanceof Error ? error.message : trans("enterprise.environments.services.managedObjects.failedToFetchManagedObjects");
messageInstance.error(errorMessage);
throw error;
}
Expand All @@ -166,7 +167,7 @@ export async function getSingleManagedObject(
): Promise<ManagedObject | null> {
try {
if (!objGid || !environmentId || !objType) {
throw new Error("Missing required parameters");
throw new Error(trans("enterprise.environments.services.managedObjects.missingRequiredParameters"));
}

const response = await axios.get(`/api/plugins/enterprise/managed-obj`, {
Expand All @@ -184,7 +185,7 @@ export async function getSingleManagedObject(
return null;
}

const errorMessage = error instanceof Error ? error.message : "Failed to fetch managed object";
const errorMessage = error instanceof Error ? error.message : trans("enterprise.environments.services.managedObjects.failedToFetchManagedObject");
messageInstance.error(errorMessage);
throw error;
}
Expand All @@ -197,7 +198,7 @@ export async function transferManagedObject(objGid: string, sourceEnvId: string,
if (managedObject) {
await setManagedObject(managedObject.objGid, targetEnvId, objType, managedObject.managedId);
} else {
throw new Error(`Managed object not found for objGid: ${objGid}`);
throw new Error(trans("enterprise.environments.services.managedObjects.managedObjectNotFound", { objGid }));
}
} catch (error) {
console.error('Error transferring managed object:', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Get merged queries (both regular and managed) for a workspace
*/
import axios from 'axios';
import { trans } from 'i18n';
import { getManagedObjects, ManagedObjectType, transferManagedObject } from './managed-objects.service';
import { getWorkspaceQueries } from './environments.service';
import { Query, QueryStats } from '../types/query.types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// services/workspacesService.ts (or wherever makes sense in your structure)
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
import { trans } from "i18n";
import { getEnvironmentWorkspaces } from "./environments.service";
import { getManagedObjects, ManagedObject, ManagedObjectType, transferManagedObject } from "./managed-objects.service";
import { Workspace } from "../types/workspace.types";
Expand Down Expand Up @@ -69,7 +70,7 @@ export async function getMergedEnvironmentWorkspaces(
}
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : "Failed to fetch workspaces";
const errorMessage = error instanceof Error ? error.message : trans("enterprise.environments.services.workspace.failedToFetchWorkspaces");
messageInstance.error(errorMessage);
throw error;
}
Expand Down Expand Up @@ -107,7 +108,7 @@ export async function deployWorkspace(params: {

return response.status === 200;
} catch (error) {
const errorMessage = error instanceof Error ? error.message : 'Failed to deploy workspace';
const errorMessage = error instanceof Error ? error.message : trans("enterprise.environments.services.workspace.failedToDeployWorkspace");
// Don't show message directly, let the calling component handle it
throw new Error(errorMessage);
}
Expand Down