diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000000..06e486c784 --- /dev/null +++ b/TODO.md @@ -0,0 +1,4 @@ +* Save settings to DB +* Hide select boxes by the settings +* Add liquibase changeset for customers already using namespaces, disable them only when there are none + * Default is off, set it to on for customers who already use it \ No newline at end of file diff --git a/backend/data/src/main/kotlin/io/tolgee/dtos/request/project/EditProjectRequest.kt b/backend/data/src/main/kotlin/io/tolgee/dtos/request/project/EditProjectRequest.kt index 9546b7e00f..1cd3e8e549 100644 --- a/backend/data/src/main/kotlin/io/tolgee/dtos/request/project/EditProjectRequest.kt +++ b/backend/data/src/main/kotlin/io/tolgee/dtos/request/project/EditProjectRequest.kt @@ -13,6 +13,7 @@ data class EditProjectRequest( @field:Pattern(regexp = "^[a-z0-9-]*[a-z]+[a-z0-9-]*$", message = "invalid_pattern") var slug: String? = null, var baseLanguageId: Long? = null, + var useNamespaces: Boolean = false, var defaultNamespaceId: Long? = null, @field:Size(min = 3, max = 2000) var description: String? = null, diff --git a/backend/data/src/main/kotlin/io/tolgee/model/Project.kt b/backend/data/src/main/kotlin/io/tolgee/model/Project.kt index a01b6bda4a..63938bfc71 100644 --- a/backend/data/src/main/kotlin/io/tolgee/model/Project.kt +++ b/backend/data/src/main/kotlin/io/tolgee/model/Project.kt @@ -125,6 +125,9 @@ class Project( @ColumnDefault("true") override var icuPlaceholders: Boolean = true + @ColumnDefault("false") + var useNamespaces: Boolean = false + @ColumnDefault("0") var lastTaskNumber: Long = 0 diff --git a/backend/data/src/main/kotlin/io/tolgee/service/project/ProjectService.kt b/backend/data/src/main/kotlin/io/tolgee/service/project/ProjectService.kt index 0ffa1a5354..59ab225984 100644 --- a/backend/data/src/main/kotlin/io/tolgee/service/project/ProjectService.kt +++ b/backend/data/src/main/kotlin/io/tolgee/service/project/ProjectService.kt @@ -180,6 +180,7 @@ class ProjectService( project.name = dto.name project.description = dto.description project.icuPlaceholders = dto.icuPlaceholders + project.useNamespaces = dto.useNamespaces if (project.defaultNamespace != null) { namespaceService.deleteUnusedNamespaces(listOf(project.defaultNamespace!!)) diff --git a/webapp/src/service/apiSchema.generated.ts b/webapp/src/service/apiSchema.generated.ts index cd63011a2f..46b942e5c1 100644 --- a/webapp/src/service/apiSchema.generated.ts +++ b/webapp/src/service/apiSchema.generated.ts @@ -1152,6 +1152,7 @@ export interface components { slug?: string; /** Format: int64 */ baseLanguageId?: number; + useNamespaces: boolean; /** Format: int64 */ defaultNamespaceId?: number; description?: string; @@ -1336,6 +1337,7 @@ export interface components { avatar?: components["schemas"]["Avatar"]; organizationOwner?: components["schemas"]["SimpleOrganizationModel"]; baseLanguage?: components["schemas"]["LanguageModel"]; + useNamespaces: boolean; defaultNamespace?: components["schemas"]["NamespaceModel"]; organizationRole?: "MEMBER" | "OWNER"; directPermission?: components["schemas"]["PermissionModel"]; diff --git a/webapp/src/views/projects/project/ProjectSettingsGeneral.tsx b/webapp/src/views/projects/project/ProjectSettingsGeneral.tsx index 408ec472b3..c4dd8d7349 100644 --- a/webapp/src/views/projects/project/ProjectSettingsGeneral.tsx +++ b/webapp/src/views/projects/project/ProjectSettingsGeneral.tsx @@ -15,11 +15,13 @@ import { Box, styled } from '@mui/material'; import { ProjectLanguagesProvider } from 'tg.hooks/ProjectLanguagesProvider'; import { useProjectNamespaces } from 'tg.hooks/useProjectNamespaces'; import { DefaultNamespaceSelect } from './components/DefaultNamespaceSelect'; +import { UseNamespacesCheckbox } from './components/UseNamespacesCheckbox'; type FormValues = { name: string; description: string | undefined; baseLanguageId: number | undefined; + useNamespaces: boolean | false; defaultNamespaceId: number | ''; }; @@ -49,6 +51,15 @@ const LanguageSelect = () => { ); }; +const NamespacesCheckbox = () => { + return ( + } + name="useNamespaces" + /> + ); +}; + const NamespaceSelect = () => { const { allNamespacesWithNone } = useProjectNamespaces(); return ( @@ -69,6 +80,7 @@ export const ProjectSettingsGeneral = () => { name: project.name, baseLanguageId: project.baseLanguage?.id, description: project.description ?? '', + useNamespaces: project.useNamespaces ?? false, defaultNamespaceId: defaultNamespace?.id ?? '', } satisfies FormValues; @@ -82,6 +94,7 @@ export const ProjectSettingsGeneral = () => { const data = { ...values, description: values.description || undefined, + useNamespaces: values.useNamespaces || false, defaultNamespaceId: values.defaultNamespaceId === 0 ? undefined : values.defaultNamespaceId, }; @@ -157,6 +170,7 @@ export const ProjectSettingsGeneral = () => { + diff --git a/webapp/src/views/projects/project/components/UseNamespacesCheckbox.tsx b/webapp/src/views/projects/project/components/UseNamespacesCheckbox.tsx new file mode 100644 index 0000000000..a10d9fa0ea --- /dev/null +++ b/webapp/src/views/projects/project/components/UseNamespacesCheckbox.tsx @@ -0,0 +1,24 @@ +import { FC, ReactNode } from 'react'; +import { Box, Checkbox, MenuItem } from '@mui/material'; + +import { Select } from 'tg.component/common/form/fields/Select'; +import { components } from 'tg.service/apiSchema.generated'; +import { FieldLabel } from 'tg.component/FormField'; +import { useTranslate } from '@tolgee/react'; + +export const UseNamespacesCheckbox: FC<{ + label?: ReactNode; + name: string; +}> = (props) => { + return ( + + {props.label} + + + ); +}; diff --git a/webapp/src/views/projects/translations/KeyCreateForm/FormBody.tsx b/webapp/src/views/projects/translations/KeyCreateForm/FormBody.tsx index 77a41bb8e9..111e20ef4d 100644 --- a/webapp/src/views/projects/translations/KeyCreateForm/FormBody.tsx +++ b/webapp/src/views/projects/translations/KeyCreateForm/FormBody.tsx @@ -126,7 +126,7 @@ export const FormBody: React.FC = ({ onCancel, autofocus }) => { {({ field, form }: FieldProps) => { return (
- + {/*TODO tady možná taky*/} diff --git a/webapp/src/views/projects/translations/KeyEdit/KeyGeneral.tsx b/webapp/src/views/projects/translations/KeyEdit/KeyGeneral.tsx index 9453d3e923..e00821cba2 100644 --- a/webapp/src/views/projects/translations/KeyEdit/KeyGeneral.tsx +++ b/webapp/src/views/projects/translations/KeyEdit/KeyGeneral.tsx @@ -67,10 +67,11 @@ export const KeyGeneral = () => { + {/**/} - {t('translations_key_edit_label_namespace')} + {t('translations_key_edit_label_namespace')} tady { /> + {/**/}