Skip to content

Commit

Permalink
Refactor into existing Workspace component
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Sep 25, 2023
1 parent 5b1b446 commit 42a6fa6
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 233 deletions.
1 change: 1 addition & 0 deletions common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export const PLUGIN_ID = 'aiFlowDashboards';

export const BASE_NODE_API_PATH = '/api/ai_flow';
Expand Down
74 changes: 74 additions & 0 deletions common/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { Node, Edge } from 'reactflow';
import { IComponent } from '../public/component_types';

/**
* TODO: remove hardcoded nodes/edges.
*
* Converts the stored IComponents into the low-level ReactFlow nodes and edges.
* This may change entirely, depending on how/where the ReactFlow JSON will be
* persisted. Using this stub helper fn in the meantime.
*/
export function convertToReactFlowData(components: IComponent[]) {
const dummyNodes = [
{
id: 'semantic-search',
position: { x: 40, y: 10 },
data: { label: 'Semantic Search' },
type: 'group',
style: {
height: 110,
width: 700,
},
},
{
id: 'model',
position: { x: 25, y: 25 },
data: { label: 'Deployed Model ID' },
type: 'default',
parentNode: 'semantic-search',
extent: 'parent',
},
{
id: 'ingest-pipeline',
position: { x: 262, y: 25 },
data: { label: 'Ingest Pipeline Name' },
type: 'default',
parentNode: 'semantic-search',
extent: 'parent',
},
] as Array<
Node<
{
label: string;
},
string | undefined
>
>;

const dummyEdges = [
{
id: 'e1-2',
source: 'model',
target: 'ingest-pipeline',
style: {
strokeWidth: 2,
stroke: 'black',
},
markerEnd: {
type: 'arrow',
strokeWidth: 1,
color: 'black',
},
},
] as Array<Edge<any>>;

return {
rfNodes: dummyNodes,
rfEdges: dummyEdges,
};
}
1 change: 1 addition & 0 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

export * from './constants';
export * from './interfaces';
export * from './helpers';
export { IComponent } from '../public/component_types';
6 changes: 0 additions & 6 deletions public/pages/temp/index.ts

This file was deleted.

141 changes: 0 additions & 141 deletions public/pages/temp/workspace.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
flex-grow: 1;
height: 100%;
}

.workspace {
width: 50vh;
height: 50vh;
padding: 0;
}
Loading

0 comments on commit 42a6fa6

Please sign in to comment.