-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added toggle for notification support (#10872)
* feat: added toggle for notification support * feat: updated snaps * feat: added test for toggle support notification component * feat: added generated badges * fix: corrected snapshot * chore: updates badges
- Loading branch information
Showing
22 changed files
with
191 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-1020 KB
.yarn/cache/@rollup-rollup-linux-x64-gnu-npm-4.9.6-c67944ac17-10.zip
Binary file not shown.
Binary file renamed
BIN
+14.6 MB
...nux-x64-gnu-npm-1.3.107-1986905504-10.zip → ...arwin-arm64-npm-1.3.100-d327f936fd-10.zip
Binary file not shown.
Binary file renamed
BIN
+14.7 MB
...nux-x64-gnu-npm-1.3.100-d30180f514-10.zip → ...arwin-arm64-npm-1.3.107-7cf917d486-10.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
80 changes: 80 additions & 0 deletions
80
...tal/src/components/apps/__tests__/__snapshots__/toggle-support-notification.test.tsx.snap
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 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ToggleSupportNotification should match a snapshot 1`] = ` | ||
{ | ||
"asFragment": [Function], | ||
"baseElement": <body> | ||
<div> | ||
<mock-styled.div /> | ||
<mock-styled.button | ||
classname="el-intent-primary" | ||
disabled="true" | ||
> | ||
<mock-styled.div /> | ||
Toggle Support Notification | ||
</mock-styled.button> | ||
</div> | ||
</body>, | ||
"container": <div> | ||
<mock-styled.div /> | ||
<mock-styled.button | ||
classname="el-intent-primary" | ||
disabled="true" | ||
> | ||
<mock-styled.div /> | ||
Toggle Support Notification | ||
</mock-styled.button> | ||
</div>, | ||
"debug": [Function], | ||
"findAllByAltText": [Function], | ||
"findAllByDisplayValue": [Function], | ||
"findAllByLabelText": [Function], | ||
"findAllByPlaceholderText": [Function], | ||
"findAllByRole": [Function], | ||
"findAllByTestId": [Function], | ||
"findAllByText": [Function], | ||
"findAllByTitle": [Function], | ||
"findByAltText": [Function], | ||
"findByDisplayValue": [Function], | ||
"findByLabelText": [Function], | ||
"findByPlaceholderText": [Function], | ||
"findByRole": [Function], | ||
"findByTestId": [Function], | ||
"findByText": [Function], | ||
"findByTitle": [Function], | ||
"getAllByAltText": [Function], | ||
"getAllByDisplayValue": [Function], | ||
"getAllByLabelText": [Function], | ||
"getAllByPlaceholderText": [Function], | ||
"getAllByRole": [Function], | ||
"getAllByTestId": [Function], | ||
"getAllByText": [Function], | ||
"getAllByTitle": [Function], | ||
"getByAltText": [Function], | ||
"getByDisplayValue": [Function], | ||
"getByLabelText": [Function], | ||
"getByPlaceholderText": [Function], | ||
"getByRole": [Function], | ||
"getByTestId": [Function], | ||
"getByText": [Function], | ||
"getByTitle": [Function], | ||
"queryAllByAltText": [Function], | ||
"queryAllByDisplayValue": [Function], | ||
"queryAllByLabelText": [Function], | ||
"queryAllByPlaceholderText": [Function], | ||
"queryAllByRole": [Function], | ||
"queryAllByTestId": [Function], | ||
"queryAllByText": [Function], | ||
"queryAllByTitle": [Function], | ||
"queryByAltText": [Function], | ||
"queryByDisplayValue": [Function], | ||
"queryByLabelText": [Function], | ||
"queryByPlaceholderText": [Function], | ||
"queryByRole": [Function], | ||
"queryByTestId": [Function], | ||
"queryByText": [Function], | ||
"queryByTitle": [Function], | ||
"rerender": [Function], | ||
"unmount": [Function], | ||
} | ||
`; |
24 changes: 24 additions & 0 deletions
24
packages/admin-portal/src/components/apps/__tests__/toggle-support-notification.test.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,24 @@ | ||
import React from 'react' | ||
import { render } from '../../../tests/react-testing' | ||
import { ToggleSupportNotification, handleSetSupportNotification } from '../toggle-support-notification' | ||
|
||
jest.mock('@reapit/use-reapit-data', () => ({ | ||
...jest.requireActual('@reapit/use-reapit-data'), | ||
useReapitUpdate: jest.fn(() => [undefined, undefined, jest.fn(), false]), | ||
})) | ||
|
||
describe('ToggleSupportNotification', () => { | ||
it('should match a snapshot', () => { | ||
expect(render(<ToggleSupportNotification appId="MOCK_ID" hasReadAccess={true} />)).toMatchSnapshot() | ||
}) | ||
|
||
it('handleSetSupportNotification', () => { | ||
const setNotificationFunction = jest.fn() | ||
|
||
const curried = handleSetSupportNotification(setNotificationFunction) | ||
|
||
curried() | ||
|
||
expect(setNotificationFunction).toHaveBeenCalledTimes(1) | ||
}) | ||
}) |
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
55 changes: 55 additions & 0 deletions
55
packages/admin-portal/src/components/apps/toggle-support-notification.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,55 @@ | ||
import { BodyText, Button, ButtonGroup, useModal } from '@reapit/elements' | ||
import { UpdateActionNames, updateActions, useReapitUpdate } from '@reapit/use-reapit-data' | ||
import React, { FC, useEffect } from 'react' | ||
import { reapitConnectBrowserSession } from '../../core/connect-session' | ||
|
||
export const handleSetSupportNotification = (setSupportNotification: (data: any) => void) => () => { | ||
setSupportNotification({ | ||
sendInternalInstallNotification: true, | ||
}) | ||
} | ||
|
||
export const ToggleSupportNotification: FC<{ appId: string; hasReadAccess: boolean }> = ({ appId, hasReadAccess }) => { | ||
const { Modal, openModal, closeModal } = useModal() | ||
|
||
const [loading, , setSupportNotification, done] = useReapitUpdate({ | ||
reapitConnectBrowserSession, | ||
action: updateActions[UpdateActionNames.updateApp], | ||
method: 'PUT', | ||
uriParams: { | ||
appId, | ||
}, | ||
headers: { | ||
['Api-Version']: 'latest', | ||
}, | ||
}) | ||
|
||
useEffect(() => { | ||
if (done) closeModal() | ||
}, [done]) | ||
|
||
return ( | ||
<> | ||
<Button onClick={openModal} intent="primary" disabled={hasReadAccess}> | ||
Toggle Support Notification | ||
</Button> | ||
|
||
<Modal title={'Toggle Support Notifications'}> | ||
<BodyText>This will enable the support notifications</BodyText> | ||
<ButtonGroup alignment="center"> | ||
<Button intent="secondary" onClick={closeModal}> | ||
Cancel | ||
</Button> | ||
<Button | ||
intent="primary" | ||
disabled={loading} | ||
loading={loading} | ||
onClick={handleSetSupportNotification(setSupportNotification)} | ||
> | ||
Confirm | ||
</Button> | ||
</ButtonGroup> | ||
</Modal> | ||
</> | ||
) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.