Skip to content

Commit 12053d9

Browse files
authored
Merge pull request #119 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 9c0f50d + 37f3917 commit 12053d9

File tree

5 files changed

+410
-65
lines changed

5 files changed

+410
-65
lines changed

.github/workflows/dev_deploy.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CIPP Development Frontend CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
8+
jobs:
9+
build_and_deploy_job:
10+
if: github.event.repository.fork == false && github.event_name == 'push'
11+
runs-on: ubuntu-latest
12+
name: Build and Deploy Job
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
submodules: true
17+
- name: Build And Deploy
18+
id: builddeploy
19+
uses: Azure/static-web-apps-deploy@v1
20+
with:
21+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_MOSS_0A047A40F }} # change this to your repository secret name
22+
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
23+
action: 'upload'
24+
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
25+
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
26+
app_location: '/' # App source code path
27+
api_location: '' # Api source code path - optional
28+
output_location: 'out' # Built app content directory - optional
29+
###### End of Repository/Build Configurations ######
30+
31+
close_pull_request_job:
32+
if: github.event.repository.fork == false && github.event_name == 'pull_request' && github.event.action == 'closed'
33+
runs-on: ubuntu-latest
34+
name: Close Pull Request Job
35+
steps:
36+
- name: Close Pull Request
37+
id: closepullrequest
38+
uses: Azure/static-web-apps-deploy@v1
39+
with:
40+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_MOSS_0A047A40F }} # change this to your repository secret name
41+
action: 'close'

src/components/CippComponents/CippFormCondition.jsx

+59-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { useWatch } from "react-hook-form";
22
import isEqual from "lodash/isEqual"; // lodash for deep comparison
3+
import React from "react";
34

45
export const CippFormCondition = (props) => {
5-
let { field, compareType = "is", compareValue, children, formControl } = props;
6+
let { field, compareType = "is", compareValue, action = 'hide', children, formControl } = props;
67

78
if (
89
field === undefined ||
@@ -22,24 +23,48 @@ export const CippFormCondition = (props) => {
2223
compareValue = compareValue.value;
2324
}
2425

26+
const disableChildren = (children) => {
27+
return React.Children.map(children, (child) => {
28+
if (React.isValidElement(child)) {
29+
if (child.props?.children && child.type.name !== "CippFormCondition") {
30+
return React.cloneElement(child, {
31+
children: disableChildren(child.props.children),
32+
disabled: true,
33+
});
34+
}
35+
return React.cloneElement(child, { disabled: true });
36+
}
37+
return child;
38+
});
39+
};
40+
2541
switch (compareType) {
2642
case "regex":
2743
if (watcher?.match(new RegExp(compareValue))) {
2844
return children;
2945
}
46+
if (action === "disable") {
47+
return disableChildren(children);
48+
}
3049
return null;
3150
case "is":
3251
// Deep comparison for objects and arrays
3352
if (isEqual(watcher, compareValue)) {
3453
return children;
3554
}
55+
if (action === "disable") {
56+
return disableChildren(children);
57+
}
3658
return null;
3759

3860
case "isNot":
3961
// Deep comparison for objects and arrays (negation)
4062
if (!isEqual(watcher, compareValue)) {
4163
return children;
4264
}
65+
if (action === "disable") {
66+
return disableChildren(children);
67+
}
4368
return null;
4469

4570
case "contains":
@@ -55,6 +80,9 @@ export const CippFormCondition = (props) => {
5580
// Check if object contains the key
5681
return children;
5782
}
83+
if (action === "disable") {
84+
return disableChildren(children);
85+
}
5886
return null;
5987

6088
case "doesNotContain":
@@ -73,6 +101,9 @@ export const CippFormCondition = (props) => {
73101
// Check if object does not contain the key
74102
return children;
75103
}
104+
if (action === "disable") {
105+
return disableChildren(children);
106+
}
76107
return null;
77108

78109
case "greaterThan":
@@ -83,6 +114,9 @@ export const CippFormCondition = (props) => {
83114
) {
84115
return children;
85116
}
117+
if (action === "disable") {
118+
return disableChildren(children);
119+
}
86120
return null;
87121

88122
case "lessThan":
@@ -93,6 +127,9 @@ export const CippFormCondition = (props) => {
93127
) {
94128
return children;
95129
}
130+
if (action === "disable") {
131+
return disableChildren(children);
132+
}
96133
return null;
97134

98135
case "arrayLength":
@@ -103,12 +140,18 @@ export const CippFormCondition = (props) => {
103140
) {
104141
return children;
105142
}
143+
if (action === "disable") {
144+
return disableChildren(children);
145+
}
106146
return null;
107147

108148
case "hasValue":
109149
if (watcher !== undefined && watcher !== null && watcher !== "") {
110150
return children;
111151
}
152+
if (action === "disable") {
153+
return disableChildren(children);
154+
}
112155
return null;
113156

114157
/*
@@ -119,6 +162,9 @@ export const CippFormCondition = (props) => {
119162
if (Array.isArray(watcher) && watcher.some((item) => item?.label === compareValue)) {
120163
return children;
121164
}
165+
if (action === "disable") {
166+
return disableChildren(children);
167+
}
122168
return null;
123169

124170
case "labelContains":
@@ -129,13 +175,19 @@ export const CippFormCondition = (props) => {
129175
) {
130176
return children;
131177
}
178+
if (action === "disable") {
179+
return disableChildren(children);
180+
}
132181
return null;
133182

134183
case "valueEq":
135184
// Checks if any object in array has .value exactly equal to compareValue
136185
if (Array.isArray(watcher) && watcher.some((item) => item?.value === compareValue)) {
137186
return children;
138187
}
188+
if (action === "disable") {
189+
return disableChildren(children);
190+
}
139191
return null;
140192

141193
case "valueContains":
@@ -146,9 +198,15 @@ export const CippFormCondition = (props) => {
146198
) {
147199
return children;
148200
}
201+
if (action === "disable") {
202+
return disableChildren(children);
203+
}
149204
return null;
150205

151206
default:
207+
if (action === "disable") {
208+
return disableChildren(children);
209+
}
152210
return null;
153211
}
154212
};

src/components/CippFormPages/CippSchedulerForm.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ const CippSchedulerForm = (props) => {
203203
options={recurrenceOptions}
204204
multiple={false}
205205
disableClearable={true}
206-
creatable={false}
207206
/>
208207
</Grid>
209208
{selectedCommand?.addedFields?.Synopsis && (

0 commit comments

Comments
 (0)