Skip to content

[pull] main from KelvinTegelaar:main #10

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 172 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
ff19281
Change Delete Policy request type from GET to POST
kris6673 Jan 21, 2025
fe3b293
Add "Scripts" menu item to the endpoint navigation
kris6673 Jan 21, 2025
1f3b755
Add Intune scripts page
kris6673 Jan 21, 2025
a45dc74
Make into 1 page
kris6673 Jan 23, 2025
45fa375
Add speed dial actions for bug reporting and feature requests
Jr7468 Jan 28, 2025
44798d7
Merge pull request #96 from KelvinTegelaar/dev
kris6673 Jan 29, 2025
e53fe8c
Merge branch 'KelvinTegelaar:dev' into dev
Jr7468 Jan 30, 2025
912bc12
Merge branch 'KelvinTegelaar:dev' into dev
Jr7468 Jan 31, 2025
32cbe02
Add Speed Dial component with help, bug report, and feedback actions
Jr7468 Jan 31, 2025
205fa4c
Prettier fix
Jr7468 Jan 31, 2025
65da8b6
Tested and works properly on my Dev Env now!
Jr7468 Jan 31, 2025
6c432d3
Add onClick handlers to Speed Dial GitHub links
Jr7468 Jan 31, 2025
d6eaf09
Add Discord link to Speed Dial component
Jr7468 Jan 31, 2025
5c538ca
Merge pull request #97 from KelvinTegelaar/dev
kris6673 Jan 31, 2025
fc243b9
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP into dev
kris6673 Jan 31, 2025
033592c
feat: New standard RetentionPolicyTag
OfficialEsco Feb 2, 2025
4aeaa22
Merge pull request #3548 from Ren-Roros-Digital/RetentionPolicyTag
KelvinTegelaar Feb 2, 2025
63dfaef
Merge branch 'KelvinTegelaar:dev' into dev
kris6673 Feb 2, 2025
32d9f71
fix: make some standards required input
OfficialEsco Feb 3, 2025
dc9c7c3
feat: Add Edit Contact page with form functionality
kris6673 Feb 3, 2025
5cc4ae4
Tweaks to Start with Windows Terminal and Dev Installation
OfficialEsco Feb 3, 2025
3f7e051
move up
kris6673 Feb 3, 2025
fa7eda9
make it actually work
kris6673 Feb 4, 2025
d185ae1
fix tenant mapping and buttons
JohnDuprey Feb 4, 2025
9c8c316
Merge pull request #3563 from Ren-Roros-Digital/devtools
KelvinTegelaar Feb 4, 2025
f72dfd2
Merge pull request #3556 from Ren-Roros-Digital/autoComplete
KelvinTegelaar Feb 4, 2025
8e4c7f5
api data key
KelvinTegelaar Feb 4, 2025
b38d9f8
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP into dev
KelvinTegelaar Feb 4, 2025
422b76e
api datakey
KelvinTegelaar Feb 4, 2025
199b29f
fixes default attributess
KelvinTegelaar Feb 4, 2025
54f0fde
auto username and default attributes
KelvinTegelaar Feb 4, 2025
b0e222d
Country selector
kris6673 Feb 4, 2025
7e2c987
fix: Update label for GAL visibility and disable creatable option for…
kris6673 Feb 4, 2025
0a60044
feat: Add Edit Contact page with form functionality
kris6673 Feb 3, 2025
e6ad713
move up
kris6673 Feb 3, 2025
b74a81f
make it actually work
kris6673 Feb 4, 2025
852fafa
Country selector
kris6673 Feb 4, 2025
fa30168
fix: Update label for GAL visibility and disable creatable option for…
kris6673 Feb 4, 2025
f2bd99e
feat: Add Edit Contact page with form functionality
kris6673 Feb 3, 2025
53b07e4
Merge branch 'edit-contact' of https://github.com/kris6673/CIPP into …
kris6673 Feb 4, 2025
9849351
Merge pull request #3572 from kris6673/edit-contact
KelvinTegelaar Feb 4, 2025
e378097
add sam wizard form validation
JohnDuprey Feb 4, 2025
23c3056
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP into dev
kris6673 Feb 4, 2025
0bcf894
add conditional
kris6673 Feb 4, 2025
1236ee5
fix some wrong values
kris6673 Feb 4, 2025
671bc5a
fix state values for connector enable/disable logic
kris6673 Feb 4, 2025
018ce6d
Update CIPPDeploymentStep.js
JohnDuprey Feb 5, 2025
50f6ada
feat: CIPP-API Integration v2
JohnDuprey Feb 5, 2025
a4377ef
Update CippApiClientManagement.jsx
JohnDuprey Feb 5, 2025
0584d61
move actions
JohnDuprey Feb 5, 2025
0a82a3c
add template library options
KelvinTegelaar Feb 5, 2025
30b4e8f
Add some onprem sync stuff back
kris6673 Feb 5, 2025
42d6a73
Now with a null check too!
kris6673 Feb 5, 2025
7c115b1
Merge pull request #3574 from kris6673/connector-fixes
JohnDuprey Feb 5, 2025
be34d7b
Merge pull request #3500 from Jr7468/dev
JohnDuprey Feb 5, 2025
06213ce
Merge pull request #3379 from kris6673/intune-scripts
KelvinTegelaar Feb 6, 2025
ccdee24
fix: rename Action to SafeAttachmentAction
OfficialEsco Feb 6, 2025
448b8df
support conditional fields in integrations
JohnDuprey Feb 6, 2025
6b0f3b1
add refresh button to autocomplete
JohnDuprey Feb 6, 2025
ec900fa
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP into dev
JohnDuprey Feb 6, 2025
2bd704a
Edit Intune Scripts
redanthrax Feb 6, 2025
1779fba
extension updates
JohnDuprey Feb 6, 2025
97afe05
template repo
KelvinTegelaar Feb 6, 2025
782fa76
Update CippApiClientManagement.jsx
JohnDuprey Feb 6, 2025
885e06a
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP into dev
JohnDuprey Feb 6, 2025
823b4db
minor updates
KelvinTegelaar Feb 6, 2025
5bce72a
Update CippApiClientManagement.jsx
JohnDuprey Feb 7, 2025
f27b213
fix geo ip lookup actions
JohnDuprey Feb 7, 2025
bb53d63
Update CippApiClientManagement.jsx
JohnDuprey Feb 7, 2025
0504105
Update CippApiClientManagement.jsx
JohnDuprey Feb 7, 2025
183ce29
ui tweaks
JohnDuprey Feb 7, 2025
be74657
feat: added View in Entra button to user page
OfficialEsco Feb 7, 2025
355afec
feat: Enterprise Application Links
OfficialEsco Feb 7, 2025
853369e
Merge pull request #3597 from Ren-Roros-Digital/enterpriseapps
KelvinTegelaar Feb 7, 2025
09de188
Merge pull request #3596 from Ren-Roros-Digital/viewinentra
KelvinTegelaar Feb 7, 2025
246f8be
Merge pull request #3588 from redanthrax/IntuneScripts
KelvinTegelaar Feb 7, 2025
d348808
Merge pull request #3585 from Ren-Roros-Digital/SafeAttachmentAction
KelvinTegelaar Feb 7, 2025
4e73dd4
fix cal permissions if folder is empty
KelvinTegelaar Feb 7, 2025
2d92125
text update
KelvinTegelaar Feb 7, 2025
a7ca562
add standard
KelvinTegelaar Feb 7, 2025
aa156e9
available units update and correct url
KelvinTegelaar Feb 7, 2025
c2477ce
thanks esco
KelvinTegelaar Feb 7, 2025
a5d239b
Community Repos page
JohnDuprey Feb 7, 2025
01a17ab
control accordion state
JohnDuprey Feb 7, 2025
1cdfeaa
update search results dialog
JohnDuprey Feb 7, 2025
7ec50aa
add view repository page
JohnDuprey Feb 7, 2025
ffdb671
repo page tweakl
JohnDuprey Feb 7, 2025
3f58396
Add edit page and refactor other pages to fit
kris6673 Feb 7, 2025
7e2061a
tweak community repos
JohnDuprey Feb 7, 2025
e7e54fd
FEAT: add alert for Entra ID license over-utilization
kris6673 Feb 7, 2025
c2bd070
Update index.js
JohnDuprey Feb 8, 2025
02f150d
integration tweaks
JohnDuprey Feb 8, 2025
ca8bb4c
log and notification improvements
JohnDuprey Feb 8, 2025
ce38565
adjust cloudflare integration
JohnDuprey Feb 8, 2025
3638845
spacing for api results
JohnDuprey Feb 8, 2025
085f8cc
disable option creation on tenant selector
JohnDuprey Feb 8, 2025
eb903be
Scheduler: default to textField values on <object>
JohnDuprey Feb 8, 2025
cbd0261
add filters
JohnDuprey Feb 9, 2025
bde053a
scheduler form fixes
JohnDuprey Feb 9, 2025
b193156
CippApiDialog
JohnDuprey Feb 9, 2025
db0e254
fix form state changes on save
JohnDuprey Feb 9, 2025
1f046ac
prevent resubmit on cippformpage
JohnDuprey Feb 9, 2025
431926c
fix authentication pages
JohnDuprey Feb 9, 2025
47ca2ae
fix placeholder text
JohnDuprey Feb 9, 2025
9aa15ce
Update CippApiClientManagement.jsx
JohnDuprey Feb 9, 2025
2c73351
add skeleton loading for integration config
JohnDuprey Feb 9, 2025
7d77979
Update CippApiClientManagement.jsx
JohnDuprey Feb 9, 2025
88e52b8
add cold start table indicator
JohnDuprey Feb 9, 2025
893aa54
Update CIPPTableToptoolbar.js
JohnDuprey Feb 9, 2025
3b2f334
fix url
JohnDuprey Feb 9, 2025
1af3428
update help text
JohnDuprey Feb 9, 2025
d58203c
add validation for CSV import form field
kris6673 Feb 9, 2025
934f4f1
CippApiDialog
JohnDuprey Feb 10, 2025
0cf1835
fix skeleton loading for second half
JohnDuprey Feb 10, 2025
92e0c42
fix CippApiResults reopen
JohnDuprey Feb 10, 2025
d777103
remove mapped tenants from integration map
JohnDuprey Feb 10, 2025
ee8cceb
CippApiDialog
JohnDuprey Feb 10, 2025
dc07d6d
clear search query on close dialog
JohnDuprey Feb 10, 2025
11fd2bb
scroll standards and keep search box at the top
JohnDuprey Feb 10, 2025
95514f8
fix securescore
JohnDuprey Feb 10, 2025
70232a6
Update index.js
JohnDuprey Feb 10, 2025
4ea3218
fix TimeAgo error
JohnDuprey Feb 10, 2025
e96891d
FEAT: Add clear immutable ID to offboarding wizard
kris6673 Feb 10, 2025
7fa788c
console.log removal because gary scares us
KelvinTegelaar Feb 10, 2025
b024c96
simpleColumns update handling
JohnDuprey Feb 10, 2025
996007c
add creatable properties and new AuthMethodsSettings standard
kris6673 Feb 10, 2025
03536a4
fix logout page
JohnDuprey Feb 10, 2025
c46ecb7
Memoize CippAutocomplete in form components
JohnDuprey Feb 10, 2025
59dc28a
Merge pull request #3610 from kris6673/authpolicy-standard
JohnDuprey Feb 10, 2025
3635117
Merge pull request #3608 from kris6673/offboarding-imm-id
JohnDuprey Feb 10, 2025
354e73d
Merge pull request #3602 from kris6673/autopilot-blank-prevention
JohnDuprey Feb 10, 2025
62911ca
Merge pull request #3601 from kris6673/entra-alert
JohnDuprey Feb 10, 2025
15183d8
Merge pull request #3600 from kris6673/edit-room
JohnDuprey Feb 10, 2025
2649a8d
community repositories
JohnDuprey Feb 10, 2025
7895a4d
Update CippApiResults.jsx
JohnDuprey Feb 11, 2025
2a56d47
repo browser page
JohnDuprey Feb 11, 2025
7a3e6d6
add branch selection to template library
JohnDuprey Feb 11, 2025
d97992f
template library
JohnDuprey Feb 11, 2025
e3423d3
add alert for github integration
JohnDuprey Feb 11, 2025
b8957ba
Update index.jsx
JohnDuprey Feb 11, 2025
4905c8b
fix repo search
JohnDuprey Feb 11, 2025
9653cc5
add default branch to query params
JohnDuprey Feb 11, 2025
c501bcc
default branch support
JohnDuprey Feb 11, 2025
456973a
Update repo.js
JohnDuprey Feb 11, 2025
e02c7ad
Update authentication methods to use negated state values
kris6673 Feb 11, 2025
4528617
api results tweaks
JohnDuprey Feb 11, 2025
e042dce
update repo view
JohnDuprey Feb 11, 2025
4728b3b
fix odata stuff
KelvinTegelaar Feb 11, 2025
384d892
Update CippApiResults.jsx
JohnDuprey Feb 11, 2025
252a1cf
tweaks and features
JohnDuprey Feb 12, 2025
89c860e
Add Set Upload Branch action
JohnDuprey Feb 12, 2025
2977f9e
graph explorer and table tweaks
JohnDuprey Feb 12, 2025
625974e
bring back required label on memoized text field
JohnDuprey Feb 12, 2025
adf719a
bugfixes
JohnDuprey Feb 12, 2025
f358b54
New DisableQRCodePin standard
kris6673 Feb 12, 2025
e33c8eb
Merge pull request #3615 from kris6673/qrcode-support
KelvinTegelaar Feb 12, 2025
22e0dbc
add save to github for all template pages
JohnDuprey Feb 12, 2025
af17615
add conditionals to GitHub action requiring a token
JohnDuprey Feb 12, 2025
be8595e
UI tweaks
JohnDuprey Feb 12, 2025
5d46544
Update index.js
JohnDuprey Feb 12, 2025
211e379
Update index.js
JohnDuprey Feb 12, 2025
8e622cf
add import template button
JohnDuprey Feb 12, 2025
7ce94e7
fix casing
kris6673 Feb 12, 2025
2116831
json view tweak
JohnDuprey Feb 12, 2025
bb2209a
fixes escos whining
KelvinTegelaar Feb 12, 2025
3b4b2dc
Merge pull request #3627 from kris6673/casing
KelvinTegelaar Feb 12, 2025
a5f4545
up version
JohnDuprey Feb 12, 2025
0e4d787
Merge pull request #3629 from KelvinTegelaar/dev
JohnDuprey Feb 12, 2025
ec49fb7
github null safety
JohnDuprey Feb 13, 2025
fe6c5d1
Merge pull request #3630 from KelvinTegelaar/dev
JohnDuprey Feb 13, 2025
a279d8b
null safety sam wizard
JohnDuprey Feb 13, 2025
6135d24
Merge pull request #3631 from KelvinTegelaar/dev
JohnDuprey Feb 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Tools/Start-CippDevEmulators.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
Write-Host 'Starting CIPP Dev Emulators'
Get-Command wt -ErrorAction Stop | Out-Null
Get-Process node -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue
$Path = (Get-Item $PSScriptRoot).Parent.Parent.FullName

