Skip to content

Commit

Permalink
Merge branch 'ourcodeinc:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
samyak1326 authored Sep 19, 2024
2 parents c93c010 + 8e21db0 commit 40f975e
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 88 deletions.
Binary file added public/OurCode-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/rules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 0 additions & 13 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,6 @@ export const updateFilePath = (filePath) => {
};


/*
nav-bar navigation
*/


export const clickedOnForward = () => {
return {type: reduxStoreActions.action_click_forward};
};

export const clickedOnBack = () => {
return {type: reduxStoreActions.action_click_back};
};

/*
RulePad
*/
Expand Down
12 changes: 12 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,22 @@ body {
justify-content: center;
}

/*-- Nav bar --*/

.navbar {
margin-bottom: 0;
}

.navbar-brand {
display: flex;
align-items: center;
}

.navbar-icon {
width: 40px;
height: 40px;
}

/*!*** rule Generator GUI ***!*/

.guiBoundingBox {
Expand Down
11 changes: 8 additions & 3 deletions src/ui/RulePad/rulePadGraphicalEditor/graphicalComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ class GraphicalComponent extends Component {
if ((this.state.thisElement.activeElement && this.state.elementCondition.canBeSelected) || this.props.root) {
return (
<div className={"elementIconsDiv"}>
{!this.state.thisElement.activeElement ? null :
this.renderCheckboxAndErase(!isResetting ? changeFunction : changeAndResetFunction, checkedStatus, eraseFunction, "element", null, null, !isDelegate || isResetting)}
{this.props["canBeStarredIDs"].indexOf(this.state.elementId) === -1 ? null : (
<div style={{float: "left"}}>
<div data-tip={"React-tooltip"} data-for={"star"}>
Expand All @@ -385,6 +383,8 @@ class GraphicalComponent extends Component {
</ReactToolTip>
</div>
)}
{!this.state.thisElement.activeElement ? null :
this.renderCheckboxAndErase(!isResetting ? changeFunction : changeAndResetFunction, checkedStatus, eraseFunction, "element", null, null, !isDelegate || isResetting)}
</div>
);
}
Expand Down Expand Up @@ -1022,8 +1022,13 @@ class GraphicalComponent extends Component {
}

_handleSelectedElement(elementId, thisElement, elementCondition) {
if (!(thisElement.activeElement && elementCondition.canBeSelected)) return;
if (!elementCondition.canBeSelected) return;
const jobs = [];
jobs.push({
elementId: elementId,
task: "UPDATE_ELEMENT",
value: {activeElement: true},
});
jobs.push({
elementId: elementId,
task: "SELECT_ELEMENT",
Expand Down
11 changes: 2 additions & 9 deletions src/ui/RulePad/rulePadGraphicalEditor/graphicalEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ class GraphicalEditor extends Component {
const guiElements = JSON.parse(JSON.stringify(this.state.guiElements));
const guiTree = JSON.parse(JSON.stringify(this.state.guiTree));


// check connectivity of elements
const activateJobs = this.connectElements(guiElements, guiTree);
if (activateJobs.jobs.length !== 0) {
console.log("error: not connected", activateJobs.jobs);
// this.props.onChangeGuiElement(this.ruleIndex, activateJobs.jobs);
return;
}

// check the selected element
const selectJobs = this.lowestCommonAncestor(guiElements, guiTree);
if (selectJobs.jobs.length !== 0) {
Expand Down Expand Up @@ -904,6 +895,7 @@ export function buildFromGUI(guiTree, guiElements, nodeId, group="quantifier",
if (visitedNodeId.indexOf(childId) !== -1) return;
if (childId === "" || !guiElements[childId].activeElement) return;
if (guiElements[childId].isConstraint && group === "quantifier") return;
if (!guiElements[childId].isConstraint && group === "constraint") return;
if (forMiningRules && isNotElementOrIdentifier(guiElements, childId)) return;
const newSubTree = buildTreeFromNodeId(childId, group);
if (newSubTree) nodeChildren[childGroup].push(newSubTree);
Expand All @@ -914,6 +906,7 @@ export function buildFromGUI(guiTree, guiElements, nodeId, group="quantifier",
if (visitedNodeId.indexOf(childId) !== -1) return;
if (childId === "" || !guiElements[childId].activeElement) return;
if (guiElements[childId].isConstraint && group === "quantifier") return;
if (!guiElements[childId].isConstraint && group === "constraint") return;
if (forMiningRules && isNotElementOrIdentifier(guiElements, childId)) return;
const newSubTree = buildTreeFromNodeId(childId, group);
if (newSubTree) nodeChildren["body"].push(newSubTree);
Expand Down
39 changes: 10 additions & 29 deletions src/ui/navBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@

import React, {Component} from "react";
import "../App.css";
import {FaArrowLeft, FaArrowRight} from "react-icons/fa";
import {Nav, Navbar, NavItem} from "react-bootstrap";
import {connect} from "react-redux";
import {clickedOnBack, clickedOnForward} from "../actions";
import {hashConst} from "./uiConstants";
import {featureConfig} from "../config";

export class NavBar extends Component {
render() {
return (
<Navbar inverse collapseOnSelect
style={{backgroundColor: "transparent", backgroundImage: "none", border: "none"}}>
<Navbar.Toggle/>
<Navbar inverse collapseOnSelect style={{backgroundColor: "transparent", backgroundImage: "none", border: "none"}}>
<Navbar.Header>
<Navbar.Brand>
<a href="#/index">
<img src="/OurCode-icon.png" alt="Logo" className="navbar-icon grayscale"/>
</a>
</Navbar.Brand>
<Navbar.Toggle/>
</Navbar.Header>
<Navbar.Collapse>
<Nav
onSelect={(key) => {
Expand All @@ -26,12 +30,6 @@ export class NavBar extends Component {
(key === 3) ? `#/${hashConst.violatedRules}` : (key === 4) ? `#/${hashConst.learnDesignRules}` : `#/${hashConst.index}`;
}
}}>
<NavItem eventKey={-1} className={this.props.backDisable} onClick={() => this.props.backClick(this.props)}>
<FaArrowLeft size={20}/>
</NavItem>
<NavItem eventKey={-2} className={this.props.forwardDisable} onClick={() => this.props.forwardClick(this.props)}>
<FaArrowRight size={20}/>
</NavItem>

<NavItem eventKey={1}>
{"Table of Contents"}
Expand Down Expand Up @@ -62,21 +60,4 @@ function mapStateToProps(state) {
};
}

function mapDispatchToProps(dispatch) {
return {
backClick: (props) => {
if (props.activeHashIndex > 0) {
dispatch(clickedOnBack());
window.location.hash = props.history[props.activeHashIndex - 1];
}
},
forwardClick: (props) => {
if (props.activeHashIndex < props.history.length - 1) {
dispatch(clickedOnForward());
window.location.hash = props.history[props.activeHashIndex + 1];
}
},
};
}

export default connect(mapStateToProps, mapDispatchToProps)(NavBar);
export default connect(mapStateToProps)(NavBar);
97 changes: 63 additions & 34 deletions src/ui/tableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,71 @@ class TableOfContents extends Component {
render() {
return (
<div>
<div className={"well well-sm"}>
<h4>Tags</h4>
</div>
<ul className={"list-inline"} id={"tags_list"}>
{this.props.tags.map((tag, i) =>
(<li key={i}
onClick={() =>
window.location.hash = `#/${hashConst.tag}/${tag.ID}`
}>{tag.tagName}</li>),
)}
</ul>

<div className={"well well-sm"}>
<h4>Rules</h4>
</div>
<div className={"ist-inline"}>
<table>
<tbody>
{this.props.rules.map((rule, i) =>
<tr key={i}>
<td className={"list-group-item"}>{rule.title}</td>
</tr>,
{this.props.rules.length > 0 ? (
<div>
<div className={"well well-sm"}>
<h4>Tags</h4>
</div>
<ul className={"list-inline"} id={"tags_list"}>
{this.props.tags.map((tag, i) =>
(<li key={i}
onClick={() =>
window.location.hash = `#/${hashConst.tag}/${tag.ID}`
}>{tag.tagName}</li>),
)}
</tbody>
</table>
<div style={{padding: "10px 0 10px 0", clear: "both"}}>
<Button style={{padding: "0 5px"}}
onClick={() => {
window.location.hash = `#/${hashConst.rules}`;
this.props.onAddNewRule();
}}>
<MdPlaylistAdd className={"react-icons"} size={35}/>
Add a New Rule
</Button>
</ul>
<div className={"well well-sm"}>
<h4>Rules</h4>
</div>
<div className={"ist-inline"}>
<table>
<tbody>
{this.props.rules.map((rule, i) => (
<tr key={i}>
<td className={"list-group-item"}>{rule.title}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
) : (
<div>
<p>Welcome to the Rules Dashboard! This tool helps you manage design rules for your projects.</p>
<p>Explore how easy it is to create, view, and manage design rules with the intuitive interface.</p>
<br></br>
<div style={{marginTop: "20px"}}>
<h4>How Active Documentation Works?</h4>
<p>ActiveDocumentation seamlessly integrates into your IDE and codebase, automatically monitoring and enforcing design rules.</p>
<div style={{marginTop: "20px", color: "red"}}>
<p><b>Have not installed Plugin yet?</b></p>
<p>Please check out the <a href={"https://github.com/ourcodeinc/ActiveDocumentation-webapp/wiki/User-Manual#2-installing-the-plugin"}>installation process here</a> to install the plugin and get started.</p>
</div>
<p>
To get started, add a new rule by clicking the button above. You can also explore the detailed explanation of how rules work by visiting the <a href={`#/${hashConst.learnDesignRules}`}>Learn Design Rules</a> section.
</p>
</div>
<div>
<div>
<img src={`${process.env.PUBLIC_URL}/rules.png`} alt="Rules Dashboard Screenshot" style={{width: "450px", height: "400px", borderRadius: "10px", boxShadow: "0 4px 8px rgba(0, 0, 0, 0.1)"}}/>
</div>
<br></br>
<p>Start by creating a rule to begin!</p>
<div className={"ist-inline"}>
<div style={{padding: "10px 0 10px 0", clear: "both"}}>
<Button style={{padding: "0 5px"}}
onClick={() => {
window.location.hash = `#/${hashConst.rules}`;
this.props.onAddNewRule();
}}>
<MdPlaylistAdd className={"react-icons"} size={35}/>
Add a New Rule
</Button>
</div>
</div>
</div>
</div>
</div>
)}
</div>
);
}
Expand Down

0 comments on commit 40f975e

Please sign in to comment.