Skip to content

Commit

Permalink
fix: stuff forgotten in rebase + update enterprise plan (#2774)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 authored Dec 12, 2024
1 parent 789a676 commit c5b2854
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 186 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.tolgee.hateoas.task

import io.tolgee.hateoas.TranslationAgencySimpleModel
import io.tolgee.hateoas.language.LanguageModel
import io.tolgee.hateoas.project.SimpleProjectModel
import io.tolgee.hateoas.userAccount.SimpleUserAccountModel
Expand All @@ -26,4 +27,5 @@ data class TaskWithProjectModel(
var closedAt: Long? = null,
var state: TaskState = TaskState.IN_PROGRESS,
var project: SimpleProjectModel,
var agency: TranslationAgencySimpleModel? = null,
) : RepresentationModel<TaskWithProjectModel>()
16 changes: 0 additions & 16 deletions e2e/cypress/e2e/tasks/projectTasks.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ describe('project tasks', () => {
cy.gcy('tasks-header-add-task').click();
cy.gcy('create-task-field-languages').click();
cy.gcy('create-task-field-languages-item').contains('Czech').click();
cy.gcy('create-task-field-languages-item').contains('English').click();
dismissMenu();
cy.waitForDom();

Expand All @@ -125,13 +124,6 @@ describe('project tasks', () => {
words: 8,
characters: 52,
});
checkTaskPreview({
language: 'English',
keys: 2,
alert: true,
words: 4,
characters: 26,
});
});

it('task create displays correct numbers for review task', () => {
Expand Down Expand Up @@ -164,7 +156,6 @@ describe('project tasks', () => {
cy.gcy('tasks-header-add-task').click();
cy.gcy('create-task-field-languages').click();
cy.gcy('create-task-field-languages-item').contains('Czech').click();
cy.gcy('create-task-field-languages-item').contains('English').click();
dismissMenu();

cy.gcy('translations-state-filter').click();
Expand All @@ -179,12 +170,5 @@ describe('project tasks', () => {
words: 4,
characters: 26,
});
checkTaskPreview({
language: 'English',
keys: 0,
alert: false,
words: 0,
characters: 0,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.tolgee.ee.api.v2.hateoas.assemblers

import io.tolgee.dtos.cacheable.LanguageDto
import io.tolgee.ee.api.v2.controllers.TaskController
import io.tolgee.hateoas.TranslationAgencySimpleModelAssembler
import io.tolgee.hateoas.language.LanguageModelAssembler
import io.tolgee.hateoas.project.SimpleProjectModelAssembler
import io.tolgee.hateoas.task.TaskWithProjectModel
Expand All @@ -15,6 +16,7 @@ class TaskWithProjectModelAssembler(
private val simpleUserAccountModelAssembler: SimpleUserAccountModelAssembler,
private val languageModelAssembler: LanguageModelAssembler,
private val simpleProjectModelAssembler: SimpleProjectModelAssembler,
private val translationAgencySimpleModelAssembler: TranslationAgencySimpleModelAssembler,
) : RepresentationModelAssemblerSupport<TaskWithScopeView, TaskWithProjectModel>(
TaskController::class.java,
TaskWithProjectModel::class.java,
Expand Down Expand Up @@ -45,6 +47,7 @@ class TaskWithProjectModelAssembler(
baseCharacterCount = entity.baseCharacterCount,
state = entity.state,
project = entity.project.let { simpleProjectModelAssembler.toModel(it) },
agency = entity.agency?.let { translationAgencySimpleModelAssembler.toModel(it) },
)
}
}
3 changes: 2 additions & 1 deletion webapp/src/ee/billing/Subscriptions/cloud/PlansCloudList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ export const PlansCloudList: React.FC<BillingPlansProps> = ({
'STANDARD_SUPPORT',
'WEBHOOKS',
'TASKS',
'ORDER_TRANSLATION',
'SSO',
],
] as const satisfies PlanType['enabledFeatures'],
free: false,
hasYearlyPrice: false,
public: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export const PlansSelfHostedList: React.FC<BillingPlansProps> = ({
'STANDARD_SUPPORT',
'WEBHOOKS',
'TASKS',
],
'ORDER_TRANSLATION',
'SSO',
] as const satisfies PlanType['enabledFeatures'],
free: false,
hasYearlyPrice: false,
public: true,
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/ee/task/components/TaskLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FlagImage } from 'tg.component/languages/FlagImage';
import { components } from 'tg.service/apiSchema.generated';
import { TaskNumber, TaskNumberWithLink } from './TaskId';
import { TaskTypeChip } from 'tg.component/task/TaskTypeChip';
import { AgencyLabel } from 'tg.ee';

type TaskModel = components['schemas']['TaskModel'];
type SimpleProjectModel = components['schemas']['SimpleProjectModel'];
Expand Down Expand Up @@ -58,6 +59,7 @@ export const TaskLabel = ({
<TaskNumber taskNumber={task.number} />
)}
{!hideType && <TaskTypeChip type={task.type} />}
{task.agency && <AgencyLabel agency={task.agency} />}
</StyledContainer>
);
};
177 changes: 16 additions & 161 deletions webapp/src/ee/task/components/taskCreate/TaskCreateDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import {
Box,
Button,
Checkbox,
Dialog,
DialogTitle,
ListItemText,
MenuItem,
styled,
Typography,
} from '@mui/material';
import { Button, Dialog, DialogTitle, styled } from '@mui/material';
import { T, useTranslate } from '@tolgee/react';
import { Formik } from 'formik';
import { useState } from 'react';
Expand All @@ -17,28 +7,19 @@ import { Validation } from 'tg.constants/GlobalValidationSchema';
import { components } from 'tg.service/apiSchema.generated';
import { useApiMutation, useApiQuery } from 'tg.service/http/useQueryApi';
import { messageService } from 'tg.service/MessageService';
import { useTaskTypeTranslation } from 'tg.translationTools/useTaskTranslation';
import LoadingButton from 'tg.component/common/form/LoadingButton';
import { Select as FormSelect } from 'tg.component/common/form/fields/Select';
import { TextField } from 'tg.component/common/form/fields/TextField';
import { FiltersType } from 'tg.component/translation/translationFilters/tools';
import { TranslationFilters } from 'tg.component/translation/translationFilters/TranslationFilters';
import { Select } from 'tg.component/common/Select';
import { User } from 'tg.component/UserAccount';

import { TaskDatePicker } from '../TaskDatePicker';
import { TaskPreview } from './TaskPreview';
import { TranslationStateFilter } from './TranslationStateFilter';
import { TranslationStateType } from 'tg.translationTools/useStateTranslation';
import { StateType } from 'tg.constants/translationStates';
import { useEnabledFeatures } from 'tg.globalContext/helpers';
import { DisabledFeatureBanner } from 'tg.component/common/DisabledFeatureBanner';

import { TaskCreateForm } from './TaskCreateForm';

type TaskType = components['schemas']['TaskModel']['type'];
type LanguageModel = components['schemas']['LanguageModel'];

const TASK_TYPES: TaskType[] = ['TRANSLATE', 'REVIEW'];

const StyledMainTitle = styled(DialogTitle)`
padding-bottom: 0px;
`;
Expand All @@ -56,26 +37,6 @@ const StyledContainer = styled('div')`
width: min(calc(100vw - 64px), 800px);
`;

const StyledTopPart = styled(Box)`
display: grid;
gap: ${({ theme }) => theme.spacing(0.5, 2)};
grid-template-columns: 3fr 5fr;
align-items: start;
${({ theme }) => theme.breakpoints.down('sm')} {
grid-template-columns: 1fr;
}
`;

const StyledFilters = styled(Box)`
display: grid;
gap: ${({ theme }) => theme.spacing(0.5, 2)};
grid-template-columns: 3fr 3fr 2fr;
${({ theme }) => theme.breakpoints.down('sm')} {
grid-template-columns: 1fr;
gap: ${({ theme }) => theme.spacing(2)};
}
`;

const StyledActions = styled('div')`
display: flex;
gap: 8px;
Expand Down Expand Up @@ -112,7 +73,6 @@ export const TaskCreateDialog = ({
}: Props) => {
const { t } = useTranslate();

const translateTaskType = useTaskTypeTranslation();
const { isEnabled } = useEnabledFeatures();
const taskFeature = isEnabled('TASKS');

Expand Down Expand Up @@ -203,130 +163,25 @@ export const TaskCreateDialog = ({
);
}}
>
{({ values, setFieldValue, submitForm }) => {
{({ submitForm }) => {
return (
<StyledContainer>
<StyledTopPart>
<FormSelect
label={t('create_task_field_type')}
name="type"
size="small"
renderValue={(v) => translateTaskType(v)}
fullWidth
data-cy="create-task-field-type"
>
{TASK_TYPES.map((v) => (
<MenuItem
key={v}
value={v}
data-cy="create-task-field-type-item"
>
{translateTaskType(v)}
</MenuItem>
))}
</FormSelect>
<TextField
name="name"
label={t('create_task_field_name')}
data-cy="create-task-field-name"
fullWidth
/>
<Select
label={t('create_task_field_languages')}
data-cy="create-task-field-languages"
value={languages}
onChange={(e) => setLanguages(e.target.value as number[])}
size="small"
fullWidth
multiple
style={{ display: 'grid' }}
renderValue={
((langIds: number[]) =>
langIds
.map(
(id) => allLanguages?.find((l) => l.id === id)?.name
)
.join(', ') ?? '') as any
}
>
{allLanguages?.map((lang) => (
<MenuItem
key={lang.id}
value={lang.id}
dense
data-cy="create-task-field-languages-item"
>
<Checkbox
sx={{ marginLeft: -0.75 }}
checked={languages.includes(lang.id)}
size="small"
/>
<ListItemText primary={lang.name} />
</MenuItem>
))}
</Select>
<TaskDatePicker
label={t('create_task_field_due_date')}
value={values.dueDate ?? null}
onChange={(value) => setFieldValue('dueDate', value)}
/>
</StyledTopPart>
<TextField
label={t('create_task_field_description')}
data-cy="create-task-field-description"
name="description"
multiline
minRows={3}
<TaskCreateForm
selectedKeys={selectedKeys}
languages={languages}
allLanguages={allLanguages}
disabled={!taskFeature}
setLanguages={setLanguages}
filters={filters}
setFilters={initialValues?.selection ? undefined : setFilters}
stateFilters={stateFilters}
setStateFilters={setStateFilters}
projectId={projectId}
/>

<Typography variant="subtitle2" mt={2}>
{t('create_task_tasks_and_assignees_title')}
</Typography>
<StyledFilters my={1}>
{!initialValues?.selection && (
<TranslationFilters
value={filters}
onChange={setFilters}
selectedLanguages={allLanguages.filter((l) =>
languages.includes(l.id)
)}
placeholder={t('create_task_filter_keys_placeholder')}
filterOptions={{ keyRelatedOnly: true }}
sx={{ width: '100%', maxWidth: '270px' }}
/>
)}
<TranslationStateFilter
value={stateFilters}
placeholder={t(
'create_task_filter_translation_states_placeholder'
)}
onChange={setStateFilters}
sx={{ maxWidth: '270px' }}
/>
</StyledFilters>

{allLanguages && (
<Box display="grid" gap={2} mt={1}>
{languages?.map((language) => (
<TaskPreview
key={language}
language={allLanguages.find((l) => l.id === language)!}
type={values.type}
keys={selectedKeys}
assigness={values.assignees[language] ?? []}
onUpdateAssignees={(users) => {
setFieldValue(`assignees[${language}]`, users);
}}
filters={stateFilters}
projectId={projectId}
/>
))}
</Box>
)}
<StyledActions>
<Button onClick={onClose}>{t('global_cancel_button')}</Button>
<LoadingButton
disabled={!languages.length}
disabled={!languages.length || !taskFeature}
onClick={submitForm}
color="primary"
variant="contained"
Expand Down
3 changes: 1 addition & 2 deletions webapp/src/ee/task/components/taskFilter/TaskFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ export const TaskFilter = ({
size: 1000,
},
options: {
enabled:
!project && Boolean(value.agencies?.length) && config.billing.enabled,
enabled: Boolean(value.agencies?.length) && config.billing.enabled,
keepPreviousData: true,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { SubfilterAssignees } from './SubfilterAssignees';
import { SubfilterLanguages } from './SubfilterLanguages';
import { SubfilterProjects } from './SubfilterProjects';
import { SubfilterAgencies } from './SubfilterAgencies';
import { useConfig, useEnabledFeatures } from 'tg.globalContext/helpers';
import { useConfig } from 'tg.globalContext/helpers';

type SimpleProjectModel = components['schemas']['SimpleProjectModel'];
type TaskType = components['schemas']['TaskModel']['type'];
Expand Down Expand Up @@ -59,10 +59,8 @@ export const TaskFilterPopover: React.FC<Props> = ({
const debouncedOnChange = useDebouncedCallback(onChange, 200);

const config = useConfig();
const { isEnabled } = useEnabledFeatures();

const agencyVisible =
config.billing.enabled && isEnabled('ORDER_TRANSLATION');
const agencyVisible = config.billing.enabled;

function handleChange(value: TaskFilterType) {
setValue(value);
Expand Down Expand Up @@ -115,7 +113,7 @@ export const TaskFilterPopover: React.FC<Props> = ({
/>
)}

{project && agencyVisible && (
{agencyVisible && (
<SubfilterAgencies
value={value.agencies ?? []}
onChange={(agencies) => handleChange({ ...value, agencies })}
Expand Down
1 change: 1 addition & 0 deletions webapp/src/ee/task/views/myTasks/MyTasksBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const MyTasksBoard = ({
...query,
filterState: showClosed ? ['DONE', 'CLOSED'] : ['DONE'],
filterDoneMinClosedAt: filter.doneMinClosedAt,
filterAgency: filter.agencies,
},
});

Expand Down
1 change: 1 addition & 0 deletions webapp/src/ee/task/views/myTasks/MyTasksList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const MyTasksList = ({
filterProject: filter.projects,
filterType: filter.types,
filterDoneMinClosedAt: filter.doneMinClosedAt,
filterAgency: filter.agencies,
},
options: {
keepPreviousData: true,
Expand Down
Loading

0 comments on commit c5b2854

Please sign in to comment.