Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #1327

Merged
merged 9 commits into from
Nov 9, 2024
8 changes: 7 additions & 1 deletion app/components/StyledUtils/Title.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from 'styled-components'
import { fontSize, space, style, themeGet } from 'styled-system'
import { fontSize, fontWeight, space, style, themeGet } from 'styled-system'

export const textTransform = style({
prop: 'textTransform',
Expand All @@ -11,6 +11,7 @@ export const StyledH1 = styled.h1`
${fontSize}
${space}
${textTransform}
${fontWeight}
`

export const StyledH2 = styled.h2`
Expand All @@ -19,6 +20,7 @@ export const StyledH2 = styled.h2`
${fontSize}
${space}
${textTransform}
${fontWeight}
`

export const StyledH3 = styled.h3`
Expand All @@ -27,6 +29,7 @@ export const StyledH3 = styled.h3`
${fontSize}
${space}
${textTransform}
${fontWeight}
`

export const StyledH4 = styled.h4`
Expand All @@ -35,6 +38,7 @@ export const StyledH4 = styled.h4`
${fontSize}
${space}
${textTransform}
${fontWeight}
`

export const StyledH5 = styled.h5`
Expand All @@ -43,6 +47,7 @@ export const StyledH5 = styled.h5`
${fontSize}
${space}
${textTransform}
${fontWeight}
`

export const StyledH6 = styled.h6`
Expand All @@ -51,4 +56,5 @@ export const StyledH6 = styled.h6`
${fontSize}
${space}
${textTransform}
${fontWeight}
`
5 changes: 4 additions & 1 deletion app/components/UsersActions/ActionDiff.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ class ActionDiff extends PureComponent {
formatChangeValue(value, key) {
if (key === 'speaker_id' && value) {
return <Link to={speakerURL(value)}>#{value}</Link>
} else if (key === 'is_draft' && !value) {
} else if (['is_draft', 'unlisted'].includes(key) && !value) {
return 'No'
} else if (typeof value === 'boolean') {
return value ? 'Yes' : 'No'
}

return value
}

Expand Down
134 changes: 98 additions & 36 deletions app/components/Videos/EditVideoModal.jsx
Original file line number Diff line number Diff line change
@@ -1,68 +1,130 @@
import { Mutation } from '@apollo/client/react/components'
import { Flex } from '@rebass/grid'
import { Formik } from 'formik'
import gql from 'graphql-tag'
import React from 'react'
import { withNamespaces } from 'react-i18next'
import { connect } from 'react-redux'
import Select from 'react-select'
import { Edit } from 'styled-icons/fa-regular'

import { flashErrorMsg, flashSuccessMsg } from '../../state/flashes/reducer'
import { popModal } from '../../state/modals/reducer'
import { shiftStatements } from '../../state/video_debate/effects'
import FieldWithButton from '../FormUtils/FieldWithButton'
import StyledLabel from '../FormUtils/StyledLabel'
import Modal from '../Modal/Modal'
import { StyledH3 } from '../StyledUtils/Title'

const editVideoMutation = gql`
mutation editVideo($id: ID!, $unlisted: Boolean) {
editVideo(id: $id, unlisted: $unlisted) {
id
unlisted
}
}
`

class EditVideoModal extends React.PureComponent {
renderTitle() {
return (
<span>
<div className="is-flex gap-2">
<Edit size="1em" /> {this.props.t('video.edit')}
</span>
</div>
)
}

render() {
const { t, popModal, video } = this.props
const unlistedOptions = [
{ value: true, label: t('main:videos.unlisted') },
{ value: false, label: t('main:videos.public') },
]

return (
<Modal handleCloseClick={popModal} title={this.renderTitle()}>
<Flex flexDirection="column">
<StyledH3>{t('video.shiftStatements')}</StyledH3>
<Formik
initialValues={{ youtube_offset: video.youtube_offset }}
onSubmit={async (values, { setSubmitting }) => {
setSubmitting(true)
const reply = await this.props.shiftStatements(values)
setSubmitting(false)
this.props.popModal()
return reply
}}
>
{({ handleSubmit, isSubmitting, values, handleChange }) => (
<form onSubmit={handleSubmit}>
<Flex>
<StyledLabel fontSize={3} mr={3}>
Youtube
</StyledLabel>
<FieldWithButton
type="number"
input={{
name: 'youtube_offset',
max: '10000000',
value: values.youtube_offset,
onChange: handleChange,
}}
meta={{ submitting: isSubmitting }}
placeholder="+0s"
buttonLabel={t('main:actions.apply')}
buttonClickHandler={handleSubmit}
/>
</Flex>
</form>
<StyledH3 mb={2} fontSize="15px" fontWeight="700">
Change visibility
</StyledH3>
<Mutation mutation={editVideoMutation}>
{(editVideo) => (
<Formik
initialValues={{ unlisted: video.unlisted }}
enableReinitialize
onSubmit={async (values) => {
try {
await editVideo({
variables: { id: video.id, unlisted: values.unlisted },
})
this.props.flashSuccessMsg('Visibility changed')
window.location.reload()
} catch (e) {
console.error(e) // eslint-disable-line no-console
this.props.flashErrorMsg('Failed to change visibility')
}
}}
>
{({ handleSubmit, isSubmitting, setFieldValue, values }) => (
<form onSubmit={handleSubmit}>
<Select
className="speaker-select"
placeholder="Select visibility"
menuPortalTarget={document.body}
styles={{ menuPortal: (base) => ({ ...base, zIndex: 99999 }) }}
options={unlistedOptions}
value={unlistedOptions.find((option) => option.value === values.unlisted)}
name="unlisted"
isLoading={isSubmitting}
disabled={isSubmitting}
onChange={({ value }) => {
setFieldValue('unlisted', value)
handleSubmit()
}}
/>
</form>
)}
</Formik>
)}
</Formik>
</Mutation>
</Flex>
{video['youtube_id'] && (
<React.Fragment>
<hr />
<Flex flexDirection="column">
<StyledH3 mb={2} fontSize="15px" fontWeight="700">
{t('video.shiftStatements')}
</StyledH3>
<Formik
initialValues={{ youtube_offset: video.youtube_offset }}
onSubmit={async (values, { setSubmitting }) => {
setSubmitting(true)
const reply = await this.props.shiftStatements(values)
setSubmitting(false)
this.props.popModal()
return reply
}}
>
{({ handleSubmit, isSubmitting, values, handleChange }) => (
<form onSubmit={handleSubmit}>
<FieldWithButton
type="number"
input={{
name: 'youtube_offset',
max: '10000000',
value: values.youtube_offset,
onChange: handleChange,
}}
meta={{ submitting: isSubmitting }}
placeholder="+0s"
buttonLabel="Shift"
buttonClickHandler={handleSubmit}
/>
</form>
)}
</Formik>
</Flex>
</React.Fragment>
)}
</Modal>
)
}
Expand Down
4 changes: 2 additions & 2 deletions app/styles/_components/VideoDebate/comments/comment.sass
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
.score
text-align: center
font-size: 0.9em
height: 1.1em
min-height: 1.1em
.round-spinner
animation: spinAround 400ms infinite linear, fadeIn 500ms
margin-left: 3px
Expand Down Expand Up @@ -132,4 +132,4 @@
color: lighten($red, 30)
cursor: help
.fa
font-size: 1.4em !important
font-size: 1.4em !important
Loading
Loading