mirror of
https://github.com/docmost/docmost.git
synced 2025-11-13 08:42:36 +10:00
fix space translations (#826)
This commit is contained in:
@ -340,5 +340,11 @@
|
|||||||
"Write anything. Enter \"/\" for commands": "Write anything. Enter \"/\" for commands",
|
"Write anything. Enter \"/\" for commands": "Write anything. Enter \"/\" for commands",
|
||||||
"Names do not match": "Names do not match",
|
"Names do not match": "Names do not match",
|
||||||
"Today, {{time}}": "Today, {{time}}",
|
"Today, {{time}}": "Today, {{time}}",
|
||||||
"Yesterday, {{time}}": "Yesterday, {{time}}"
|
"Yesterday, {{time}}": "Yesterday, {{time}}",
|
||||||
|
"Space created successfully": "Space created successfully",
|
||||||
|
"Space updated successfully": "Space updated successfully",
|
||||||
|
"Space deleted successfully": "Space deleted successfully",
|
||||||
|
"Members added successfully": "Members added successfully",
|
||||||
|
"Member removed successfully": "Member removed successfully",
|
||||||
|
"Member role updated successfully": "Member role updated successfully"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,8 @@ import { IconCheck } from "@tabler/icons-react";
|
|||||||
import { Group, Select, SelectProps, Text } from "@mantine/core";
|
import { Group, Select, SelectProps, Text } from "@mantine/core";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { spaceRoleData } from "@/features/space/types/space-role-data.ts";
|
import { spaceRoleData } from "@/features/space/types/space-role-data.ts";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { IRoleData } from "@/lib/types.ts";
|
||||||
|
|
||||||
const iconProps = {
|
const iconProps = {
|
||||||
stroke: 1.5,
|
stroke: 1.5,
|
||||||
@ -38,9 +40,15 @@ export function SpaceMemberRole({
|
|||||||
defaultRole,
|
defaultRole,
|
||||||
label,
|
label,
|
||||||
}: SpaceMemberRoleProps) {
|
}: SpaceMemberRoleProps) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
data={spaceRoleData}
|
data={spaceRoleData.map((role: IRoleData) => ({
|
||||||
|
label: t(role.label),
|
||||||
|
value: role.value,
|
||||||
|
description: t(role.description),
|
||||||
|
}))}
|
||||||
defaultValue={defaultRole}
|
defaultValue={defaultRole}
|
||||||
label={label}
|
label={label}
|
||||||
onChange={onSelect}
|
onChange={onSelect}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ import {
|
|||||||
} from "@/features/space/services/space-service.ts";
|
} from "@/features/space/services/space-service.ts";
|
||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
import { IPagination, QueryParams } from "@/lib/types.ts";
|
import { IPagination, QueryParams } from "@/lib/types.ts";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { queryClient } from "@/main.tsx";
|
import { queryClient } from "@/main.tsx";
|
||||||
import { getRecentChanges } from "@/features/page/services/page-service.ts";
|
import { getRecentChanges } from "@/features/page/services/page-service.ts";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
@ -76,6 +77,7 @@ export const prefetchSpace = (spaceSlug: string, spaceId?: string) => {
|
|||||||
|
|
||||||
export function useCreateSpaceMutation() {
|
export function useCreateSpaceMutation() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return useMutation<ISpace, Error, Partial<ISpace>>({
|
return useMutation<ISpace, Error, Partial<ISpace>>({
|
||||||
mutationFn: (data) => createSpace(data),
|
mutationFn: (data) => createSpace(data),
|
||||||
@ -83,7 +85,7 @@ export function useCreateSpaceMutation() {
|
|||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: ["spaces"],
|
queryKey: ["spaces"],
|
||||||
});
|
});
|
||||||
notifications.show({ message: "Space created successfully" });
|
notifications.show({ message: t("Space created successfully") });
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
const errorMessage = error["response"]?.data?.message;
|
const errorMessage = error["response"]?.data?.message;
|
||||||
@ -105,11 +107,12 @@ export function useGetSpaceBySlugQuery(
|
|||||||
|
|
||||||
export function useUpdateSpaceMutation() {
|
export function useUpdateSpaceMutation() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return useMutation<ISpace, Error, Partial<ISpace>>({
|
return useMutation<ISpace, Error, Partial<ISpace>>({
|
||||||
mutationFn: (data) => updateSpace(data),
|
mutationFn: (data) => updateSpace(data),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Space updated successfully" });
|
notifications.show({ message: t("Space updated successfully") });
|
||||||
|
|
||||||
const space = queryClient.getQueryData([
|
const space = queryClient.getQueryData([
|
||||||
"space",
|
"space",
|
||||||
@ -134,11 +137,12 @@ export function useUpdateSpaceMutation() {
|
|||||||
|
|
||||||
export function useDeleteSpaceMutation() {
|
export function useDeleteSpaceMutation() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (data: Partial<ISpace>) => deleteSpace(data.id),
|
mutationFn: (data: Partial<ISpace>) => deleteSpace(data.id),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Space deleted successfully" });
|
notifications.show({ message: t("Space deleted successfully") });
|
||||||
|
|
||||||
if (variables.slug) {
|
if (variables.slug) {
|
||||||
queryClient.removeQueries({
|
queryClient.removeQueries({
|
||||||
@ -176,11 +180,12 @@ export function useSpaceMembersQuery(
|
|||||||
|
|
||||||
export function useAddSpaceMemberMutation() {
|
export function useAddSpaceMemberMutation() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return useMutation<void, Error, IAddSpaceMember>({
|
return useMutation<void, Error, IAddSpaceMember>({
|
||||||
mutationFn: (data) => addSpaceMember(data),
|
mutationFn: (data) => addSpaceMember(data),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Members added successfully" });
|
notifications.show({ message: t("Members added successfully") });
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: ["spaceMembers", variables.spaceId],
|
queryKey: ["spaceMembers", variables.spaceId],
|
||||||
});
|
});
|
||||||
@ -194,11 +199,12 @@ export function useAddSpaceMemberMutation() {
|
|||||||
|
|
||||||
export function useRemoveSpaceMemberMutation() {
|
export function useRemoveSpaceMemberMutation() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return useMutation<void, Error, IRemoveSpaceMember>({
|
return useMutation<void, Error, IRemoveSpaceMember>({
|
||||||
mutationFn: (data) => removeSpaceMember(data),
|
mutationFn: (data) => removeSpaceMember(data),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Removed successfully" });
|
notifications.show({ message: t("Member removed successfully") });
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
queryKey: ["spaceMembers", variables.spaceId],
|
queryKey: ["spaceMembers", variables.spaceId],
|
||||||
});
|
});
|
||||||
@ -212,11 +218,12 @@ export function useRemoveSpaceMemberMutation() {
|
|||||||
|
|
||||||
export function useChangeSpaceMemberRoleMutation() {
|
export function useChangeSpaceMemberRoleMutation() {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return useMutation<void, Error, IChangeSpaceMemberRole>({
|
return useMutation<void, Error, IChangeSpaceMemberRole>({
|
||||||
mutationFn: (data) => changeMemberRole(data),
|
mutationFn: (data) => changeMemberRole(data),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Member role updated successfully" });
|
notifications.show({ message: t("Member role updated successfully") });
|
||||||
// due to pagination levels, change in cache instead
|
// due to pagination levels, change in cache instead
|
||||||
queryClient.refetchQueries({
|
queryClient.refetchQueries({
|
||||||
queryKey: ["spaceMembers", variables.spaceId],
|
queryKey: ["spaceMembers", variables.spaceId],
|
||||||
|
|||||||
@ -1,21 +1,20 @@
|
|||||||
import { IRoleData, SpaceRole } from "@/lib/types.ts";
|
import { IRoleData, SpaceRole } from "@/lib/types.ts";
|
||||||
import i18n from "@/i18n.ts";
|
|
||||||
|
|
||||||
export const spaceRoleData: IRoleData[] = [
|
export const spaceRoleData: IRoleData[] = [
|
||||||
{
|
{
|
||||||
label: i18n.t("Full access"),
|
label: "Full access",
|
||||||
value: SpaceRole.ADMIN,
|
value: SpaceRole.ADMIN,
|
||||||
description: i18n.t("Has full access to space settings and pages."),
|
description: "Has full access to space settings and pages.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: i18n.t("Can edit"),
|
label: "Can edit",
|
||||||
value: SpaceRole.WRITER,
|
value: SpaceRole.WRITER,
|
||||||
description: i18n.t("Can create and edit pages in space."),
|
description: "Can create and edit pages in space.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: i18n.t("Can view"),
|
label: "Can view",
|
||||||
value: SpaceRole.READER,
|
value: SpaceRole.READER,
|
||||||
description: i18n.t("Can view pages in space but not edit."),
|
description: "Can view pages in space but not edit.",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user