This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 831
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Device manager - add learn more popups to filtered sessions section (#…
…9497) * add learn more to filtered sessions * fullstop * update tests and i18n for fullstop * remove unused switch * whitespace * use correct card type
- Loading branch information
Kerry
authored
Oct 26, 2022
1 parent
de51bfd
commit 6964254
Showing
9 changed files
with
270 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
.mx_LearnMore_button { | ||
margin-left: $spacing-4; | ||
} |
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,56 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { _t } from '../../../languageHandler'; | ||
import Modal from '../../../Modal'; | ||
import InfoDialog from '../dialogs/InfoDialog'; | ||
import AccessibleButton, { IAccessibleButtonProps } from './AccessibleButton'; | ||
|
||
interface Props extends IAccessibleButtonProps { | ||
title: string; | ||
description: string | React.ReactNode; | ||
} | ||
|
||
const LearnMore: React.FC<Props> = ({ | ||
title, | ||
description, | ||
...rest | ||
}) => { | ||
const onClick = () => { | ||
Modal.createDialog( | ||
InfoDialog, | ||
{ | ||
title, | ||
description, | ||
button: _t('Got it'), | ||
hasCloseButton: true, | ||
}, | ||
); | ||
}; | ||
|
||
return <AccessibleButton | ||
{...rest} | ||
kind='link_inline' | ||
onClick={onClick} | ||
className='mx_LearnMore_button' | ||
> | ||
{ _t('Learn more') } | ||
</AccessibleButton>; | ||
}; | ||
|
||
export default LearnMore; |
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,57 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { fireEvent, render } from '@testing-library/react'; | ||
|
||
import LearnMore from '../../../../src/components/views/elements/LearnMore'; | ||
import Modal from '../../../../src/Modal'; | ||
import InfoDialog from '../../../../src/components/views/dialogs/InfoDialog'; | ||
|
||
describe('<LearnMore />', () => { | ||
const defaultProps = { | ||
title: 'Test', | ||
description: 'test test test', | ||
['data-testid']: 'testid', | ||
}; | ||
const getComponent = (props = {}) => | ||
(<LearnMore {...defaultProps} {...props} />); | ||
|
||
const modalSpy = jest.spyOn(Modal, 'createDialog').mockReturnValue(undefined); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('renders button', () => { | ||
const { container } = render(getComponent()); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('opens modal on click', async () => { | ||
const { getByTestId } = render(getComponent()); | ||
fireEvent.click(getByTestId('testid')); | ||
|
||
expect(modalSpy).toHaveBeenCalledWith( | ||
InfoDialog, | ||
{ | ||
button: 'Got it', | ||
description: defaultProps.description, | ||
hasCloseButton: true, | ||
title: defaultProps.title, | ||
}); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
test/components/views/elements/__snapshots__/LearnMore-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,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<LearnMore /> renders button 1`] = ` | ||
<div> | ||
<div | ||
class="mx_AccessibleButton mx_LearnMore_button mx_AccessibleButton_hasKind mx_AccessibleButton_kind_link_inline" | ||
data-testid="testid" | ||
role="button" | ||
tabindex="0" | ||
> | ||
Learn more | ||
</div> | ||
</div> | ||
`; |
Oops, something went wrong.