chore: tweak props definition
This commit is contained in:
parent
8df0dea304
commit
54e6ca37a2
16 changed files with 30 additions and 28 deletions
|
|
@ -13,7 +13,7 @@ import React, { useState } from "react";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { Attachment } from "@/types/proto/api/v1/attachment_service";
|
import { Attachment } from "@/types/proto/api/v1/attachment_service";
|
||||||
import { getAttachmentType, getAttachmentUrl } from "@/utils/attachment";
|
import { getAttachmentType, getAttachmentUrl } from "@/utils/attachment";
|
||||||
import { PreviewImageDialog } from "./PreviewImageDialog";
|
import PreviewImageDialog from "./PreviewImageDialog";
|
||||||
import SquareDiv from "./kit/SquareDiv";
|
import SquareDiv from "./kit/SquareDiv";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,14 @@ import { userStore } from "@/store";
|
||||||
import { User } from "@/types/proto/api/v1/user_service";
|
import { User } from "@/types/proto/api/v1/user_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
interface ChangeMemberPasswordDialogProps {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
user?: User;
|
user?: User;
|
||||||
onSuccess?: () => void;
|
onSuccess?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ChangeMemberPasswordDialog({ open, onOpenChange, user, onSuccess }: ChangeMemberPasswordDialogProps) {
|
function ChangeMemberPasswordDialog({ open, onOpenChange, user, onSuccess }: Props) {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const [newPassword, setNewPassword] = useState("");
|
const [newPassword, setNewPassword] = useState("");
|
||||||
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import useLoading from "@/hooks/useLoading";
|
import useLoading from "@/hooks/useLoading";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
interface CreateAccessTokenDialogProps {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
onSuccess: () => void;
|
onSuccess: () => void;
|
||||||
|
|
@ -21,7 +21,7 @@ interface State {
|
||||||
expiration: number;
|
expiration: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CreateAccessTokenDialog({ open, onOpenChange, onSuccess }: CreateAccessTokenDialogProps) {
|
function CreateAccessTokenDialog({ open, onOpenChange, onSuccess }: Props) {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const currentUser = useCurrentUser();
|
const currentUser = useCurrentUser();
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
|
|
|
||||||
|
|
@ -97,14 +97,14 @@ const templateList: IdentityProvider[] = [
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
interface CreateIdentityProviderDialogProps {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
identityProvider?: IdentityProvider;
|
identityProvider?: IdentityProvider;
|
||||||
onSuccess?: () => void;
|
onSuccess?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, onSuccess }: CreateIdentityProviderDialogProps) {
|
function CreateIdentityProviderDialog({ open, onOpenChange, identityProvider, onSuccess }: Props) {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const identityProviderTypes = [...new Set(templateList.map((t) => t.type))];
|
const identityProviderTypes = [...new Set(templateList.map((t) => t.type))];
|
||||||
const [basicInfo, setBasicInfo] = useState({
|
const [basicInfo, setBasicInfo] = useState({
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,14 @@ import { userStore } from "@/store";
|
||||||
import { Shortcut } from "@/types/proto/api/v1/shortcut_service";
|
import { Shortcut } from "@/types/proto/api/v1/shortcut_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
interface CreateShortcutDialogProps {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
shortcut?: Shortcut;
|
shortcut?: Shortcut;
|
||||||
onSuccess?: () => void;
|
onSuccess?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CreateShortcutDialog({ open, onOpenChange, shortcut: initialShortcut, onSuccess }: CreateShortcutDialogProps) {
|
function CreateShortcutDialog({ open, onOpenChange, shortcut: initialShortcut, onSuccess }: Props) {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const user = useCurrentUser();
|
const user = useCurrentUser();
|
||||||
const [shortcut, setShortcut] = useState<Shortcut>({
|
const [shortcut, setShortcut] = useState<Shortcut>({
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@ import useLoading from "@/hooks/useLoading";
|
||||||
import { User, User_Role } from "@/types/proto/api/v1/user_service";
|
import { User, User_Role } from "@/types/proto/api/v1/user_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
interface CreateUserDialogProps {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
user?: User;
|
user?: User;
|
||||||
onSuccess?: () => void;
|
onSuccess?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CreateUserDialog({ open, onOpenChange, user: initialUser, onSuccess }: CreateUserDialogProps) {
|
function CreateUserDialog({ open, onOpenChange, user: initialUser, onSuccess }: Props) {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const [user, setUser] = useState(User.fromPartial({ ...initialUser }));
|
const [user, setUser] = useState(User.fromPartial({ ...initialUser }));
|
||||||
const requestState = useLoading(false);
|
const requestState = useLoading(false);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import useLoading from "@/hooks/useLoading";
|
import useLoading from "@/hooks/useLoading";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
interface CreateWebhookDialogProps {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
webhookName?: string;
|
webhookName?: string;
|
||||||
|
|
@ -21,7 +21,7 @@ interface State {
|
||||||
url: string;
|
url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CreateWebhookDialog({ open, onOpenChange, webhookName, onSuccess }: CreateWebhookDialogProps) {
|
function CreateWebhookDialog({ open, onOpenChange, webhookName, onSuccess }: Props) {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const currentUser = useCurrentUser();
|
const currentUser = useCurrentUser();
|
||||||
const [state, setState] = useState<State>({
|
const [state, setState] = useState<State>({
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { cn } from "@/lib/utils";
|
||||||
import { Attachment } from "@/types/proto/api/v1/attachment_service";
|
import { Attachment } from "@/types/proto/api/v1/attachment_service";
|
||||||
import { getAttachmentType, getAttachmentUrl } from "@/utils/attachment";
|
import { getAttachmentType, getAttachmentUrl } from "@/utils/attachment";
|
||||||
import MemoAttachment from "./MemoAttachment";
|
import MemoAttachment from "./MemoAttachment";
|
||||||
import { PreviewImageDialog } from "./PreviewImageDialog";
|
import PreviewImageDialog from "./PreviewImageDialog";
|
||||||
|
|
||||||
const MemoAttachmentListView = ({ attachments = [] }: { attachments: Attachment[] }) => {
|
const MemoAttachmentListView = ({ attachments = [] }: { attachments: Attachment[] }) => {
|
||||||
const [previewImage, setPreviewImage] = useState<{ open: boolean; urls: string[]; index: number }>({
|
const [previewImage, setPreviewImage] = useState<{ open: boolean; urls: string[]; index: number }>({
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import MemoEditor from "./MemoEditor";
|
||||||
import MemoLocationView from "./MemoLocationView";
|
import MemoLocationView from "./MemoLocationView";
|
||||||
import MemoReactionistView from "./MemoReactionListView";
|
import MemoReactionistView from "./MemoReactionListView";
|
||||||
import MemoRelationListView from "./MemoRelationListView";
|
import MemoRelationListView from "./MemoRelationListView";
|
||||||
import { PreviewImageDialog } from "./PreviewImageDialog";
|
import PreviewImageDialog from "./PreviewImageDialog";
|
||||||
import ReactionSelector from "./ReactionSelector";
|
import ReactionSelector from "./ReactionSelector";
|
||||||
import UserAvatar from "./UserAvatar";
|
import UserAvatar from "./UserAvatar";
|
||||||
import VisibilityIcon from "./VisibilityIcon";
|
import VisibilityIcon from "./VisibilityIcon";
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@ import React, { useEffect, useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Dialog, DialogContent } from "@/components/ui/dialog";
|
import { Dialog, DialogContent } from "@/components/ui/dialog";
|
||||||
|
|
||||||
interface PreviewImageDialogProps {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
imgUrls: string[];
|
imgUrls: string[];
|
||||||
initialIndex?: number;
|
initialIndex?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PreviewImageDialog({ open, onOpenChange, imgUrls, initialIndex = 0 }: PreviewImageDialogProps) {
|
function PreviewImageDialog({ open, onOpenChange, imgUrls, initialIndex = 0 }: Props) {
|
||||||
const [currentIndex, setCurrentIndex] = useState(initialIndex);
|
const [currentIndex, setCurrentIndex] = useState(initialIndex);
|
||||||
|
|
||||||
// Update current index when initialIndex prop changes
|
// Update current index when initialIndex prop changes
|
||||||
|
|
@ -91,3 +91,5 @@ export function PreviewImageDialog({ open, onOpenChange, imgUrls, initialIndex =
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default PreviewImageDialog;
|
||||||
|
|
|
||||||
|
|
@ -59,23 +59,23 @@ const ReactionSelector = observer((props: Props) => {
|
||||||
<PopoverTrigger asChild>
|
<PopoverTrigger asChild>
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-7 w-7 flex justify-center items-center rounded-full border hover:bg-accent hover:text-accent-foreground cursor-pointer transition-colors",
|
"h-7 w-7 flex justify-center items-center rounded-full border cursor-pointer transition-colors hover:opacity-80",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<SmilePlusIcon className="w-4 h-4 mx-auto text-muted-foreground" />
|
<SmilePlusIcon className="w-4 h-4 mx-auto text-muted-foreground" />
|
||||||
</span>
|
</span>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent align="start" sideOffset={2}>
|
<PopoverContent align="center">
|
||||||
<div ref={containerRef}>
|
<div ref={containerRef}>
|
||||||
<div className="flex flex-row flex-wrap py-0.5 px-2 h-auto gap-1 max-w-56">
|
<div className="grid grid-cols-4 sm:grid-cols-6 h-auto gap-1 max-w-56">
|
||||||
{workspaceMemoRelatedSetting.reactions.map((reactionType) => {
|
{workspaceMemoRelatedSetting.reactions.map((reactionType) => {
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
key={reactionType}
|
key={reactionType}
|
||||||
className={cn(
|
className={cn(
|
||||||
"inline-flex w-auto text-base cursor-pointer rounded px-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",
|
"inline-flex w-auto text-base cursor-pointer rounded px-1 text-muted-foreground hover:opacity-80 transition-colors",
|
||||||
hasReacted(reactionType) && "bg-primary text-primary-foreground",
|
hasReacted(reactionType) && "bg-secondary text-secondary-foreground",
|
||||||
)}
|
)}
|
||||||
onClick={() => handleReactionClick(reactionType)}
|
onClick={() => handleReactionClick(reactionType)}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,14 @@ import { memoServiceClient } from "@/grpcweb";
|
||||||
import useLoading from "@/hooks/useLoading";
|
import useLoading from "@/hooks/useLoading";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
interface RenameTagDialogProps {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
tag: string;
|
tag: string;
|
||||||
onSuccess?: () => void;
|
onSuccess?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RenameTagDialog({ open, onOpenChange, tag, onSuccess }: RenameTagDialogProps) {
|
function RenameTagDialog({ open, onOpenChange, tag, onSuccess }: Props) {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const [newName, setNewName] = useState(tag);
|
const [newName, setNewName] = useState(tag);
|
||||||
const requestState = useLoading(false);
|
const requestState = useLoading(false);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { User as UserPb } from "@/types/proto/api/v1/user_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import UserAvatar from "./UserAvatar";
|
import UserAvatar from "./UserAvatar";
|
||||||
|
|
||||||
interface UpdateAccountDialogProps {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
onSuccess?: () => void;
|
onSuccess?: () => void;
|
||||||
|
|
@ -28,7 +28,7 @@ interface State {
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UpdateAccountDialog({ open, onOpenChange, onSuccess }: UpdateAccountDialogProps) {
|
function UpdateAccountDialog({ open, onOpenChange, onSuccess }: Props) {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const currentUser = useCurrentUser();
|
const currentUser = useCurrentUser();
|
||||||
const [state, setState] = useState<State>({
|
const [state, setState] = useState<State>({
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,13 @@ import { useTranslate } from "@/utils/i18n";
|
||||||
import AppearanceSelect from "./AppearanceSelect";
|
import AppearanceSelect from "./AppearanceSelect";
|
||||||
import LocaleSelect from "./LocaleSelect";
|
import LocaleSelect from "./LocaleSelect";
|
||||||
|
|
||||||
interface UpdateCustomizedProfileDialogProps {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
onSuccess?: () => void;
|
onSuccess?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UpdateCustomizedProfileDialog({ open, onOpenChange, onSuccess }: UpdateCustomizedProfileDialogProps) {
|
function UpdateCustomizedProfileDialog({ open, onOpenChange, onSuccess }: Props) {
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const workspaceGeneralSetting = workspaceStore.state.generalSetting;
|
const workspaceGeneralSetting = workspaceStore.state.generalSetting;
|
||||||
const [customProfile, setCustomProfile] = useState<WorkspaceCustomProfile>(
|
const [customProfile, setCustomProfile] = useState<WorkspaceCustomProfile>(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue