Skip to content

Commit fbbf3ca

Browse files
authored
Merge pull request #472 from easyops-cn/steve/sidebar
fix(): add serviceflow
2 parents 9e46559 + 81ff91f commit fbbf3ca

File tree

5 files changed

+39
-10
lines changed

5 files changed

+39
-10
lines changed

bricks/ai-portal/src/elevo-sidebar/ChatHistory.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type {
1717
ActionType,
1818
SimpleActionType,
1919
} from "@next-bricks/basic/mini-actions";
20-
import type { GeneralIconProps } from "@next-bricks/icons/general-icon";
2120
import { isEqual } from "lodash";
2221
import { K, t } from "./i18n.js";
2322
import {
@@ -32,11 +31,7 @@ import type { ConversationState } from "../shared/interfaces.js";
3231
import type { SidebarLink } from "./interfaces.js";
3332
import { NavLink } from "./NavLink.js";
3433
import { SectionTitle } from "./SectionTitle.js";
35-
36-
const ADD_ICON: GeneralIconProps = {
37-
lib: "fa",
38-
icon: "plus",
39-
};
34+
import { ADD_ICON } from "./constants.js";
4035

4136
export interface HistoryItem {
4237
conversationId: string;

bricks/ai-portal/src/elevo-sidebar/SpaceNav.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import React, { useRef, useState } from "react";
22
import classNames from "classnames";
33
import { SectionTitle } from "./SectionTitle.js";
44
import { K, t } from "./i18n.js";
5-
import { WrappedIcon, WrappedLink } from "./bricks.js";
5+
import { WrappedIcon, WrappedIconButton, WrappedLink } from "./bricks.js";
66
import { NavLink } from "./NavLink.js";
77
import type { SidebarLink } from "./interfaces.js";
8+
import { ADD_ICON } from "./constants.js";
89

910
export interface SpaceNavProps {
1011
returnUrl: string;
@@ -17,13 +18,18 @@ export interface SpaceNavProps {
1718
spaceLinks?: SidebarLink[];
1819
}
1920

21+
export interface SpaceNavComponentProps extends SpaceNavProps {
22+
onAddServiceflow?: () => void;
23+
}
24+
2025
export function SpaceNav({
2126
returnUrl,
2227
spaceDetail,
2328
spaceObjects,
2429
spaceServiceflows,
2530
spaceLinks,
26-
}: SpaceNavProps) {
31+
onAddServiceflow,
32+
}: SpaceNavComponentProps) {
2733
const rootRef = useRef<HTMLDivElement | null>(null);
2834
const [objectsCollapsed, setObjectsCollapsed] = useState(false);
2935
const [serviceflowsCollapsed, setServiceflowsCollapsed] = useState(false);
@@ -80,7 +86,16 @@ export function SpaceNav({
8086
title={t(K.SERVICEFLOWS)}
8187
collapsed={serviceflowsCollapsed}
8288
onToggle={() => setServiceflowsCollapsed((prev) => !prev)}
83-
/>
89+
>
90+
<WrappedIconButton
91+
icon={ADD_ICON}
92+
variant="mini-light"
93+
tooltip={t(K.CREATE_SERVICEFLOW)}
94+
tooltipHoist={true}
95+
className="button"
96+
onClick={onAddServiceflow}
97+
/>
98+
</SectionTitle>
8499
<ul className="items">
85100
{spaceServiceflows.map((obj, index) => (
86101
<li key={index}>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { GeneralIconProps } from "@next-bricks/icons/general-icon";
2+
3+
export const ADD_ICON: GeneralIconProps = {
4+
lib: "fa",
5+
icon: "plus",
6+
};

bricks/ai-portal/src/elevo-sidebar/i18n.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export enum K {
1818
BUSINESS_OBJECTS = "BUSINESS_OBJECTS",
1919
SERVICEFLOWS = "SERVICEFLOWS",
2020
COLLABORATION_SPACES = "COLLABORATION_SPACES",
21+
CREATE_SERVICEFLOW = "CREATE_SERVICEFLOW",
2122
}
2223

2324
const en: Locale = {
@@ -38,6 +39,7 @@ const en: Locale = {
3839
[K.BUSINESS_OBJECTS]: "Business objects",
3940
[K.SERVICEFLOWS]: "Serviceflows",
4041
[K.COLLABORATION_SPACES]: "Collaboration spaces",
42+
[K.CREATE_SERVICEFLOW]: "Create serviceflow",
4143
};
4244

4345
const zh: Locale = {
@@ -58,6 +60,7 @@ const zh: Locale = {
5860
[K.BUSINESS_OBJECTS]: "业务对象",
5961
[K.SERVICEFLOWS]: "业务流",
6062
[K.COLLABORATION_SPACES]: "协作空间",
63+
[K.CREATE_SERVICEFLOW]: "创建业务流",
6164
};
6265

6366
export const NS = "bricks/ai-portal/elevo-sidebar";

bricks/ai-portal/src/elevo-sidebar/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ class ElevoSidebar extends ReactNextElement implements ElevoSidebarProps {
163163
this.#addProject.emit();
164164
};
165165

166+
@event({ type: "add.serviceflow" })
167+
accessor #addServiceflow!: EventEmitter<void>;
168+
169+
#handleAddServiceflow = () => {
170+
this.#addServiceflow.emit();
171+
};
172+
166173
#ref = createRef<ElevoSidebarRef>();
167174

168175
/**
@@ -223,6 +230,7 @@ class ElevoSidebar extends ReactNextElement implements ElevoSidebarProps {
223230
onActionClick={this.#handleActionClick}
224231
onProjectActionClick={this.#handleProjectActionClick}
225232
onAddProject={this.#handleAddProject}
233+
onAddServiceflow={this.#handleAddServiceflow}
226234
/>
227235
);
228236
}
@@ -233,6 +241,7 @@ interface ElevoSidebarComponentProps extends ElevoSidebarProps {
233241
onActionClick: (detail: ActionClickDetail) => void;
234242
onProjectActionClick: (detail: ProjectActionClickDetail) => void;
235243
onAddProject: () => void;
244+
onAddServiceflow: () => void;
236245
}
237246

238247
function LegacyElevoSidebarComponent(
@@ -255,6 +264,7 @@ function LegacyElevoSidebarComponent(
255264
onActionClick,
256265
onProjectActionClick,
257266
onAddProject,
267+
onAddServiceflow,
258268
}: ElevoSidebarComponentProps,
259269
ref: React.Ref<ElevoSidebarRef>
260270
) {
@@ -367,7 +377,7 @@ function LegacyElevoSidebarComponent(
367377
</div>
368378
<div className="main">
369379
{scope === "space" ? (
370-
<SpaceNav {...spaceNav!} />
380+
<SpaceNav onAddServiceflow={onAddServiceflow} {...spaceNav!} />
371381
) : (
372382
<>
373383
<WrappedLink className="new-chat" url={newChatUrl}>

0 commit comments

Comments
 (0)