Handle Totally Normal™ flags

This commit is contained in:
rschamp 2022-03-11 14:22:43 -05:00
parent 413d3e0f11
commit 930bb78304
4 changed files with 13 additions and 3 deletions

View file

@ -144,6 +144,8 @@ module.exports.selectProjectCommentsGloballyEnabled = state =>
get(state, ['session', 'session', 'flags', 'project_comments_enabled'], false);
module.exports.selectStudioCommentsGloballyEnabled = state =>
get(state, ['session', 'session', 'flags', 'gallery_comments_enabled'], false);
module.exports.selectIsTotallyNormal = state =>
get(state, ['session', 'session', 'flags', 'everything_is_totally_normal'], false);
module.exports.selectMuteStatus = state => get(state, ['session', 'session', 'permissions', 'mute_status'],
{muteExpiresAt: 0, offenses: [], showWarning: false});
module.exports.selectIsMuted = state => (module.exports.selectMuteStatus(state).muteExpiresAt || 0) * 1000 > Date.now();

View file

@ -722,6 +722,7 @@ PreviewPresentation.propTypes = {
favoriteCount: PropTypes.number,
intl: intlShape,
isAdmin: PropTypes.bool,
isTotallyNormal: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types
isFullScreen: PropTypes.bool,
isLoggedIn: PropTypes.bool,
isNewScratcher: PropTypes.bool,

View file

@ -27,7 +27,7 @@ const NotAvailable = require('../../components/not-available/not-available.jsx')
const Meta = require('./meta.jsx');
const sessionActions = require('../../redux/session.js');
import {selectProjectCommentsGloballyEnabled} from '../../redux/session';
import {selectProjectCommentsGloballyEnabled, selectIsTotallyNormal} from '../../redux/session';
const navigationActions = require('../../redux/navigation.js');
const previewActions = require('../../redux/preview.js');
const projectCommentActions = require('../../redux/project-comment-actions.js');
@ -930,6 +930,7 @@ Preview.propTypes = {
handleUpdateProjectThumbnail: PropTypes.func,
isAdmin: PropTypes.bool,
isEditable: PropTypes.bool,
isTotallyNormal: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types
isLoggedIn: PropTypes.bool,
isProjectCommentsGloballyEnabled: PropTypes.bool,
isNewScratcher: PropTypes.bool,
@ -1019,7 +1020,8 @@ const mapStateToProps = state => {
const showEmailConfirmationBanner = state.session.session.flags &&
state.session.session.flags.has_outstanding_email_confirmation &&
state.session.session.flags.confirm_email_banner;
const isTotallyNormal = state.session.session.flags && selectIsTotallyNormal(state);
// if we don't have projectInfo, assume it's shared until we know otherwise
const isShared = !projectInfoPresent || state.preview.projectInfo.is_published;
@ -1046,6 +1048,7 @@ const mapStateToProps = state => {
// project is editable iff logged in user is the author of the project, or
// logged in user is an admin.
isEditable: isEditable,
isTotallyNormal: isTotallyNormal,
isLoggedIn: isLoggedIn,
isAdmin: isAdmin,
isNewScratcher: isLoggedIn && state.permissions.new_scratcher,

View file

@ -15,6 +15,8 @@ const Select = require('../../components/forms/select.jsx');
const TitleBanner = require('../../components/title-banner/title-banner.jsx');
const Tabs = require('../../components/tabs/tabs.jsx');
import {selectIsTotallyNormal} from '../../redux/session';
const Page = require('../../components/page/www/page.jsx');
const render = require('../../lib/render.jsx');
@ -258,11 +260,13 @@ class Search extends React.Component {
Search.propTypes = {
dispatch: PropTypes.func,
intl: intlShape,
isTotallyNormal: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types
searchTerm: PropTypes.string
};
const mapStateToProps = state => ({
searchTerm: state.navigation.searchTerm
searchTerm: state.navigation.searchTerm,
isTotallyNormal: selectIsTotallyNormal(state)
});
const WrappedSearch = injectIntl(Search);