mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 09:35:56 -05:00
Merge pull request #6734 from LLK/release/2022-04-13
[Develop] release/2022-04-13
This commit is contained in:
commit
e9abb0db4f
2 changed files with 7 additions and 51 deletions
|
@ -8,8 +8,7 @@ import {
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {connect} from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
import {FormattedMessage, injectIntl, intlShape} from 'react-intl';
|
|
||||||
import {isRtl} from 'scratch-l10n';
|
|
||||||
|
|
||||||
import Page from '../../components/page/www/page.jsx';
|
import Page from '../../components/page/www/page.jsx';
|
||||||
import render from '../../lib/render.jsx';
|
import render from '../../lib/render.jsx';
|
||||||
|
@ -35,21 +34,20 @@ import './studio.scss';
|
||||||
import {selectIsAdmin, selectMuteStatus} from '../../redux/session.js';
|
import {selectIsAdmin, selectMuteStatus} from '../../redux/session.js';
|
||||||
import {formatRelativeTime} from '../../lib/format-time.js';
|
import {formatRelativeTime} from '../../lib/format-time.js';
|
||||||
import CommentingStatus from '../../components/commenting-status/commenting-status.jsx';
|
import CommentingStatus from '../../components/commenting-status/commenting-status.jsx';
|
||||||
|
import {FormattedMessage} from 'react-intl';
|
||||||
import {selectShowCuratorMuteError} from '../../redux/studio-permissions.js';
|
import {selectShowCuratorMuteError} from '../../redux/studio-permissions.js';
|
||||||
|
|
||||||
export const StudioShell = ({intl, isAdmin, showCuratorMuteError, muteExpiresAtMs, studioLoadFailed, onLoadInfo}) => {
|
const StudioShell = ({isAdmin, showCuratorMuteError, muteExpiresAtMs, studioLoadFailed, onLoadInfo}) => {
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onLoadInfo();
|
onLoadInfo();
|
||||||
}, [isAdmin]); // Reload any time isAdmin changes to allow admins to view deleted studios
|
}, [isAdmin]); // Reload any time isAdmin changes to allow admins to view deleted studios
|
||||||
|
|
||||||
return (
|
return (
|
||||||
studioLoadFailed ?
|
studioLoadFailed ?
|
||||||
<NotAvailable /> :
|
<NotAvailable /> :
|
||||||
<div
|
<div className="studio-shell">
|
||||||
className="studio-shell"
|
|
||||||
dir={isRtl(intl.locale) ? 'rtl' : null}
|
|
||||||
>
|
|
||||||
<StudioDeleted />
|
<StudioDeleted />
|
||||||
<StudioMeta />
|
<StudioMeta />
|
||||||
<div className="studio-info">
|
<div className="studio-info">
|
||||||
|
@ -100,7 +98,6 @@ export const StudioShell = ({intl, isAdmin, showCuratorMuteError, muteExpiresAtM
|
||||||
};
|
};
|
||||||
|
|
||||||
StudioShell.propTypes = {
|
StudioShell.propTypes = {
|
||||||
intl: intlShape,
|
|
||||||
isAdmin: PropTypes.bool,
|
isAdmin: PropTypes.bool,
|
||||||
showCuratorMuteError: PropTypes.bool,
|
showCuratorMuteError: PropTypes.bool,
|
||||||
muteExpiresAtMs: PropTypes.number,
|
muteExpiresAtMs: PropTypes.number,
|
||||||
|
@ -120,8 +117,6 @@ const ConnectedStudioShell = connect(
|
||||||
}
|
}
|
||||||
)(StudioShell);
|
)(StudioShell);
|
||||||
|
|
||||||
const IntlConnectedStudioShell = injectIntl(ConnectedStudioShell);
|
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<Page className="studio-page">
|
<Page className="studio-page">
|
||||||
<StudioAdminPanel />
|
<StudioAdminPanel />
|
||||||
|
@ -129,7 +124,7 @@ render(
|
||||||
<Switch>
|
<Switch>
|
||||||
{/* Use variable studioPath to support /studio-playground/ or future route */}
|
{/* Use variable studioPath to support /studio-playground/ or future route */}
|
||||||
<Route path="/:studioPath/:studioId">
|
<Route path="/:studioPath/:studioId">
|
||||||
<IntlConnectedStudioShell />
|
<ConnectedStudioShell />
|
||||||
</Route>
|
</Route>
|
||||||
</Switch>
|
</Switch>
|
||||||
</Router>
|
</Router>
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
const React = require('react');
|
|
||||||
const {shallow} = require('enzyme');
|
|
||||||
import {StudioShell} from '../../../src/views/studio/studio.jsx';
|
|
||||||
|
|
||||||
jest.mock('react-dom', () => ({
|
|
||||||
render: jest.fn()
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock('react-router-dom', () => ({
|
|
||||||
useRouteMatch: jest.fn(() => ({path: ''}))
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('Studio', () => {
|
|
||||||
test('dir is RTL when locale is rtl', () => {
|
|
||||||
const component = shallow(
|
|
||||||
<StudioShell
|
|
||||||
intl={{
|
|
||||||
locale: 'ar'
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
const studioShell = component.find('div.studio-shell');
|
|
||||||
expect(studioShell.prop('dir')).toEqual('rtl');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('dir is LTR when locale is ltr', () => {
|
|
||||||
const component = shallow(
|
|
||||||
<StudioShell
|
|
||||||
intl={{
|
|
||||||
locale: 'ja'
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
const studioShell = component.find('div.studio-shell');
|
|
||||||
expect(studioShell.prop('dir')).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in a new issue