Skip to content

Commit 917ed8a

Browse files
fix: address PR #55 review feedback
- Remove unused .project-list-card-clickable-content CSS class - Reduce !important usage in schema select styles, increase specificity instead - Replace duplicate API call with explorerService.setProjectSchema - Replace message.success/error with useNotificationService for consistency - Show error InfoChip when schema list is empty instead of hiding dropdown - Revert project_schema max_length change (will be added to PR #54 with migration)
1 parent 0e4e424 commit 917ed8a

4 files changed

Lines changed: 30 additions & 41 deletions

File tree

backend/backend/core/models/project_details.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def delete(self, *args, **kwargs):
102102
project_path = models.CharField(max_length=100)
103103
profile_path = models.CharField(max_length=100)
104104

105-
project_schema = models.CharField(max_length=1024, blank=True, null=True)
105+
project_schema = models.CharField(max_length=20, blank=True, null=True)
106106
# User specific access control fields
107107
created_by = models.JSONField(default=dict)
108108
created_at = models.DateTimeField(auto_now_add=True)

frontend/src/base/components/project-list/ProjectListCard.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,6 @@
171171
}
172172

173173
/* ---------- body ---------- */
174-
.project-list-card-clickable-content {
175-
/* clickable via parent wrapper */
176-
}
177-
178174
.project-list-card-detail-section {
179175
padding: 12px 14px;
180176
}

frontend/src/ide/chat-ai/ChatAI.css

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -443,24 +443,25 @@
443443
.chat-ai-info-chip:has(.chat-ai-schema-select) {
444444
padding: 3px 4px 3px 10px;
445445
}
446-
.chat-ai-schema-select {
446+
/* Schema select inside info chip — !important needed to override Ant Design inline styles */
447+
.chat-ai-info-chip .chat-ai-schema-select {
447448
max-width: 180px;
448449
}
449-
.chat-ai-schema-select.ant-select {
450+
.chat-ai-info-chip .chat-ai-schema-select.ant-select {
450451
height: 16px !important;
451452
}
452-
.chat-ai-schema-select .ant-select-selector {
453+
.chat-ai-info-chip .chat-ai-schema-select .ant-select-selector {
453454
padding: 0 !important;
454455
height: 16px !important;
455456
min-height: unset !important;
456457
}
457-
.chat-ai-schema-select .ant-select-selection-item {
458-
font-size: 10px !important;
459-
line-height: 16px !important;
460-
padding-inline-end: 14px !important;
458+
.chat-ai-info-chip .chat-ai-schema-select .ant-select-selection-item {
459+
font-size: 10px;
460+
line-height: 16px;
461+
padding-inline-end: 14px;
461462
}
462-
.chat-ai-schema-select .ant-select-arrow {
463-
font-size: 8px !important;
463+
.chat-ai-info-chip .chat-ai-schema-select .ant-select-arrow {
464+
font-size: 8px;
464465
right: 0;
465466
inset-block-start: 50%;
466467
}

frontend/src/ide/chat-ai/PromptActions.jsx

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import { memo, useCallback, useEffect, useMemo } from "react";
2-
import {
3-
Space,
4-
Typography,
5-
Select,
6-
Switch,
7-
Segmented,
8-
Tooltip,
9-
message,
10-
} from "antd";
2+
import { Space, Typography, Select, Switch, Segmented, Tooltip } from "antd";
113
import {
124
ConsoleSqlOutlined,
135
DatabaseOutlined,
@@ -16,15 +8,15 @@ import {
168
WalletOutlined,
179
} from "@ant-design/icons";
1810
import PropTypes from "prop-types";
19-
import Cookies from "js-cookie";
2011

2112
import { CHAT_INTENTS } from "./helper";
2213
import CircularTokenDisplay from "./CircularTokenDisplay";
14+
import InfoChip from "./InfoChip";
2315
import { useTokenStore } from "../../store/token-store";
2416
import { useSessionStore } from "../../store/session-store";
2517
import { useProjectStore } from "../../store/project-store";
26-
import { orgStore } from "../../store/org-store";
27-
import { useAxiosPrivate } from "../../service/axios-service";
18+
import { explorerService } from "../explorer/explorer-service";
19+
import { useNotificationService } from "../../service/notification-service";
2820

2921
// Define hidden intents and a fixed order array
3022
const HIDDEN_CHAT_INTENTS = ["AUTO", "NOTA", "INFO"];
@@ -66,8 +58,8 @@ const PromptActions = memo(function PromptActions({
6658
const setCurrentSchema = useProjectStore((state) => state.setCurrentSchema);
6759
const schemaList = useProjectStore((state) => state.schemaList);
6860
const projectId = useProjectStore((state) => state.projectId);
69-
const { selectedOrgId } = orgStore();
70-
const axios = useAxiosPrivate();
61+
const expService = explorerService();
62+
const { notify } = useNotificationService();
7163

7264
const schemaOptions = useMemo(
7365
() => schemaList.map((s) => ({ label: s, value: s })),
@@ -76,25 +68,18 @@ const PromptActions = memo(function PromptActions({
7668

7769
const handleSchemaChange = useCallback(
7870
(value) => {
79-
const csrfToken = Cookies.get("csrftoken");
80-
axios({
81-
url: `/api/v1/visitran/${
82-
selectedOrgId || "default_org"
83-
}/project/${projectId}/set_schema`,
84-
method: "POST",
85-
data: { schema_name: value },
86-
headers: { "X-CSRFToken": csrfToken },
87-
})
71+
expService
72+
.setProjectSchema(projectId, value)
8873
.then(() => {
8974
setCurrentSchema(value);
90-
message.success("Schema updated successfully");
75+
notify({ type: "success", message: "Schema updated successfully" });
9176
})
9277
.catch((error) => {
9378
console.error(error);
94-
message.error("Failed to update schema");
79+
notify({ error });
9580
});
9681
},
97-
[axios, selectedOrgId, projectId, setCurrentSchema]
82+
[expService, projectId, setCurrentSchema, notify]
9883
);
9984

10085
const llmOptions = useMemo(
@@ -213,7 +198,7 @@ const PromptActions = memo(function PromptActions({
213198
)}
214199

215200
{/* Schema selector */}
216-
{schemaList.length > 0 && (
201+
{schemaList.length > 0 ? (
217202
<div className="chat-ai-info-chip chat-ai-info-chip-clickable">
218203
<DatabaseOutlined className="chat-ai-info-chip-icon" />
219204
<Select
@@ -228,6 +213,13 @@ const PromptActions = memo(function PromptActions({
228213
className="chat-ai-schema-select"
229214
/>
230215
</div>
216+
) : (
217+
<InfoChip
218+
icon={<DatabaseOutlined className="chat-ai-info-chip-icon" />}
219+
text="No schema"
220+
tooltipTitle="No schemas available. Please configure a database connection and select a schema from the explorer."
221+
className="chat-ai-info-chip-error"
222+
/>
231223
)}
232224
</Space>
233225

0 commit comments

Comments
 (0)