Skip to content

Commit

Permalink
Merge pull request #7629 from weseek/fix/120922-121620-replace-by-IAt…
Browse files Browse the repository at this point in the history
…tachmentHasId

imprv: Replaced by IAttachmentHasId
  • Loading branch information
yuki-takei authored May 8, 2023
2 parents c98ab52 + 54d330b commit 25e3d49
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
6 changes: 3 additions & 3 deletions apps/app/src/components/PageAttachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {
useCallback, useMemo, useState,
} from 'react';

import { HasObjectId, IAttachment } from '@growi/core';
import { IAttachmentHasId } from '@growi/core';

import { useSWRxAttachments } from '~/stores/attachment';
import { useIsGuestUser } from '~/stores/context';
Expand All @@ -28,7 +28,7 @@ const PageAttachment = (): JSX.Element => {

// States
const [pageNumber, setPageNumber] = useState(1);
const [attachmentToDelete, setAttachmentToDelete] = useState<(IAttachment & HasObjectId) | null>(null);
const [attachmentToDelete, setAttachmentToDelete] = useState<(IAttachmentHasId) | null>(null);
const [deleting, setDeleting] = useState(false);
const [deleteError, setDeleteError] = useState('');

Expand Down Expand Up @@ -58,7 +58,7 @@ const PageAttachment = (): JSX.Element => {
setAttachmentToDelete(attachment);
}, []);

const onAttachmentDeleteClickedConfirmHandler = useCallback(async(attachment: IAttachment & HasObjectId) => {
const onAttachmentDeleteClickedConfirmHandler = useCallback(async(attachment: IAttachmentHasId) => {
setDeleting(true);

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/prop-types */
import React, { useCallback } from 'react';

import { HasObjectId, IAttachment } from '@growi/core';
import { IAttachmentHasId } from '@growi/core';
import { UserPicture } from '@growi/ui/dist/components/User/UserPicture';
import {
Button,
Expand All @@ -25,10 +25,10 @@ function iconNameByFormat(format: string): string {
type Props = {
isOpen: boolean,
toggle: () => void,
attachmentToDelete: IAttachment & HasObjectId | null,
attachmentToDelete: IAttachmentHasId | null,
deleting: boolean,
deleteError: string,
onAttachmentDeleteClickedConfirm?: (attachment: IAttachment & HasObjectId) => Promise<void>,
onAttachmentDeleteClickedConfirm?: (attachment: IAttachmentHasId) => Promise<void>,
}

export const DeleteAttachmentModal = (props: Props): JSX.Element => {
Expand Down
6 changes: 3 additions & 3 deletions apps/app/src/components/PageAttachment/PageAttachmentList.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';

import { HasObjectId, IAttachment } from '@growi/core';
import { IAttachmentHasId } from '@growi/core';
import { Attachment } from '@growi/ui/dist/components/Attachment';
import { useTranslation } from 'next-i18next';

type Props = {
attachments: (IAttachment & HasObjectId)[],
attachments: (IAttachmentHasId)[],
inUse: { [id: string]: boolean },
onAttachmentDeleteClicked?: (attachment: IAttachment & HasObjectId) => void,
onAttachmentDeleteClicked?: (attachment: IAttachmentHasId) => void,
isUserLoggedIn?: boolean,
}

Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/interfaces/attachment.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { HasObjectId, IAttachment } from '@growi/core';
import type { IAttachmentHasId } from '@growi/core';

import type { PaginateResult } from './mongoose-utils';


export type IResAttachmentList = {
paginateResult: PaginateResult<IAttachment & HasObjectId>
paginateResult: PaginateResult<IAttachmentHasId>
};
5 changes: 2 additions & 3 deletions apps/app/src/stores/attachment.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useCallback } from 'react';

import {
HasObjectId,
IAttachment, Nullable, type SWRResponseWithUtils, withUtils,
IAttachmentHasId, Nullable, type SWRResponseWithUtils, withUtils,
} from '@growi/core';
import useSWR from 'swr';

Expand All @@ -15,7 +14,7 @@ type Util = {
};

type IDataAttachmentList = {
attachments: (IAttachment & HasObjectId)[]
attachments: (IAttachmentHasId)[]
totalAttachments: number
limit: number
};
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/components/Attachment.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';

import { HasObjectId, IAttachment } from '@growi/core';
import { IAttachmentHasId } from '@growi/core';

import { UserPicture } from './User/UserPicture';

type AttachmentProps = {
attachment: IAttachment & HasObjectId,
attachment: IAttachmentHasId,
inUse: boolean,
onAttachmentDeleteClicked?: (attachment: IAttachment & HasObjectId) => void,
onAttachmentDeleteClicked?: (attachment: IAttachmentHasId) => void,
isUserLoggedIn?: boolean,
};

Expand Down

0 comments on commit 25e3d49

Please sign in to comment.