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 833
Add simple live share warning #8066
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0d64066
add simple live share warning
b08bbc8
rough first cut of OwnBeaconStore
ad80df7
working (?) has live beacons status
6458906
lint
1988067
add left panel share warning
9c8c9cc
setup for tests
979f91e
test ownbeaconstore
93900a0
add copyright
7bc55b4
add copyright
4529813
remove warning banner
bb5a5cb
fix test
cd224b5
fix tests for weird asyncstore closure issues
b27b2c9
fix OwnBeaconStore more...
20c5ed9
revert loose change to LeftPanel
80839b2
Revert "remove warning banner"
3a6530d
test live share warning
5fdfb11
Merge branch 'develop' into psf-662/live-share-banner
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 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
31 changes: 31 additions & 0 deletions
31
res/css/components/views/beacon/_LeftPanelLiveShareWarning.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,31 @@ | ||
/* | ||
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_LeftPanelLiveShareWarning { | ||
width: 100%; | ||
box-sizing: border-box; | ||
|
||
padding: $spacing-4; | ||
text-align: center; | ||
|
||
background-color: $accent; | ||
color: #fff; | ||
font-size: $font-10px; | ||
|
||
// panel backdrops overlay the whole sidepanel | ||
// go above to get hover for title | ||
z-index: 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
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 |
---|---|---|
|
@@ -75,6 +75,7 @@ import RightPanelStore from '../../stores/right-panel/RightPanelStore'; | |
import { TimelineRenderingType } from "../../contexts/RoomContext"; | ||
import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts"; | ||
import { SwitchSpacePayload } from "../../dispatcher/payloads/SwitchSpacePayload"; | ||
import LeftPanelLiveShareWarning from '../views/beacon/LeftPanelLiveShareWarning'; | ||
|
||
// We need to fetch each pinned message individually (if we don't already have it) | ||
// so each pinned message may trigger a request. Limit the number per room for sanity. | ||
|
@@ -694,8 +695,10 @@ class LoggedInView extends React.Component<IProps, IState> { | |
> | ||
<ToastContainer /> | ||
<div className={bodyClasses}> | ||
<div className='mx_LeftPanel_wrapper'> | ||
{ SettingsStore.getValue('TagPanel.enableTagPanel') && | ||
<div className='mx_LeftPanel_outerWrapper'> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the past we've had performance issues with adding layers to the left panel like this, but it's entirely possible that they have been fixed over the years. Would recommend watching for left panel-related performance complaints post-merge, particularly for large accounts and Chrome users. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. surprisingly, it wasn't a performance issue but rather a scrolling issue this time 😭 #8109 |
||
<LeftPanelLiveShareWarning isMinimized={this.props.collapseLhs || false} /> | ||
<div className='mx_LeftPanel_wrapper'> | ||
{ SettingsStore.getValue('TagPanel.enableTagPanel') && | ||
(<div className="mx_GroupFilterPanelContainer"> | ||
<BackdropPanel | ||
blurMultiplier={0.5} | ||
|
@@ -704,26 +707,27 @@ class LoggedInView extends React.Component<IProps, IState> { | |
<GroupFilterPanel /> | ||
{ SettingsStore.getValue("feature_custom_tags") ? <CustomRoomTagPanel /> : null } | ||
</div>) | ||
} | ||
{ SpaceStore.spacesEnabled ? <> | ||
} | ||
{ SpaceStore.spacesEnabled ? <> | ||
<BackdropPanel | ||
blurMultiplier={0.5} | ||
backgroundImage={this.state.backgroundImage} | ||
/> | ||
<SpacePanel /> | ||
</> : null } | ||
<BackdropPanel | ||
blurMultiplier={0.5} | ||
backgroundImage={this.state.backgroundImage} | ||
/> | ||
<SpacePanel /> | ||
</> : null } | ||
<BackdropPanel | ||
backgroundImage={this.state.backgroundImage} | ||
/> | ||
<div | ||
className="mx_LeftPanel_wrapper--user" | ||
ref={this._resizeContainer} | ||
data-collapsed={this.props.collapseLhs ? true : undefined} | ||
> | ||
<LeftPanel | ||
isMinimized={this.props.collapseLhs || false} | ||
resizeNotifier={this.props.resizeNotifier} | ||
/> | ||
<div | ||
className="mx_LeftPanel_wrapper--user" | ||
ref={this._resizeContainer} | ||
data-collapsed={this.props.collapseLhs ? true : undefined} | ||
> | ||
<LeftPanel | ||
isMinimized={this.props.collapseLhs || false} | ||
resizeNotifier={this.props.resizeNotifier} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
<ResizeHandle passRef={this.resizeHandler} id="lp-resizer" /> | ||
|
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,50 @@ | ||
/* | ||
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 classNames from 'classnames'; | ||
import React from 'react'; | ||
|
||
import { useEventEmitterState } from '../../../hooks/useEventEmitter'; | ||
import { _t } from '../../../languageHandler'; | ||
import { OwnBeaconStore, OwnBeaconStoreEvent } from '../../../stores/OwnBeaconStore'; | ||
import { Icon as LiveLocationIcon } from '../../../../res/img/location/live-location.svg'; | ||
|
||
interface Props { | ||
isMinimized?: boolean; | ||
} | ||
|
||
const LeftPanelLiveShareWarning: React.FC<Props> = ({ isMinimized }) => { | ||
const hasLiveBeacons = useEventEmitterState( | ||
OwnBeaconStore.instance, | ||
OwnBeaconStoreEvent.LivenessChange, | ||
() => OwnBeaconStore.instance.hasLiveBeacons(), | ||
); | ||
|
||
if (!hasLiveBeacons) { | ||
return null; | ||
} | ||
|
||
return <div | ||
className={classNames('mx_LeftPanelLiveShareWarning', { | ||
'mx_LeftPanelLiveShareWarning__minimized': isMinimized, | ||
})} | ||
title={isMinimized ? _t('You are sharing your live location') : undefined} | ||
> | ||
{ isMinimized ? <LiveLocationIcon height={10} /> : _t('You are sharing your live location') } | ||
</div>; | ||
}; | ||
|
||
export default LeftPanelLiveShareWarning; |
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
test/components/views/beacon/LeftPanelLiveShareWarning-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,80 @@ | ||
/* | ||
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 { mocked } from 'jest-mock'; | ||
import { mount } from 'enzyme'; | ||
|
||
import '../../../skinned-sdk'; | ||
import LeftPanelLiveShareWarning from '../../../../src/components/views/beacon/LeftPanelLiveShareWarning'; | ||
import { OwnBeaconStore, OwnBeaconStoreEvent } from '../../../../src/stores/OwnBeaconStore'; | ||
import { flushPromises } from '../../../test-utils'; | ||
|
||
jest.mock('../../../../src/stores/OwnBeaconStore', () => { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const EventEmitter = require("events"); | ||
class MockOwnBeaconStore extends EventEmitter { | ||
public hasLiveBeacons = jest.fn().mockReturnValue(false); | ||
} | ||
return { | ||
// @ts-ignore | ||
...jest.requireActual('../../../../src/stores/OwnBeaconStore'), | ||
OwnBeaconStore: { | ||
instance: new MockOwnBeaconStore() as unknown as OwnBeaconStore, | ||
}, | ||
}; | ||
}, | ||
); | ||
|
||
describe('<LeftPanelLiveShareWarning />', () => { | ||
const defaultProps = {}; | ||
const getComponent = (props = {}) => | ||
mount(<LeftPanelLiveShareWarning {...defaultProps} {...props} />); | ||
|
||
it('renders nothing when user has no live beacons', () => { | ||
const component = getComponent(); | ||
expect(component.html()).toBe(null); | ||
}); | ||
|
||
describe('when user has live beacons', () => { | ||
beforeEach(() => { | ||
mocked(OwnBeaconStore.instance).hasLiveBeacons.mockReturnValue(true); | ||
}); | ||
it('renders correctly when not minimized', () => { | ||
const component = getComponent(); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders correctly when minimized', () => { | ||
const component = getComponent({ isMinimized: true }); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it('removes itself when user stops having live beacons', async () => { | ||
const component = getComponent({ isMinimized: true }); | ||
// started out rendered | ||
expect(component.html()).toBeTruthy(); | ||
|
||
mocked(OwnBeaconStore.instance).hasLiveBeacons.mockReturnValue(false); | ||
OwnBeaconStore.instance.emit(OwnBeaconStoreEvent.LivenessChange, false); | ||
|
||
await flushPromises(); | ||
component.setProps({}); | ||
|
||
expect(component.html()).toBe(null); | ||
}); | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
test/components/views/beacon/__snapshots__/LeftPanelLiveShareWarning-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,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<LeftPanelLiveShareWarning /> when user has live beacons renders correctly when minimized 1`] = ` | ||
<LeftPanelLiveShareWarning | ||
isMinimized={true} | ||
> | ||
<div | ||
className="mx_LeftPanelLiveShareWarning mx_LeftPanelLiveShareWarning__minimized" | ||
title="You are sharing your live location" | ||
> | ||
<div | ||
height={10} | ||
/> | ||
</div> | ||
</LeftPanelLiveShareWarning> | ||
`; | ||
|
||
exports[`<LeftPanelLiveShareWarning /> when user has live beacons renders correctly when not minimized 1`] = ` | ||
<LeftPanelLiveShareWarning> | ||
<div | ||
className="mx_LeftPanelLiveShareWarning" | ||
> | ||
You are sharing your live location | ||
</div> | ||
</LeftPanelLiveShareWarning> | ||
`; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird diff, change is adding this extra wrapper
mx_LeftPanel_outerWrapper
andLeftPanelLiveShareWarning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the block for
mx_GroupFilterPanelContainer
didn't get indented, which confused the diff a bit. Not that diffs to jsx are ever clear... 😅