-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api-client,app,react-api-client): upload splash logo from deskto…
…p app (#14941) adds the upload input component, api-client, and react-api-client functions needed to upload a splash logo from the factory mode slideout closes PLAT-283
- Loading branch information
1 parent
737c58c
commit 433ef44
Showing
14 changed files
with
397 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { POST, request } from '../request' | ||
|
||
import type { ResponsePromise } from '../request' | ||
import type { HostConfig } from '../types' | ||
import type { RobotSettingsResponse, UpdateRobotSettingRequest } from './types' | ||
|
||
export function updateRobotSetting( | ||
config: HostConfig, | ||
id: string, | ||
value: boolean | ||
): ResponsePromise<RobotSettingsResponse> { | ||
return request<RobotSettingsResponse, UpdateRobotSettingRequest>( | ||
POST, | ||
'/settings', | ||
{ id, value }, | ||
config | ||
) | ||
} |
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,24 @@ | ||
import { POST, request } from '../request' | ||
import type { ResponsePromise } from '../request' | ||
import type { HostConfig } from '../types' | ||
|
||
export function createSplash( | ||
config: HostConfig, | ||
file: File | ||
): ResponsePromise<void> { | ||
// sanitize file name to ensure no spaces | ||
const renamedFile = new File([file], file.name.replace(' ', '_'), { | ||
type: 'image/png', | ||
}) | ||
|
||
const formData = new FormData() | ||
formData.append('file', renamedFile) | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type | ||
return request<void, FormData>( | ||
POST, | ||
'/system/oem_mode/upload_splash', | ||
formData, | ||
config | ||
) | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export { createAuthorization } from './createAuthorization' | ||
export { createRegistration } from './createRegistration' | ||
export { createSplash } from './createSplash' | ||
export { getConnections } from './getConnections' | ||
export * from './types' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import * as React from 'react' | ||
import { css } from 'styled-components' | ||
|
||
import { | ||
ALIGN_CENTER, | ||
BORDERS, | ||
Btn, | ||
COLORS, | ||
DIRECTION_COLUMN, | ||
Flex, | ||
Icon, | ||
JUSTIFY_SPACE_BETWEEN, | ||
SPACING, | ||
StyledText, | ||
} from '@opentrons/components' | ||
|
||
const FILE_UPLOAD_STYLE = css` | ||
&:hover > svg { | ||
background: ${COLORS.black90}${COLORS.opacity20HexCode}; | ||
} | ||
&:active > svg { | ||
background: ${COLORS.black90}${COLORS.opacity20HexCode}}; | ||
} | ||
` | ||
|
||
interface FileUploadProps { | ||
file: File | ||
fileError: string | null | ||
handleClick: () => unknown | ||
} | ||
|
||
export function FileUpload({ | ||
file, | ||
fileError, | ||
handleClick, | ||
}: FileUploadProps): JSX.Element { | ||
return ( | ||
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing4}> | ||
<Btn onClick={handleClick} aria-label="remove_file"> | ||
<Flex | ||
alignItems={ALIGN_CENTER} | ||
backgroundColor={fileError == null ? COLORS.grey20 : COLORS.red30} | ||
borderRadius={BORDERS.borderRadius4} | ||
height={SPACING.spacing44} | ||
justifyContent={JUSTIFY_SPACE_BETWEEN} | ||
padding={SPACING.spacing8} | ||
css={FILE_UPLOAD_STYLE} | ||
> | ||
<StyledText as="p">{file.name}</StyledText> | ||
<Icon name="close" size="1.5rem" borderRadius="50%" /> | ||
</Flex> | ||
</Btn> | ||
{fileError != null ? ( | ||
<StyledText as="label" color={COLORS.red50}> | ||
{fileError} | ||
</StyledText> | ||
) : null} | ||
</Flex> | ||
) | ||
} |
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
Oops, something went wrong.