-
Notifications
You must be signed in to change notification settings - Fork 3
Rules manager #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Rules manager #23
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { type RuleGroupType } from "react-querybuilder"; | ||
|
|
||
| export enum RuleDirection { | ||
| EMIT = "emit", // Use "emitted" when describing the act of producing or broadcasting an event. | ||
| CONSUME = "consume", // Use "consumed" when describing the act of receiving and processing an event. | ||
| } | ||
|
|
||
| export enum RuleLogicalOperator { | ||
| AND = "and", | ||
| OR = "or", | ||
| } | ||
|
|
||
| export type TOperator = | ||
| | "equals" | ||
| | "contains" | ||
| | "startsWith" | ||
| | "endsWith" | ||
| | "regex" | ||
| | "exists" | ||
| | "notExists"; | ||
|
|
||
| export enum RuleActionType { | ||
| TRANSFORM = "transform", | ||
| FILTER = "filter", | ||
| ROUTE = "route", | ||
| LOG = "log", | ||
| } | ||
|
|
||
| export enum RuleOperator { | ||
| EQUALS = "equals", | ||
| NOT_EQUALS = "notEquals", | ||
| CONTAINS = "contains", | ||
| NOT_CONTAINS = "notContains", | ||
| STARTS_WITH = "startsWith", | ||
| ENDS_WITH = "endsWith", | ||
| IS_EMPTY = "null", | ||
| NOT_IS_EMPTY = "notNull", | ||
| REGEX = "regex", | ||
| } | ||
|
|
||
| export interface Rule { | ||
| id: string; | ||
| name: string; | ||
| description: string; | ||
| eventType: string; | ||
| direction: RuleDirection; | ||
| targetBrands: string[]; | ||
| conditions: RuleGroupType; | ||
| actions: RuleAction[]; | ||
| enabled: boolean; | ||
| priority: number; | ||
| createdAt: Date; | ||
| updatedAt: Date; | ||
| } | ||
|
|
||
| export interface RuleAction { | ||
| type: RuleActionType; | ||
| target?: string; | ||
| parameters?: Record<string, any>; | ||
| } | ||
|
|
||
| export interface RuleEvaluationResult { | ||
| ruleId: string; | ||
| matched: boolean; | ||
| actions: RuleAction[]; | ||
| executionTime: number; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,92 +1,116 @@ | ||
| /* | ||
| * <license header> | ||
| */ | ||
| /* | ||
| * <license header> | ||
| */ | ||
|
|
||
| import React, { useEffect } from 'react' | ||
| import { Provider, defaultTheme, Grid, View } from '@adobe/react-spectrum' | ||
| import ErrorBoundary from 'react-error-boundary' | ||
| import { HashRouter as Router, Routes, Route } from 'react-router-dom' | ||
| import SpectrumHeader from './common/SpectrumHeader' | ||
| import SideBar from './common/SideBar' | ||
| import { Home } from './Home' | ||
| import { About } from './About' | ||
| import BrandManagerView from './layout/BrandManagerView' | ||
| import RulesManagerView from './RulesManagerView' | ||
| import RulesConfigurationView from './layout/RulesConfigurationView' | ||
| import { apiService } from '../services/api' | ||
| import React, { useEffect } from "react"; | ||
| import { Provider, defaultTheme, Grid, View } from "@adobe/react-spectrum"; | ||
| import { ErrorBoundary } from "react-error-boundary"; | ||
| import { HashRouter as Router, Routes, Route } from "react-router-dom"; | ||
| import SpectrumHeader from "./common/SpectrumHeader"; | ||
| import SideBar from "./common/SideBar"; | ||
| import { Home } from "./Home"; | ||
| import { About } from "./About"; | ||
| import BrandManagerView from "./layout/BrandManagerView"; | ||
| import RulesManagerView from "./RulesManagerView"; | ||
| import { apiService } from "../services/api"; | ||
| import { store } from "../store/store"; | ||
| import { Provider as ReduxProvider } from "react-redux"; | ||
|
|
||
| function App(props) { | ||
| console.log('runtime object:', props.runtime) | ||
| console.log('viewProps object:', props.viewProps) | ||
| console.log("runtime object:", props.runtime); | ||
| console.log("viewProps object:", props.viewProps); | ||
|
|
||
| // Safe access to viewProps and ims with fallbacks | ||
| const safeViewProps = props.viewProps || {}; | ||
| const safeIms = safeViewProps.ims || {}; | ||
|
|
||
| // use exc runtime event handlers | ||
| // respond to configuration change events (e.g. user switches org) | ||
| props.runtime.on('configuration', (props) => { | ||
| console.log('Ready! received on configuration:', props) | ||
| props.runtime.on("configuration", (props) => { | ||
| console.log("Ready! received on configuration:", props); | ||
| //console.log('configuration change', { imsOrg, imsToken, locale }) | ||
| }) | ||
| }); | ||
|
|
||
| // respond to history change events | ||
| props.runtime.on('history', ({ type, path }) => { | ||
| console.log('history change', { type, path }) | ||
| }) | ||
| props.runtime.on("history", ({ type, path }) => { | ||
| console.log("history change", { type, path }); | ||
| }); | ||
|
|
||
| useEffect(() => { | ||
| const apiBaseUrl = `https://${safeViewProps.aioRuntimeNamespace}.adobeio-static.net/api/v1/web/${safeViewProps.aioActionPackageName}`; | ||
| apiService.initialize(apiBaseUrl, safeViewProps.imsToken, safeViewProps.imsOrg); | ||
| apiService.initialize( | ||
| apiBaseUrl, | ||
| safeViewProps.imsToken, | ||
| safeViewProps.imsOrg | ||
| ); | ||
| return () => { | ||
| apiService.clear(); | ||
| }; | ||
| }, []) | ||
| }, []); | ||
|
|
||
| return ( | ||
| <ErrorBoundary onError={onError} FallbackComponent={fallbackComponent}> | ||
| <Router> | ||
| <Provider theme={defaultTheme} colorScheme={'light'}> | ||
| <Grid | ||
| areas={['header', 'content']} | ||
| columns={['1fr']} | ||
| rows={['auto', '1fr']} | ||
| height='100vh' | ||
| gap='size-100' | ||
| > | ||
| <View gridArea='header'> | ||
| <SpectrumHeader viewProps={safeViewProps} /> | ||
| </View> | ||
| <View gridArea='content' padding='size-200'> | ||
| <Routes> | ||
| <Route path='/' element={<Home viewProps={safeViewProps} />} /> | ||
| <Route path='/brand_manager' element={<BrandManagerView viewProps={safeViewProps} />} /> | ||
| <Route path='/rules_manager' element={<RulesConfigurationView viewProps={safeViewProps} />} /> | ||
| <Route path='/about' element={<About viewProps={safeViewProps} />} /> | ||
| </Routes> | ||
| </View> | ||
| </Grid> | ||
| </Provider> | ||
| </Router> | ||
| <ReduxProvider store={store}> | ||
| <Router> | ||
| <Provider theme={defaultTheme} colorScheme={"light"}> | ||
| <Grid | ||
| areas={["header", "content"]} | ||
| columns={["1fr"]} | ||
| rows={["auto", "1fr"]} | ||
| height="100vh" | ||
| gap="size-100" | ||
| > | ||
| <View | ||
| gridArea="header" | ||
| UNSAFE_style={{ | ||
| position: "sticky", | ||
| top: 0, | ||
| zIndex: 1000, | ||
| }} | ||
| > | ||
| <SpectrumHeader viewProps={safeViewProps} /> | ||
| </View> | ||
| <View gridArea="content" padding="size-200"> | ||
| <Routes> | ||
| <Route | ||
| path="/" | ||
| element={<Home viewProps={safeViewProps} />} | ||
| /> | ||
| <Route | ||
| path="/brand_manager" | ||
| element={<BrandManagerView viewProps={safeViewProps} />} | ||
| /> | ||
| <Route | ||
| path="/rules_manager" | ||
| element={<RulesManagerView viewProps={safeViewProps} />} | ||
| /> | ||
| <Route | ||
| path="/about" | ||
| element={<About viewProps={safeViewProps} />} | ||
| /> | ||
| </Routes> | ||
| </View> | ||
| </Grid> | ||
| </Provider> | ||
| </Router> | ||
| </ReduxProvider> | ||
| </ErrorBoundary> | ||
| ) | ||
|
|
||
| // Methods | ||
| ); | ||
|
|
||
| // error handler on UI rendering failure | ||
| function onError(e, componentStack) { } | ||
| function onError(e, componentStack) {} | ||
|
|
||
| // component to show if UI fails rendering | ||
| function fallbackComponent({ componentStack, error }) { | ||
| return ( | ||
| <React.Fragment> | ||
| <h1 style={{ textAlign: 'center', marginTop: '20px' }}> | ||
| <h1 style={{ textAlign: "center", marginTop: "20px" }}> | ||
| Something went wrong :( | ||
| </h1> | ||
| <pre>{componentStack + '\n' + error.message}</pre> | ||
| <pre>{componentStack + "\n" + error.message}</pre> | ||
| </React.Fragment> | ||
| ) | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export default App | ||
| export default App; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Copilot Autofix
AI 10 months ago
The best way to fix this issue is to delete the unnecessary import statement
import SideBar from "./common/SideBar";on line 10 ofsrc/dx-excshell-1/web-src/src/components/App.js. This change is safe and does not alter the existing functionality of the application sinceSideBaris not used elsewhere in the code. No other files or code regions need to be changed, and no additional methods, imports, or definitions are required to implement this fix.