feat: remove replace video button for libs (#390)

This commit is contained in:
Kristin Aoki
2023-09-13 13:35:42 -04:00
committed by GitHub
parent 39aa5aa749
commit 126e662d80
5 changed files with 36 additions and 16 deletions

View File

@@ -41,7 +41,9 @@ exports[`VideoEditor snapshots renders as expected with default behavior 2`] = `
<div
className="video-editor"
>
<VideoEditorModal />
<VideoEditorModal
isLibrary={false}
/>
</div>
</EditorContainer>
</Component>

View File

@@ -30,6 +30,7 @@ export const hooks = {
const VideoEditorModal = ({
close,
isOpen,
isLibrary,
}) => {
const dispatch = useDispatch();
const searchParams = new URLSearchParams(document.location.search);
@@ -42,6 +43,7 @@ const VideoEditorModal = ({
close,
isOpen,
onReturn,
isLibrary,
}}
/>
);
@@ -53,5 +55,6 @@ VideoEditorModal.defaultProps = {
VideoEditorModal.propTypes = {
close: PropTypes.func.isRequired,
isOpen: PropTypes.bool.isRequired,
isLibrary: PropTypes.bool.isRequired,
};
export default VideoEditorModal;

View File

@@ -21,21 +21,24 @@ import messages from '../../messages';
export const VideoSettingsModal = ({
onReturn,
isLibrary,
}) => (
<>
<Button
variant="link"
className="text-primary-500"
size="sm"
onClick={onReturn}
style={{
textDecoration: 'none',
marginLeft: '3px',
}}
>
<Icon src={ArrowBackIos} style={{ height: '13px' }} />
<FormattedMessage {...messages.replaceVideoButtonLabel} />
</Button>
{!isLibrary && (
<Button
variant="link"
className="text-primary-500"
size="sm"
onClick={onReturn}
style={{
textDecoration: 'none',
marginLeft: '3px',
}}
>
<Icon src={ArrowBackIos} style={{ height: '13px' }} />
<FormattedMessage {...messages.replaceVideoButtonLabel} />
</Button>
)}
<ErrorSummary />
<VideoPreviewWidget />
<VideoSourceWidget />
@@ -49,8 +52,8 @@ export const VideoSettingsModal = ({
);
VideoSettingsModal.propTypes = {
showReturn: PropTypes.bool.isRequired,
onReturn: PropTypes.func.isRequired,
isLibrary: PropTypes.func.isRequired,
};
export default VideoSettingsModal;

View File

@@ -22,6 +22,7 @@ export const VideoEditor = ({
intl,
// redux
studioViewFinished,
isLibrary,
}) => {
const {
error,
@@ -37,7 +38,7 @@ export const VideoEditor = ({
>
{studioViewFinished ? (
<div className="video-editor">
<VideoEditorModal />
<VideoEditorModal {...{ isLibrary }} />
</div>
) : (
<div style={{
@@ -70,10 +71,12 @@ VideoEditor.propTypes = {
intl: intlShape.isRequired,
// redux
studioViewFinished: PropTypes.bool.isRequired,
isLibrary: PropTypes.bool.isRequired,
};
export const mapStateToProps = (state) => ({
studioViewFinished: selectors.requests.isFinished(state, { requestKey: RequestKeys.fetchStudioView }),
isLibrary: selectors.app.isLibrary(state),
});
export const mapDispatchToProps = {};

View File

@@ -23,6 +23,9 @@ jest.mock('../../data/redux', () => ({
requests: {
isFinished: jest.fn((state, params) => ({ isFailed: { state, params } })),
},
app: {
isLibrary: jest.fn(state => ({ isLibrary: state })),
},
},
}));
@@ -31,6 +34,7 @@ describe('VideoEditor', () => {
onClose: jest.fn().mockName('props.onClose'),
intl: { formatMessage },
studioViewFinished: false,
isLibrary: false,
};
describe('snapshots', () => {
test('renders as expected with default behavior', () => {
@@ -47,6 +51,11 @@ describe('VideoEditor', () => {
mapStateToProps(testState).studioViewFinished,
).toEqual(selectors.requests.isFinished(testState, { requestKey: RequestKeys.fetchStudioView }));
});
test('isLibrary from app.isLibrary', () => {
expect(
mapStateToProps(testState).isLibrary,
).toEqual(selectors.app.isLibrary(testState));
});
});
describe('mapDispatchToProps', () => {
test('is empty', () => {