Skip to content

Commit 924d661

Browse files
added task to restore
1 parent bab7f3e commit 924d661

File tree

1 file changed

+61
-154
lines changed

1 file changed

+61
-154
lines changed

src/views/tenant/backup/RestoreBackup.jsx

Lines changed: 61 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,22 @@ const OffboardingWizard = () => {
4242

4343
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()
4444

45-
const handleSubmit = async (values) => {
45+
const handleSubmit = (values) => {
46+
const startDate = new Date()
47+
const unixTime = Math.floor(startDate.getTime() / 1000) - 45
4648
const shippedValues = {
4749
TenantFilter: tenantDomain,
48-
OOO: values.OOO ? values.OOO : '',
49-
forward: values.forward ? values.forward.value : '',
50-
OnedriveAccess: values.OnedriveAccess ? values.OnedriveAccess : '',
51-
AccessNoAutomap: values.AccessNoAutomap ? values.AccessNoAutomap : '',
52-
AccessAutomap: values.AccessAutomap ? values.AccessAutomap : '',
53-
ConvertToShared: values.ConvertToShared,
54-
HideFromGAL: values.HideFromGAL,
55-
DisableSignIn: values.DisableSignIn,
56-
RemoveGroups: values.RemoveGroups,
57-
RemoveLicenses: values.RemoveLicenses,
58-
ResetPass: values.ResetPass,
59-
RevokeSessions: values.RevokeSessions,
60-
user: values.User,
61-
deleteuser: values.DeleteUser,
62-
removeRules: values.RemoveRules,
63-
removeMobile: values.RemoveMobile,
64-
keepCopy: values.keepCopy,
65-
removePermissions: values.removePermissions,
66-
PostExecution: values.Scheduled?.enabled
67-
? { webhook: values.webhook, psa: values.psa, email: values.email }
68-
: '',
50+
Name: `CIPP Restore ${tenantDomain}`,
51+
Command: { value: `New-CIPPRestore` },
52+
Parameters: { Type: 'Scheduled', ScheduledBackupValues: { ...values } },
53+
ScheduledTime: unixTime,
54+
PostExecution: {
55+
Webhook: values.webhook,
56+
Email: values.email,
57+
PSA: values.psa,
58+
},
6959
}
70-
71-
//alert(JSON.stringify(values, null, 2))
72-
genericPostRequest({ path: '/api/ExecOffboardUser', values: shippedValues })
60+
genericPostRequest({ path: '/api/AddScheduledItem', values: shippedValues }).then((res) => {})
7361
}
7462

7563
return (
@@ -101,7 +89,7 @@ const OffboardingWizard = () => {
10189
name: `${backup.RowKey}`,
10290
}))}
10391
placeholder={!currentBackupsIsFetching ? 'Select a backup' : 'Loading...'}
104-
name="User"
92+
name="backup"
10593
/>
10694
{currentBackupsError && <span>Failed to load list of Current Backups</span>}
10795
</div>
@@ -117,44 +105,53 @@ const OffboardingWizard = () => {
117105
<CRow>
118106
<CCol>
119107
<h3 className="underline mb-4">Identity</h3>
120-
<RFFCFormSwitch label="User List" />
121-
<RFFCFormSwitch label="Groups" />
108+
<RFFCFormSwitch name="users" label="User List" />
109+
<RFFCFormSwitch name="groups" label="Groups" />
122110
<h3 className="underline mb-4">Conditional Access</h3>
123-
<RFFCFormSwitch label="Conditional Access" />
124-
<RFFCFormSwitch label="Named Locations" />
125-
<RFFCFormSwitch label="Authentication Strengths" />
111+
<RFFCFormSwitch name="ca" label="Conditional Access" />
112+
<RFFCFormSwitch name="namedlocations" label="Named Locations" />
113+
<RFFCFormSwitch name="authstrengths" label="Authentication Strengths" />
126114
</CCol>
127115
<CCol>
128116
<h3 className="underline mb-4">Intune</h3>
129-
<RFFCFormSwitch label="Intune Configuration Policies" />
130-
<RFFCFormSwitch label="Intune Compliance Policies" />
131-
<RFFCFormSwitch label="Intune Protection Policies" />
117+
<RFFCFormSwitch name="intuneconfig" label="Intune Configuration Policies" />
118+
<RFFCFormSwitch name="intunecompliance" label="Intune Compliance Policies" />
119+
<RFFCFormSwitch name="intuneprotection" label="Intune Protection Policies" />
132120
<h3 className="underline mb-4">CIPP</h3>
133-
<RFFCFormSwitch label="Alerts Configuration" />
134-
<RFFCFormSwitch label="Standards Configuration" />
121+
<RFFCFormSwitch name="CippAlerts" label="Alerts Configuration" />
122+
<RFFCFormSwitch name="CippStandards" label="Standards Configuration" />
135123
</CCol>
136124
</CRow>
137125
<hr className="my-4" />
138126
<CRow>
139127
<CCol>
140128
<RFFCFormSwitch name="overwrite" label="Overwrite existing entries" />
141129
</CCol>
142-
</CRow>
143-
<Condition when="overwrite" is={true}>
144-
<CippCallout color="warning">
145-
<h5>Warning</h5>
146-
<p>
147-
Overwriting existing entries will remove the current settings and replace them with
148-
the backup settings. If you have selected to restore users, all properties will be
149-
overwritten with the backup settings.
150-
</p>
130+
<Condition when="overwrite" is={true}>
131+
<CippCallout color="warning">
132+
<h5>Warning</h5>
133+
<p>
134+
Overwriting existing entries will remove the current settings and replace them
135+
with the backup settings. If you have selected to restore users, all properties
136+
will be overwritten with the backup settings.
137+
</p>
151138

152-
<p>
153-
To prevent and skip already existing entries, deselect the setting from the list
154-
above, or disable overwrite.
155-
</p>
156-
</CippCallout>
157-
</Condition>
139+
<p>
140+
To prevent and skip already existing entries, deselect the setting from the list
141+
above, or disable overwrite.
142+
</p>
143+
</CippCallout>
144+
</Condition>
145+
</CRow>
146+
<hr className="my-4" />
147+
<CRow>
148+
<CCol>
149+
<label>Send Restore results to:</label>
150+
<RFFCFormSwitch name="webhook" label="Webhook" />
151+
<RFFCFormSwitch name="email" label="E-mail" />
152+
<RFFCFormSwitch name="psa" label="PSA" />
153+
</CCol>
154+
</CRow>
158155
</div>
159156
<hr className="my-4" />
160157
</CippWizard.Page>
@@ -170,13 +167,7 @@ const OffboardingWizard = () => {
170167
<CSpinner>Loading</CSpinner>
171168
</CCallout>
172169
)}
173-
{postResults.isSuccess && (
174-
<CCallout color="success">
175-
{postResults.data.Results.map((message, idx) => {
176-
return <li key={idx}>{message}</li>
177-
})}
178-
</CCallout>
179-
)}
170+
{postResults.isSuccess && <CCallout color="success">{postResults.data.Results}</CCallout>}
180171
{!postResults.isSuccess && (
181172
<FormSpy>
182173
{/* eslint-disable react/prop-types */}
@@ -189,6 +180,10 @@ const OffboardingWizard = () => {
189180
<h5 className="mb-0">Selected Tenant:</h5>
190181
{tenantDomain}
191182
</CListGroupItem>
183+
<CListGroupItem className="d-flex justify-content-between align-items-center">
184+
<h5 className="mb-0">Selected Backup:</h5>
185+
{props.values.backup.value}
186+
</CListGroupItem>
192187
</CListGroup>
193188
<hr />
194189
</CCol>
@@ -197,123 +192,35 @@ const OffboardingWizard = () => {
197192
<CCol md={{ span: 6, offset: 3 }}>
198193
<CListGroup flush>
199194
<CListGroupItem className="d-flex justify-content-between align-items-center">
200-
Revoke Sessions
201-
<FontAwesomeIcon
202-
color="#f77f00"
203-
size="lg"
204-
icon={props.values.RevokeSessions ? faCheck : faTimes}
205-
/>
206-
</CListGroupItem>
207-
<CListGroupItem className="d-flex justify-content-between align-items-center">
208-
Remove all mobile devices
209-
<FontAwesomeIcon
210-
color="#f77f00"
211-
size="lg"
212-
icon={props.values.RemoveMobile ? faCheck : faTimes}
213-
/>
214-
</CListGroupItem>
215-
<CListGroupItem className="d-flex justify-content-between align-items-center">
216-
Remove all mailbox rules
217-
<FontAwesomeIcon
218-
color="#f77f00"
219-
size="lg"
220-
icon={props.values.RemoveRules ? faCheck : faTimes}
221-
/>
222-
</CListGroupItem>
223-
<CListGroupItem className="d-flex justify-content-between align-items-center">
224-
Remove all mailbox permissions
225-
<FontAwesomeIcon
226-
color="#f77f00"
227-
size="lg"
228-
icon={props.values.removePermissions ? faCheck : faTimes}
229-
/>
230-
</CListGroupItem>
231-
<CListGroupItem className="d-flex justify-content-between align-items-center">
232-
Remove Licenses
233-
<FontAwesomeIcon
234-
color="#f77f00"
235-
size="lg"
236-
icon={props.values.RemoveLicenses ? faCheck : faTimes}
237-
/>
238-
</CListGroupItem>
239-
<CListGroupItem className="d-flex justify-content-between align-items-center">
240-
Convert to Shared
241-
<FontAwesomeIcon
242-
color="#f77f00"
243-
size="lg"
244-
icon={props.values.ConvertToShared ? faCheck : faTimes}
245-
/>
246-
</CListGroupItem>
247-
<CListGroupItem className="d-flex justify-content-between align-items-center">
248-
Disable Sign-in
249-
<FontAwesomeIcon
250-
color="#f77f00"
251-
size="lg"
252-
icon={props.values.DisableSignIn ? faCheck : faTimes}
253-
/>
254-
</CListGroupItem>
255-
<CListGroupItem className="d-flex justify-content-between align-items-center">
256-
Reset Password
257-
<FontAwesomeIcon
258-
color="#f77f00"
259-
size="lg"
260-
icon={props.values.ResetPass ? faCheck : faTimes}
261-
/>
262-
</CListGroupItem>
263-
<CListGroupItem className="d-flex justify-content-between align-items-center">
264-
Remove from all groups
265-
<FontAwesomeIcon
266-
color="#f77f00"
267-
size="lg"
268-
icon={props.values.RemoveGroups ? faCheck : faTimes}
269-
/>
270-
</CListGroupItem>
271-
<CListGroupItem className="d-flex justify-content-between align-items-center">
272-
Hide from Global Address List
273-
<FontAwesomeIcon
274-
color="#f77f00"
275-
size="lg"
276-
icon={props.values.HideFromGAL ? faCheck : faTimes}
277-
/>
278-
</CListGroupItem>
279-
<CListGroupItem className="d-flex justify-content-between align-items-center">
280-
Set Out of Office
281-
<FontAwesomeIcon
282-
color="#f77f00"
283-
size="lg"
284-
icon={props.values.OOO ? faCheck : faTimes}
285-
/>
286-
</CListGroupItem>
287-
<CListGroupItem className="d-flex justify-content-between align-items-center">
288-
Give another user access to the mailbox with automap
195+
Overwrite existing configuration
289196
<FontAwesomeIcon
290197
color="#f77f00"
291198
size="lg"
292-
icon={props.values.AccessAutomap ? faCheck : faTimes}
199+
icon={props.values.overwrite ? faCheck : faTimes}
293200
/>
294201
</CListGroupItem>
295202
<CListGroupItem className="d-flex justify-content-between align-items-center">
296-
Give another user access to the mailbox without automap
203+
Send results to Webhook
297204
<FontAwesomeIcon
298205
color="#f77f00"
299206
size="lg"
300-
icon={props.values.AccessNoAutomap ? faCheck : faTimes}
207+
icon={props.values.webhook ? faCheck : faTimes}
301208
/>
302209
</CListGroupItem>
303210
<CListGroupItem className="d-flex justify-content-between align-items-center">
304-
Give another user access to OneDrive
211+
Send results to E-Mail
305212
<FontAwesomeIcon
306213
color="#f77f00"
307214
size="lg"
308-
icon={props.values.OnedriveAccess ? faCheck : faTimes}
215+
icon={props.values.email ? faCheck : faTimes}
309216
/>
310217
</CListGroupItem>
311218
<CListGroupItem className="d-flex justify-content-between align-items-center">
312-
Forward all e-mail to another user
219+
Send results to PSA
313220
<FontAwesomeIcon
314221
color="#f77f00"
315222
size="lg"
316-
icon={props.values.forward ? faCheck : faTimes}
223+
icon={props.values.psa ? faCheck : faTimes}
317224
/>
318225
</CListGroupItem>
319226
</CListGroup>

0 commit comments

Comments
 (0)