-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73e5f47
commit 7ae50b9
Showing
22 changed files
with
478 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
frontend/pages/ManageControlsPage/SetupExperience/cards/SetupAssistant/SetupAssistant.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { useState } from "react"; | ||
|
||
import SectionHeader from "components/SectionHeader"; | ||
import Spinner from "components/Spinner"; | ||
|
||
import SetupAssistantPreview from "./components/SetupAssistantPreview"; | ||
import SetupAssistantPackageUploader from "./components/SetupAssistantPackageUploader"; | ||
import SetuAssistantUploadedProfileView from "./components/SetupAssistantUploadedProfileView/SetupAssistantUploadedProfileView"; | ||
|
||
const baseClass = "setup-assistant"; | ||
|
||
interface ISetupAssistantProps { | ||
currentTeamId: number; | ||
} | ||
|
||
const StartupAssistant = ({ currentTeamId }: ISetupAssistantProps) => { | ||
const [showDeleteProfileModal, setShowDeleteProfileModal] = useState(false); | ||
|
||
const isLoading = false; | ||
|
||
const noPackageUploaded = true; | ||
|
||
return ( | ||
<div className={baseClass}> | ||
<SectionHeader title="Setup assistant" /> | ||
{isLoading ? ( | ||
<Spinner /> | ||
) : ( | ||
<div className={`${baseClass}__content`}> | ||
{false ? ( | ||
<> | ||
<SetupAssistantPackageUploader | ||
currentTeamId={currentTeamId} | ||
onUpload={() => 1} | ||
/> | ||
<div className={`${baseClass}__preview-container`}> | ||
<SetupAssistantPreview /> | ||
</div> | ||
</> | ||
) : ( | ||
<> | ||
<SetuAssistantUploadedProfileView | ||
profileMetaData={1} | ||
currentTeamId={currentTeamId} | ||
onDelete={() => setShowDeleteProfileModal(true)} | ||
/> | ||
<div className={`${baseClass}__preview-container`}> | ||
<SetupAssistantPreview /> | ||
</div> | ||
</> | ||
)} | ||
</div> | ||
)} | ||
{/* {showDeleteProfileModal && ( | ||
<DeletePackageModal | ||
onDelete={onDelete} | ||
onCancel={() => setShowDeletePackageModal(false)} | ||
/> | ||
)} */} | ||
</div> | ||
); | ||
}; | ||
|
||
export default StartupAssistant; |
15 changes: 15 additions & 0 deletions
15
frontend/pages/ManageControlsPage/SetupExperience/cards/SetupAssistant/_styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.setup-assistant { | ||
&__content { | ||
max-width: $break-xxl; | ||
margin: 0 auto; | ||
display: flex; | ||
justify-content: space-between; | ||
gap: $pad-xxlarge; | ||
} | ||
|
||
@media (max-width: $break-md) { | ||
&__content { | ||
flex-direction: column; | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...SetupAssistant/components/SetupAssistantPackageUploader/SetupAssistantPackageUploader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import React, { useContext, useState } from "react"; | ||
import { AxiosResponse } from "axios"; | ||
|
||
import { IApiError } from "interfaces/errors"; | ||
import { NotificationContext } from "context/notification"; | ||
import mdmAPI from "services/entities/mdm"; | ||
|
||
import CustomLink from "components/CustomLink"; | ||
import FileUploader from "components/FileUploader"; | ||
|
||
import { UPLOAD_ERROR_MESSAGES, getErrorMessage } from "./helpers"; | ||
|
||
const baseClass = "setup-assistant-package-uploader"; | ||
|
||
interface ISetupAssistantPackageUploaderProps { | ||
currentTeamId: number; | ||
onUpload: () => void; | ||
} | ||
|
||
const SetupAssistantPackageUploader = ({ | ||
currentTeamId, | ||
onUpload, | ||
}: ISetupAssistantPackageUploaderProps) => { | ||
const { renderFlash } = useContext(NotificationContext); | ||
const [showLoading, setShowLoading] = useState(false); | ||
|
||
const onUploadFile = async (files: FileList | null) => { | ||
setShowLoading(true); | ||
|
||
if (!files || files.length === 0) { | ||
setShowLoading(false); | ||
return; | ||
} | ||
|
||
const file = files[0]; | ||
|
||
// quick exit if the file type is incorrect | ||
if (!file.name.includes(".pkg")) { | ||
renderFlash("error", UPLOAD_ERROR_MESSAGES.wrongType.message); | ||
setShowLoading(false); | ||
return; | ||
} | ||
|
||
try { | ||
await mdmAPI.uploadBootstrapPackage(file, currentTeamId); | ||
renderFlash("success", "Successfully uploaded!"); | ||
onUpload(); | ||
} catch (e) { | ||
const error = e as AxiosResponse<IApiError>; | ||
const errMessage = getErrorMessage(error); | ||
renderFlash("error", errMessage); | ||
} finally { | ||
setShowLoading(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={baseClass}> | ||
<p> | ||
Add an automatic enrollment profile to customize the macOS Setup | ||
Assistant. | ||
<CustomLink | ||
url=" https://fleetdm.com/learn-more-about/setup-assistant" | ||
text="Learn how" | ||
newTab | ||
/> | ||
</p> | ||
<FileUploader | ||
message="Automatic enrollment profile (.json)" | ||
graphicName="file-configuration-profile" | ||
accept=".json" | ||
buttonMessage="Add profile" | ||
onFileUpload={onUploadFile} | ||
isLoading={showLoading} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SetupAssistantPackageUploader; |
6 changes: 6 additions & 0 deletions
6
...etupExperience/cards/SetupAssistant/components/SetupAssistantPackageUploader/_styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.setup-assistant-package-uploader { | ||
> p { | ||
font-size: $x-small; | ||
margin: 0 0 $pad-large; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
.../SetupExperience/cards/SetupAssistant/components/SetupAssistantPackageUploader/helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { AxiosResponse } from "axios"; | ||
import { IApiError } from "interfaces/errors"; | ||
|
||
export const UPLOAD_ERROR_MESSAGES = { | ||
wrongType: { | ||
condition: (reason: string) => reason.includes("invalid file type"), | ||
message: "Couldn’t upload. The file should be a package (.pkg).", | ||
}, | ||
unsigned: { | ||
condition: (reason: string) => reason.includes("file is not"), | ||
message: | ||
"Couldn’t upload. The package must be signed. Click “Learn more” below to learn how to sign.", | ||
}, | ||
default: { | ||
condition: () => false, | ||
message: "Couldn’t upload. Please try again.", | ||
}, | ||
}; | ||
|
||
export const getErrorMessage = (err: AxiosResponse<IApiError>) => { | ||
const apiReason = err.data.errors[0].reason; | ||
|
||
const error = Object.values(UPLOAD_ERROR_MESSAGES).find((errType) => | ||
errType.condition(apiReason) | ||
); | ||
|
||
if (!error) { | ||
return UPLOAD_ERROR_MESSAGES.default.message; | ||
} | ||
|
||
return error.message; | ||
}; |
1 change: 1 addition & 0 deletions
1
...ge/SetupExperience/cards/SetupAssistant/components/SetupAssistantPackageUploader/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./SetupAssistantPackageUploader"; |
35 changes: 35 additions & 0 deletions
35
...xperience/cards/SetupAssistant/components/SetupAssistantPreview/SetupAssistantPreview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React from "react"; | ||
|
||
import Card from "components/Card"; | ||
|
||
import OsSetupPreview from "../../../../../../../../assets/images/os-setup-preview.gif"; | ||
|
||
const baseClass = "setup-assistant-preview"; | ||
|
||
const SetupAssistantPreview = () => { | ||
return ( | ||
<Card | ||
color="gray" | ||
borderRadiusSize="medium" | ||
paddingSize="xxlarge" | ||
className={baseClass} | ||
> | ||
<h2>End user experience</h2> | ||
<p> | ||
After the end user continues past the <b>Remote Management</b> screen, | ||
macOS Setup Assistant displays several screens by default. | ||
</p> | ||
<p> | ||
By adding an automatic enrollment profile you can customize which | ||
screens are displayed and more. | ||
</p> | ||
<img | ||
className={`${baseClass}__preview-img`} | ||
src={OsSetupPreview} | ||
alt="OS setup preview" | ||
/> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default SetupAssistantPreview; |
16 changes: 16 additions & 0 deletions
16
...lsPage/SetupExperience/cards/SetupAssistant/components/SetupAssistantPreview/_styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.setup-assistant-preview { | ||
font-size: $x-small; | ||
|
||
h2 { | ||
margin: 0; | ||
font-size: $small; | ||
font-weight: normal; | ||
} | ||
|
||
&__preview-img { | ||
margin-top: $pad-xxlarge; | ||
width: 100%; | ||
display: block; | ||
margin: 40px auto 0; | ||
} | ||
} |
Oops, something went wrong.