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

Sentry MATECAT-3XX #3708

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ export const SourceLanguageSelect = ({
isRenderedInsideTab = false,
dropdownClassName,
}) => {
const {SELECT_HEIGHT, languages, sourceLang, changeSourceLanguage} =
useContext(CreateProjectContext)
const {
SELECT_HEIGHT,
languages,
sourceLang,
changeSourceLanguage,
projectTemplates,
} = useContext(CreateProjectContext)
const {isUserLogged} = useContext(ApplicationWrapperContext)

return (
Expand All @@ -22,10 +27,10 @@ export const SourceLanguageSelect = ({
maxHeightDroplist={SELECT_HEIGHT}
showSearchBar={true}
options={languages}
activeOption={sourceLang}
activeOption={Object.keys(sourceLang).length ? sourceLang : undefined}
checkSpaceToReverse={isRenderedInsideTab}
onSelect={(option) => changeSourceLanguage(option)}
isDisabled={!isUserLogged}
isDisabled={!isUserLogged || !projectTemplates.length}
>
{({name, code}) => ({
row: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,29 @@ import ChevronDown from '../../../../../img/icons/ChevronDown'
import {useRef} from 'react'

export const TargetLanguagesSelect = () => {
const {targetLangs, setIsOpenMultiselectLanguages, languages} =
useContext(CreateProjectContext)
const {
targetLangs,
setIsOpenMultiselectLanguages,
languages,
projectTemplates,
} = useContext(CreateProjectContext)
const selectedItemRef = useRef()

const getActiveLabel = () => targetLangs.map(({name}) => name).join(',')
const openModal = () =>
languages?.length > 0 && setIsOpenMultiselectLanguages(true)

return (
return projectTemplates.length > 0 ? (
<div
className="select-with-label__wrapper "
id="target-lang"
onClick={openModal}
>
<label>To</label>
<div className="select-with-icon__wrapper" aria-label={getActiveLabel()}>
<div
className="select-with-icon__wrapper"
{...(targetLangs.length > 1 && {'aria-label': getActiveLabel()})}
>
<span ref={selectedItemRef} className="select select--is-multiple">
{targetLangs.length > 1
? `${targetLangs.length} languages`
Expand All @@ -34,5 +41,14 @@ export const TargetLanguagesSelect = () => {
<ChevronDown />
</div>
</div>
) : (
<div className="select-with-label__wrapper">
<label>To</label>
<div className="select-with-icon__wrapper">
<span className="select select--is-disabled"></span>
<input readOnly={true} type="text" className="input--invisible" />
<ChevronDown />
</div>
</div>
)
}
15 changes: 8 additions & 7 deletions public/js/cat_source/es6/pages/NewProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@ const NewProject = () => {
const closeSettings = useCallback(() => setOpenSettings({isOpen: false}), [])

const selectedTeam = useMemo(() => {
const team =
userInfo?.teams?.find(({id}) => id === currentProjectTemplate?.idTeam) ??
{}
const team = userInfo?.teams?.find(
({id}) => id === currentProjectTemplate?.idTeam,
)

return {...team, id: team.id?.toString()}
return team && {...team, id: team.id?.toString()}
}, [userInfo?.teams, currentProjectTemplate?.idTeam])
const setSelectedTeam = useCallback(
({id}) =>
Expand Down Expand Up @@ -823,7 +823,7 @@ const NewProject = () => {
isDisabled={
!isUserLogged ||
userInfo?.teams.length === 1 ||
!projectTemplates.length
isLoadingTemplates
}
onSelect={(option) => setSelectedTeam(option)}
/>
Expand All @@ -835,7 +835,8 @@ const NewProject = () => {
<a
id="swaplang"
title="Swap languages"
{...(isUserLogged && {onClick: swapLanguages})}
{...(isUserLogged &&
!isLoadingTemplates && {onClick: swapLanguages})}
>
<span>Swap languages</span>
</a>
Expand All @@ -855,7 +856,7 @@ const NewProject = () => {
activeOption={subject}
checkSpaceToReverse={false}
onSelect={(option) => setSubject(option)}
isDisabled={!isUserLogged}
isDisabled={!isUserLogged || isLoadingTemplates}
/>
</div>
{/*TM and glossary*/}
Expand Down