Skip to content

Commit

Permalink
feat: remove replace video button for libs (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored Sep 13, 2023
1 parent 39aa5aa commit 126e662
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const hooks = {
const VideoEditorModal = ({
close,
isOpen,
isLibrary,
}) => {
const dispatch = useDispatch();
const searchParams = new URLSearchParams(document.location.search);
Expand All @@ -42,6 +43,7 @@ const VideoEditorModal = ({
close,
isOpen,
onReturn,
isLibrary,
}}
/>
);
Expand All @@ -53,5 +55,6 @@ VideoEditorModal.defaultProps = {
VideoEditorModal.propTypes = {
close: PropTypes.func.isRequired,
isOpen: PropTypes.bool.isRequired,
isLibrary: PropTypes.bool.isRequired,
};
export default VideoEditorModal;
Original file line number Diff line number Diff line change
Expand Up @@ -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 />
Expand All @@ -49,8 +52,8 @@ export const VideoSettingsModal = ({
);

VideoSettingsModal.propTypes = {
showReturn: PropTypes.bool.isRequired,
onReturn: PropTypes.func.isRequired,
isLibrary: PropTypes.func.isRequired,
};

export default VideoSettingsModal;
5 changes: 4 additions & 1 deletion src/editors/containers/VideoEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const VideoEditor = ({
intl,
// redux
studioViewFinished,
isLibrary,
}) => {
const {
error,
Expand All @@ -37,7 +38,7 @@ export const VideoEditor = ({
>
{studioViewFinished ? (
<div className="video-editor">
<VideoEditorModal />
<VideoEditorModal {...{ isLibrary }} />
</div>
) : (
<div style={{
Expand Down Expand Up @@ -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 = {};
Expand Down
9 changes: 9 additions & 0 deletions src/editors/containers/VideoEditor/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jest.mock('../../data/redux', () => ({
requests: {
isFinished: jest.fn((state, params) => ({ isFailed: { state, params } })),
},
app: {
isLibrary: jest.fn(state => ({ isLibrary: state })),
},
},
}));

Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand Down

0 comments on commit 126e662

Please sign in to comment.