Skip to content

Commit

Permalink
DRAFT: FE
Browse files Browse the repository at this point in the history
  • Loading branch information
StaNov committed Nov 25, 2024
1 parent ffd66ca commit c537ec6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions webapp/src/service/apiSchema.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@ export interface components {
slug?: string;
/** Format: int64 */
baseLanguageId?: number;
useNamespaces: boolean;
/** Format: int64 */
defaultNamespaceId?: number;
description?: string;
Expand Down Expand Up @@ -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"];
Expand Down
14 changes: 14 additions & 0 deletions webapp/src/views/projects/project/ProjectSettingsGeneral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 | '';
};

Expand Down Expand Up @@ -49,6 +51,15 @@ const LanguageSelect = () => {
);
};

const NamespacesCheckbox = () => {
return (
<UseNamespacesCheckbox
label={<T keyName="project_settings_use_namespaces" />}
name="useNamespaces"
/>
);
};

const NamespaceSelect = () => {
const { allNamespacesWithNone } = useProjectNamespaces();
return (
Expand All @@ -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;

Expand All @@ -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,
};
Expand Down Expand Up @@ -157,6 +170,7 @@ export const ProjectSettingsGeneral = () => {
<ProjectLanguagesProvider>
<LanguageSelect />
</ProjectLanguagesProvider>
<NamespacesCheckbox />
<NamespaceSelect />
</Box>
</StandardForm>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<Box>
<FieldLabel>{props.label}</FieldLabel>
<Checkbox
data-cy="default-namespace-select"
sx={{ mt: 0 }}
name={props.name}
size="small"
/>
</Box>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const FormBody: React.FC<Props> = ({ onCancel, autofocus }) => {
{({ field, form }: FieldProps<any>) => {
return (
<div>
<FieldLabel>
<FieldLabel> {/*TODO tady možná taky*/}
<LabelHint title={t('translation_single_namespace_hint')}>
<T keyName="translation_single_label_namespace" />
</LabelHint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ export const KeyGeneral = () => {
</EditorWrapper>
<FieldError error={errors.name} />
</StyledSection>
{/*<ConditionalFormItem>*/}
<StyledSection>
<FieldLabel>
<LabelHint title={t('translations_key_edit_label_namespace_hint')}>
{t('translations_key_edit_label_namespace')}
{t('translations_key_edit_label_namespace')} tady
</LabelHint>
</FieldLabel>
<NamespaceSelector
Expand All @@ -84,6 +85,7 @@ export const KeyGeneral = () => {
/>
<FieldError error={errors.namespace} />
</StyledSection>
{/*</ConditionalFormItem>*/}
</StyledKeyNsContainer>

<StyledSection>
Expand Down

0 comments on commit c537ec6

Please sign in to comment.