Skip to content

Commit

Permalink
Merge pull request #119 from KelvinTegelaar/dev
Browse files Browse the repository at this point in the history
[pull] dev from KelvinTegelaar:dev
  • Loading branch information
pull[bot] authored Feb 26, 2025
2 parents 9c0f50d + 37f3917 commit 12053d9
Show file tree
Hide file tree
Showing 5 changed files with 410 additions and 65 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CIPP Development Frontend CI/CD

on:
push:
branches:
- dev

jobs:
build_and_deploy_job:
if: github.event.repository.fork == false && github.event_name == 'push'
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_MOSS_0A047A40F }} # change this to your repository secret name
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: 'upload'
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: '/' # App source code path
api_location: '' # Api source code path - optional
output_location: 'out' # Built app content directory - optional
###### End of Repository/Build Configurations ######

close_pull_request_job:
if: github.event.repository.fork == false && github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_MOSS_0A047A40F }} # change this to your repository secret name
action: 'close'
60 changes: 59 additions & 1 deletion src/components/CippComponents/CippFormCondition.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useWatch } from "react-hook-form";
import isEqual from "lodash/isEqual"; // lodash for deep comparison
import React from "react";

export const CippFormCondition = (props) => {
let { field, compareType = "is", compareValue, children, formControl } = props;
let { field, compareType = "is", compareValue, action = 'hide', children, formControl } = props;

if (
field === undefined ||
Expand All @@ -22,24 +23,48 @@ export const CippFormCondition = (props) => {
compareValue = compareValue.value;
}

const disableChildren = (children) => {
return React.Children.map(children, (child) => {
if (React.isValidElement(child)) {
if (child.props?.children && child.type.name !== "CippFormCondition") {
return React.cloneElement(child, {
children: disableChildren(child.props.children),
disabled: true,
});
}
return React.cloneElement(child, { disabled: true });
}
return child;
});
};

switch (compareType) {
case "regex":
if (watcher?.match(new RegExp(compareValue))) {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;
case "is":
// Deep comparison for objects and arrays
if (isEqual(watcher, compareValue)) {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

case "isNot":
// Deep comparison for objects and arrays (negation)
if (!isEqual(watcher, compareValue)) {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

case "contains":
Expand All @@ -55,6 +80,9 @@ export const CippFormCondition = (props) => {
// Check if object contains the key
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

case "doesNotContain":
Expand All @@ -73,6 +101,9 @@ export const CippFormCondition = (props) => {
// Check if object does not contain the key
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

case "greaterThan":
Expand All @@ -83,6 +114,9 @@ export const CippFormCondition = (props) => {
) {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

case "lessThan":
Expand All @@ -93,6 +127,9 @@ export const CippFormCondition = (props) => {
) {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

case "arrayLength":
Expand All @@ -103,12 +140,18 @@ export const CippFormCondition = (props) => {
) {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

case "hasValue":
if (watcher !== undefined && watcher !== null && watcher !== "") {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

/*
Expand All @@ -119,6 +162,9 @@ export const CippFormCondition = (props) => {
if (Array.isArray(watcher) && watcher.some((item) => item?.label === compareValue)) {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

case "labelContains":
Expand All @@ -129,13 +175,19 @@ export const CippFormCondition = (props) => {
) {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

case "valueEq":
// Checks if any object in array has .value exactly equal to compareValue
if (Array.isArray(watcher) && watcher.some((item) => item?.value === compareValue)) {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

case "valueContains":
Expand All @@ -146,9 +198,15 @@ export const CippFormCondition = (props) => {
) {
return children;
}
if (action === "disable") {
return disableChildren(children);
}
return null;

default:
if (action === "disable") {
return disableChildren(children);
}
return null;
}
};
1 change: 0 additions & 1 deletion src/components/CippFormPages/CippSchedulerForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ const CippSchedulerForm = (props) => {
options={recurrenceOptions}
multiple={false}
disableClearable={true}
creatable={false}
/>
</Grid>
{selectedCommand?.addedFields?.Synopsis && (
Expand Down
Loading

0 comments on commit 12053d9

Please sign in to comment.