$Process = Read-Host -Prompt 'Start Process Function (y/N)?'
pwsh -file (Join-Path $PSScriptRoot 'Start-CippDevInstallation.ps1')

Write-Host 'Starting CIPP Dev Emulators'

if (Test-Path (Join-Path $Path 'CIPP-API-Processor')) {
$Process = Read-Host -Prompt 'Start Process Function (y/N)?'
}

if ($Process -eq 'y') {
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
Expand Down
30 changes: 15 additions & 15 deletions Tools/Start-CippDevInstallation.ps1
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
$Path = (Get-Item $PSScriptRoot).Parent.Parent.FullName

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

if (-not(Get-Command azurite)) {
if (-not(Get-Command yarn -ErrorAction SilentlyContinue)) {
Write-Host 'Installing Yarn'
npm install --global yarn
}

if (-not(Get-Command azurite -ErrorAction SilentlyContinue)) {
Write-Host 'Installing Azurite'
npm install --global 'azurite'
yarn global add 'azurite'
}

if (-not(Get-Command swa)) {
if (-not(Get-Command swa -ErrorAction SilentlyContinue)) {
Write-Host 'Installing @azure/static-web-apps-cli'
npm install --global '@azure/static-web-apps-cli'
yarn global add '@azure/static-web-apps-cli'
}

if (-not(Get-Command func)) {
if (-not(Get-Command func -ErrorAction SilentlyContinue)) {
Write-Host 'Installing Azure Functions Core Tools'
npm install --global 'azure-functions-core-tools@4' --unsafe-perms true
}

if (-not(Get-Command yarn)) {
Write-Host 'Installing Yarn'
npm install --global yarn
yarn global add 'azure-functions-core-tools@4'
}

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

yarn install --cwd (Join-Path $Path "CIPP") --network-timeout 500000
1 change: 1 addition & 0 deletions public/discord-mark-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "7.1.3"
"version": "7.2.1"
}
2 changes: 1 addition & 1 deletion src/components/CippCards/CippBannerListCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const CippBannerListCard = (props) => {
</Stack>
</Stack>
{isCollapsible && (
<Collapse in={isExpanded}>
<Collapse in={isExpanded} unmountOnExit>
<Divider />
<Stack spacing={1}>
{item?.propertyItems?.length > 0 && (
Expand Down
7 changes: 7 additions & 0 deletions src/components/CippCards/CippButtonCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function CippButtonCard({
variant,
component = "card",
accordionExpanded = false,
onAccordionChange,
}) {
const [cardExpanded, setCardExpanded] = useState(accordionExpanded);
useEffect(() => {
Expand All @@ -31,6 +32,12 @@ export default function CippButtonCard({
}
}, [accordionExpanded]);

useEffect(() => {
if (onAccordionChange) {
onAccordionChange(cardExpanded);
}
}, [cardExpanded]);

return (
<Card variant={variant} sx={cardSx}>
{component === "card" && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/CippCards/CippDomainCards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export const CippDomainCards = ({ domain: propDomain = "", fullwidth = false })
</Button>
</Grid>
</Grid>
<Collapse in={optionsVisible}>
<Collapse in={optionsVisible} unmountOnExit>
<Stack direction="column" spacing={1} sx={{ mt: 1 }}>
<Controller
name="spfRecord"
Expand Down
20 changes: 15 additions & 5 deletions src/components/CippCards/CippPropertyListCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,25 @@ export const CippPropertyListCard = (props) => {
)}
</PropertyList>
<PropertyList>
{secondHalf.map((item, index) => (
{isFetching ? (
<PropertyListItem
key={"loading-bar"}
align={align}
divider={showDivider}
copyItems={copyItems}
key={`${index}-index-PropertyListOffCanvas`}
{...item}
label="Loading"
value={<Skeleton width={280} />}
/>
))}
) : (
secondHalf.map((item, index) => (
<PropertyListItem
align={align}
divider={showDivider}
copyItems={copyItems}
key={`${index}-index-PropertyListOffCanvas`}
{...item}
/>
))
)}
</PropertyList>
</Stack>
)}
Expand Down
96 changes: 87 additions & 9 deletions src/components/CippComponents/CippApiDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,21 @@ export const CippApiDialog = (props) => {
row = {},
relatedQueryKeys,
dialogAfterEffect,
allowResubmit = false,
...other
} = props;
const router = useRouter();
const [addedFieldData, setAddedFieldData] = useState({});
const [partialResults, setPartialResults] = useState([]);
const [isFormSubmitted, setIsFormSubmitted] = useState(false);

useEffect(() => {
if (createDialog.open) {
setIsFormSubmitted(false);
formHook.reset();
}
}, [createDialog.open]);

const [getRequestInfo, setGetRequestInfo] = useState({
url: "",
waiting: false,
Expand Down Expand Up @@ -103,6 +113,7 @@ export const CippApiDialog = (props) => {
};
const tenantFilter = useSettings().currentTenant;
const handleActionClick = (row, action, formData) => {
setIsFormSubmitted(true);
if (action.multiPost === undefined) {
action.multiPost = false;
}
Expand Down Expand Up @@ -207,14 +218,63 @@ export const CippApiDialog = (props) => {
const onSubmit = (data) => handleActionClick(row, api, data);
const selectedType = api.type === "POST" ? actionPostRequest : actionGetRequest;

useEffect(() => {
if (api?.setDefaultValues && createDialog.open) {
fields.map((field) => {
if (
((typeof row[field.name] === "string" && field.type === "textField") ||
(typeof row[field.name] === "boolean" && field.type === "switch")) &&
row[field.name] !== undefined &&
row[field.name] !== null &&
row[field.name] !== ""
) {
formHook.setValue(field.name, row[field.name]);
} else if (Array.isArray(row[field.name]) && field.type === "autoComplete") {
var values = [];
row[field.name].map((element) => {
if (element.label && element.value) {
values.push(element);
} else if (typeof element === "string" || typeof element === "number") {
values.push({
label: element,
value: element,
});
}
});
formHook.setValue(field.name, values);
} else if (
field.type === "autoComplete" &&
row[field.name] !== "" &&
(typeof row[field.name] === "string" ||
(typeof row[field.name] === "object" &&
row[field.name] !== undefined &&
row[field.name] !== null))
) {
if (typeof row[field.name] === "string") {
formHook.setValue(field.name, {
label: row[field.name],
value: row[field.name],
});
} else if (
typeof row[field.name] === "object" &&
row[field.name]?.label &&
row[field.name]?.value
) {
formHook.setValue(field.name, row[field.name]);
}
}
});
}
}, [createDialog.open, api?.setDefaultValues]);

const getNestedValue = (obj, path) => {
return path
.split(".")
.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), obj);
};

// Handling link navigation
if (api.link) {
const getNestedValue = (obj, path) => {
return path
.split(".")
.reduce((acc, key) => (acc && acc[key] !== undefined ? acc[key] : undefined), obj);
};

const linkWithRowData = api.link.replace(/\[([^\]]+)\]/g, (_, key) => {
return getNestedValue(row, key) || `[${key}]`;
});
Expand All @@ -239,17 +299,35 @@ export const CippApiDialog = (props) => {
setPartialResults([]);
};

var confirmText;
if (typeof api?.confirmText === "string" && !Array.isArray(row)) {
confirmText = api.confirmText.replace(/\[([^\]]+)\]/g, (_, key) => {
return getNestedValue(row, key) || `[${key}]`;
});
} else if (Array.isArray(row) && row.length > 1) {
confirmText = api.confirmText.replace(/\[([^\]]+)\]/g, "the selected rows");
} else if (Array.isArray(row) && row.length === 1) {
confirmText = api.confirmText.replace(/\[([^\]]+)\]/g, (_, key) => {
return getNestedValue(row[0], key) || `[${key}]`;
});
} else {
confirmText = api.confirmText;
}

return (
<Dialog fullWidth maxWidth="sm" onClose={handleClose} open={createDialog.open}>
<form onSubmit={formHook.handleSubmit(onSubmit)}>
<DialogTitle>{title}</DialogTitle>
<DialogContent>
<Stack spacing={3}>{api.confirmText}</Stack>
<Stack spacing={3}>{confirmText}</Stack>
</DialogContent>
<DialogContent>
<Grid container spacing={2}>
{fields &&
fields.map((fieldProps, index) => {
if (fieldProps?.api?.processFieldData) {
fieldProps.api.data = processActionData(fieldProps.api.data, row);
}
return (
<Grid item xs={12} key={index}>
<CippFormComponent
Expand All @@ -270,8 +348,8 @@ export const CippApiDialog = (props) => {
<Button color="inherit" onClick={() => handleClose()}>
Close
</Button>
<Button variant="contained" type="submit">
Confirm
<Button variant="contained" type="submit" disabled={isFormSubmitted && !allowResubmit}>
{isFormSubmitted && allowResubmit ? "Reconfirm" : "Confirm"}
</Button>
</DialogActions>
</form>
Expand Down
Loading