This repository was archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 819
Device manager - add learn more popups to filtered sessions section #9497
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
077d68e
add learn more to filtered sessions
3f6fc84
fullstop
0e81abf
update tests and i18n for fullstop
cff4553
remove unused switch
f64e707
whitespace
656745d
use correct card type
84e2a63
Merge branch 'develop' into psg-863/dm-learn-more
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.