Skip to content

Commit 80cf5d4

Browse files
committed
hideFlowPresets
1 parent 75f1f1e commit 80cf5d4

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

libs/app-canvas/src/app/component-interface/app-nav-component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface AppNavComponentsProps<T extends BaseNodeInfo> {
4040
parameter2?: any
4141
) => void;
4242
isReadOnly?: boolean;
43+
hideFlowPresets?: boolean;
4344
}
4445

4546
export interface GenericAppNavComponentsProps<T extends BaseNodeInfo> {

libs/app-canvas/src/app/components/navbar-components.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,19 @@ export class NavbarComponent extends Component<
6767
if (props.isReadOnly) {
6868
return;
6969
}
70+
7071
this.template = createTemplate(
7172
`<div class="inline-flex items-center content-center">
7273
<button class="${navBarPrimaryIconButton}"><span class="${navBarIconButtonInnerElement} icon-add"></span></button>
7374
<button class="${navBarIconButton}"><span class="${navBarIconButtonInnerElement} icon-fit_screen"></span></button>
7475
<button class="${navBarIconButton}"><span class="${navBarIconButtonInnerElement} icon-delete"></span></button>
7576
<div></div>
76-
<button class="${navBarButton}">Import</button><select type="select" name="example-flows" class="p-2 m-2 relative max-w-[220px]">
77+
<button class="${navBarButton}">Import</button>
78+
${
79+
props.hideFlowPresets
80+
? ''
81+
: `
82+
<select type="select" name="example-flows" class="p-2 m-2 relative max-w-[220px]">
7783
<option value="">Select example flow</option>
7884
<option value="counter-flow.json">Counter</option>
7985
<option value="basic-condition.json">Basic condition</option>
@@ -89,7 +95,8 @@ export class NavbarComponent extends Component<
8995
<option value="kmeans.json">K-Means clustering</option>
9096
<option value="kmeans-csv-file.json">K-Means clustering of a CSV file</option>
9197
<option value="openai-chat.json">Open AI Chat Completion API</option>
92-
</select>
98+
</select>`
99+
}
93100
<children></children>
94101
</div>`
95102
);
@@ -113,8 +120,10 @@ export class NavbarComponent extends Component<
113120
this.deleteButton = this.centerButton?.nextSibling as HTMLButtonElement;
114121
this.exportButton = this.deleteButton?.nextSibling as HTMLButtonElement;
115122
this.importButton = this.exportButton?.nextSibling as HTMLButtonElement;
116-
this.selectExampleFlow = this.importButton
117-
?.nextSibling as HTMLSelectElement;
123+
if (!this.props.hideFlowPresets) {
124+
this.selectExampleFlow = this.importButton
125+
?.nextSibling as HTMLSelectElement;
126+
}
118127
// this.importScriptButton = this.importButton
119128
// ?.nextSibling as HTMLButtonElement;
120129

@@ -123,7 +132,7 @@ export class NavbarComponent extends Component<
123132
this.deleteButton.addEventListener('click', this.onClickDelete);
124133
//this.exportButton.addEventListener('click', this.onClickExport);
125134
this.importButton.addEventListener('click', this.onClickImport);
126-
this.selectExampleFlow.addEventListener(
135+
this.selectExampleFlow?.addEventListener(
127136
'change',
128137
this.onClickImportExample
129138
);
@@ -159,9 +168,11 @@ export class NavbarComponent extends Component<
159168
this.centerButton,
160169
this.deleteButton,
161170
this.exportButton,
162-
this.importButton,
163-
this.selectExampleFlow
171+
this.importButton
164172
);
173+
if (this.selectExampleFlow) {
174+
this.renderList.push(this.selectExampleFlow);
175+
}
165176
// this.childRoot = this.element.firstChild as HTMLElement;
166177
// this.renderList.push(this.childRoot);
167178
this.rootElement.append(this.element);
@@ -617,5 +628,6 @@ export const NavbarComponents = (props: AppNavComponentsProps<NodeInfo>) => {
617628
showPopup: props.showPopup,
618629
executeCommand: props.executeCommand,
619630
isReadOnly: props.isReadOnly,
631+
hideFlowPresets: props.hideFlowPresets,
620632
});
621633
};

libs/app-canvas/src/app/flow-app.element.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class FlowAppElement extends AppElement<NodeInfo> {
198198
canvasActionPayload: any = undefined;
199199
cancelCameraAnimation: (() => void) | undefined = undefined;
200200
updateToolbarTaskList: (() => void) | undefined = undefined;
201-
201+
hideFlowPresets = false;
202202
initializeNodes: (() => void) | undefined = undefined;
203203
flowId = '1234';
204204

@@ -222,7 +222,8 @@ export class FlowAppElement extends AppElement<NodeInfo> {
222222
) => void,
223223
flowId?: string,
224224
clearPresetRegistry?: boolean,
225-
apiUrlRoot?: string
225+
apiUrlRoot?: string,
226+
hideFlowPresets?: boolean
226227
) {
227228
super(
228229
appRootSelector,
@@ -242,7 +243,7 @@ export class FlowAppElement extends AppElement<NodeInfo> {
242243
if (flowId) {
243244
this.flowId = flowId;
244245
}
245-
246+
this.hideFlowPresets = hideFlowPresets ?? false;
246247
this.onStoreFlow = onStoreFlow;
247248
this.canvasApp.setApiUrlRoot(apiUrlRoot ?? '');
248249
this.canvasApp.setCanvasAction((action, payload?: any) => {
@@ -561,6 +562,7 @@ export class FlowAppElement extends AppElement<NodeInfo> {
561562
rootAppElement: this.rootElement as HTMLElement,
562563
setIsStoring: setIsStoring,
563564
showPopup: this.positionPopup,
565+
hideFlowPresets: this.hideFlowPresets,
564566
executeCommand: (
565567
command: string,
566568
parameter1: any,

0 commit comments

Comments
 (0)