Skip to content

Commit 0e4d787

Browse files
authored
Merge pull request #3629 from KelvinTegelaar/dev
Dev to release
2 parents bfedc41 + a5f4545 commit 0e4d787

File tree

96 files changed

+4404
-599
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+4404
-599
lines changed

Tools/Start-CippDevEmulators.ps1

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
Write-Host 'Starting CIPP Dev Emulators'
1+
Get-Command wt -ErrorAction Stop | Out-Null
22
Get-Process node -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue
33
$Path = (Get-Item $PSScriptRoot).Parent.Parent.FullName
44

5-
$Process = Read-Host -Prompt 'Start Process Function (y/N)?'
5+
pwsh -file (Join-Path $PSScriptRoot 'Start-CippDevInstallation.ps1')
6+
7+
Write-Host 'Starting CIPP Dev Emulators'
8+
9+
if (Test-Path (Join-Path $Path 'CIPP-API-Processor')) {
10+
$Process = Read-Host -Prompt 'Start Process Function (y/N)?'
11+
}
612

713
if ($Process -eq 'y') {
814
wt --title CIPP`; new-tab --title 'Azurite' -d $Path pwsh -c azurite`; new-tab --title 'FunctionApp' -d $Path\CIPP-API pwsh -c func start`; new-tab --title 'CIPP Frontend' -d $Path\CIPP pwsh -c npm run dev`; new-tab --title 'SWA' -d $Path\CIPP pwsh -c npm run start-swa`; new-tab --title 'CIPP-API-Processor' -d $Path\CIPP-API-Processor pwsh -c func start --port 7072

Tools/Start-CippDevInstallation.ps1

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
$Path = (Get-Item $PSScriptRoot).Parent.Parent.FullName
22

3-
if (-not(Get-Command npm)) {
4-
throw 'npm is required to install the CIPP development environment'
3+
if (-not((Get-Command npm -ErrorAction SilentlyContinue) -or (Get-Command yarn -ErrorAction SilentlyContinue))) {
4+
throw 'npm or yarn is required to install the CIPP development environment.'
55
}
66

7-
if (-not(Get-Command azurite)) {
7+
if (-not(Get-Command yarn -ErrorAction SilentlyContinue)) {
8+
Write-Host 'Installing Yarn'
9+
npm install --global yarn
10+
}
11+
12+
if (-not(Get-Command azurite -ErrorAction SilentlyContinue)) {
813
Write-Host 'Installing Azurite'
9-
npm install --global 'azurite'
14+
yarn global add 'azurite'
1015
}
1116

12-
if (-not(Get-Command swa)) {
17+
if (-not(Get-Command swa -ErrorAction SilentlyContinue)) {
1318
Write-Host 'Installing @azure/static-web-apps-cli'
14-
npm install --global '@azure/static-web-apps-cli'
19+
yarn global add '@azure/static-web-apps-cli'
1520
}
1621

17-
if (-not(Get-Command func)) {
22+
if (-not(Get-Command func -ErrorAction SilentlyContinue)) {
1823
Write-Host 'Installing Azure Functions Core Tools'
19-
npm install --global 'azure-functions-core-tools@4' --unsafe-perms true
20-
}
21-
22-
if (-not(Get-Command yarn)) {
23-
Write-Host 'Installing Yarn'
24-
npm install --global yarn
24+
yarn global add 'azure-functions-core-tools@4'
2525
}
2626

27-
if (-not(yarn list --global --pattern 'next' | Select-String -Pattern 'next')) {
27+
if (-not(yarn global list | Select-String -Pattern 'next')) {
2828
Write-Host 'Installing Next.js'
29-
yarn install --global next --network-timeout 500000
29+
yarn global add 'next'
3030
}
3131

3232
yarn install --cwd (Join-Path $Path "CIPP") --network-timeout 500000

public/discord-mark-blue.svg

+1
Loading

public/version.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "7.1.3"
2+
"version": "7.2.0"
33
}

src/components/CippCards/CippBannerListCard.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export const CippBannerListCard = (props) => {
143143
</Stack>
144144
</Stack>
145145
{isCollapsible && (
146-
<Collapse in={isExpanded}>
146+
<Collapse in={isExpanded} unmountOnExit>
147147
<Divider />
148148
<Stack spacing={1}>
149149
{item?.propertyItems?.length > 0 && (

src/components/CippCards/CippButtonCard.jsx

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default function CippButtonCard({
2323
variant,
2424
component = "card",
2525
accordionExpanded = false,
26+
onAccordionChange,
2627
}) {
2728
const [cardExpanded, setCardExpanded] = useState(accordionExpanded);
2829
useEffect(() => {
@@ -31,6 +32,12 @@ export default function CippButtonCard({
3132
}
3233
}, [accordionExpanded]);
3334

35+
useEffect(() => {
36+
if (onAccordionChange) {
37+
onAccordionChange(cardExpanded);
38+
}
39+
}, [cardExpanded]);
40+
3441
return (
3542
<Card variant={variant} sx={cardSx}>
3643
{component === "card" && (

src/components/CippCards/CippDomainCards.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ export const CippDomainCards = ({ domain: propDomain = "", fullwidth = false })
510510
</Button>
511511
</Grid>
512512
</Grid>
513-
<Collapse in={optionsVisible}>
513+
<Collapse in={optionsVisible} unmountOnExit>
514514
<Stack direction="column" spacing={1} sx={{ mt: 1 }}>
515515
<Controller
516516
name="spfRecord"

src/components/CippCards/CippPropertyListCard.jsx

+15-5
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,25 @@ export const CippPropertyListCard = (props) => {
122122
)}
123123
</PropertyList>
124124
<PropertyList>
125-
{secondHalf.map((item, index) => (
125+
{isFetching ? (
126126
<PropertyListItem
127+
key={"loading-bar"}
127128
align={align}
128129
divider={showDivider}
129-
copyItems={copyItems}
130-
key={`${index}-index-PropertyListOffCanvas`}
131-
{...item}
130+
label="Loading"
131+
value={<Skeleton width={280} />}
132132
/>
133-
))}
133+
) : (
134+
secondHalf.map((item, index) => (
135+
<PropertyListItem
136+
align={align}
137+
divider={showDivider}
138+
copyItems={copyItems}
139+
key={`${index}-index-PropertyListOffCanvas`}
140+
{...item}
141+
/>
142+
))
143+
)}
134144
</PropertyList>
135145
</Stack>
136146
)}

src/components/CippComponents/CippApiDialog.jsx

+87-9
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,21 @@ export const CippApiDialog = (props) => {
1717
row = {},
1818
relatedQueryKeys,
1919
dialogAfterEffect,
20+
allowResubmit = false,
2021
...other
2122
} = props;
2223
const router = useRouter();
2324
const [addedFieldData, setAddedFieldData] = useState({});
2425
const [partialResults, setPartialResults] = useState([]);
26+
const [isFormSubmitted, setIsFormSubmitted] = useState(false);
27+
28+
useEffect(() => {
29+
if (createDialog.open) {
30+
setIsFormSubmitted(false);
31+
formHook.reset();
32+
}
33+
}, [createDialog.open]);
34+
2535
const [getRequestInfo, setGetRequestInfo] = useState({
2636
url: "",
2737
waiting: false,
@@ -103,6 +113,7 @@ export const CippApiDialog = (props) => {
103113
};
104114
const tenantFilter = useSettings().currentTenant;
105115
const handleActionClick = (row, action, formData) => {
116+
setIsFormSubmitted(true);
106117
if (action.multiPost === undefined) {
107118
action.multiPost = false;
108119
}
@@ -207,14 +218,63 @@ export const CippApiDialog = (props) => {
207218
const onSubmit = (data) => handleActionClick(row, api, data);
208219
const selectedType = api.type === "POST" ? actionPostRequest : actionGetRequest;
209220

221+
useEffect(() => {
222+
if (api?.setDefaultValues && createDialog.open) {
223+
fields.map((field) => {
224+
if (
225+
((typeof row[field.name] === "string" && field.type === "textField") ||
226+
(typeof row[field.name] === "boolean" && field.type === "switch")) &&
227+
row[field.name] !== undefined &&
228+
row[field.name] !== null &&
229+
row[field.name] !== ""
230+
) {
231+
formHook.setValue(field.name, row[field.name]);
232+
} else if (Array.isArray(row[field.name]) && field.type === "autoComplete") {
233+
var values = [];
234+
row[field.name].map((element) => {
235+
if (element.label && element.value) {
236+
values.push(element);
237+
} else if (typeof element === "string" || typeof element === "number") {
238+
values.push({
239+
label: element,
240+
value: element,
241+
});
242+
}
243+
});
244+
formHook.setValue(field.name, values);
245+
} else if (
246+
field.type === "autoComplete" &&
247+
row[field.name] !== "" &&
248+
(typeof row[field.name] === "string" ||
249+
(typeof row[field.name] === "object" &&
250+
row[field.name] !== undefined &&
251+
row[field.name] !== null))
252+
) {
253+
if (typeof row[field.name] === "string") {
254+
formHook.setValue(field.name, {
255+
label: row[field.name],
256+
value: row[field.name],
257+
});
258+
} else if (
259+
typeof row[field.name] === "object" &&
260+
row[field.name]?.label &&
261+
row[field.name]?.value
262+
) {
263+
formHook.setValue(field.name, row[field.name]);
264+
}
265+
}
266+
});
267+
}
268+
}, [createDialog.open, api?.setDefaultValues]);
269+
270+
const getNestedValue = (obj, path) => {
271+
return path
272+
.split(".")
273+
.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), obj);
274+
};
275+
210276
// Handling link navigation
211277
if (api.link) {
212-
const getNestedValue = (obj, path) => {
213-
return path
214-
.split(".")
215-
.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), obj);
216-
};
217-
218278
const linkWithRowData = api.link.replace(/\[([^\]]+)\]/g, (_, key) => {
219279
return getNestedValue(row, key) || `[${key}]`;
220280
});
@@ -239,17 +299,35 @@ export const CippApiDialog = (props) => {
239299
setPartialResults([]);
240300
};
241301

302+
var confirmText;
303+
if (typeof api?.confirmText === "string" && !Array.isArray(row)) {
304+
confirmText = api.confirmText.replace(/\[([^\]]+)\]/g, (_, key) => {
305+
return getNestedValue(row, key) || `[${key}]`;
306+
});
307+
} else if (Array.isArray(row) && row.length > 1) {
308+
confirmText = api.confirmText.replace(/\[([^\]]+)\]/g, "the selected rows");
309+
} else if (Array.isArray(row) && row.length === 1) {
310+
confirmText = api.confirmText.replace(/\[([^\]]+)\]/g, (_, key) => {
311+
return getNestedValue(row[0], key) || `[${key}]`;
312+
});
313+
} else {
314+
confirmText = api.confirmText;
315+
}
316+
242317
return (
243318
<Dialog fullWidth maxWidth="sm" onClose={handleClose} open={createDialog.open}>
244319
<form onSubmit={formHook.handleSubmit(onSubmit)}>
245320
<DialogTitle>{title}</DialogTitle>
246321
<DialogContent>
247-
<Stack spacing={3}>{api.confirmText}</Stack>
322+
<Stack spacing={3}>{confirmText}</Stack>
248323
</DialogContent>
249324
<DialogContent>
250325
<Grid container spacing={2}>
251326
{fields &&
252327
fields.map((fieldProps, index) => {
328+
if (fieldProps?.api?.processFieldData) {
329+
fieldProps.api.data = processActionData(fieldProps.api.data, row);
330+
}
253331
return (
254332
<Grid item xs={12} key={index}>
255333
<CippFormComponent
@@ -270,8 +348,8 @@ export const CippApiDialog = (props) => {
270348
<Button color="inherit" onClick={() => handleClose()}>
271349
Close
272350
</Button>
273-
<Button variant="contained" type="submit">
274-
Confirm
351+
<Button variant="contained" type="submit" disabled={isFormSubmitted && !allowResubmit}>
352+
{isFormSubmitted && allowResubmit ? "Reconfirm" : "Confirm"}
275353
</Button>
276354
</DialogActions>
277355
</form>

0 commit comments

Comments
 (0)