mirror of
https://github.com/hexastack/hexabot
synced 2025-05-05 21:34:41 +00:00
fix: content reload after import
This commit is contained in:
parent
fde4224703
commit
535b4f0f8e
@ -46,7 +46,7 @@ const AttachmentInput = forwardRef<HTMLDivElement, AttachmentThumbnailProps>(
|
|||||||
ref,
|
ref,
|
||||||
) => {
|
) => {
|
||||||
const hasPermission = useHasPermission();
|
const hasPermission = useHasPermission();
|
||||||
const handleChange = (attachment: IAttachment | null) => {
|
const handleChange = (attachment?: IAttachment | null) => {
|
||||||
onChange && onChange(attachment?.id || null, attachment?.type || null);
|
onChange && onChange(attachment?.id || null, attachment?.type || null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ export type FileUploadProps = {
|
|||||||
imageButton?: boolean;
|
imageButton?: boolean;
|
||||||
accept: string;
|
accept: string;
|
||||||
enableMediaLibrary?: boolean;
|
enableMediaLibrary?: boolean;
|
||||||
onChange?: (data: IAttachment | null) => void;
|
onChange?: (data?: IAttachment | null) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const AttachmentUploader: FC<FileUploadProps> = ({
|
const AttachmentUploader: FC<FileUploadProps> = ({
|
||||||
@ -99,9 +99,10 @@ const AttachmentUploader: FC<FileUploadProps> = ({
|
|||||||
const file = event.target.files.item(0);
|
const file = event.target.files.item(0);
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
const acceptedTypes = accept.split(',');
|
const acceptedTypes = accept.split(",");
|
||||||
const isValidType = acceptedTypes.some((type) =>
|
const isValidType = acceptedTypes.some(
|
||||||
file.type === type || file.name.endsWith(type.replace('.*', ''))
|
(type) =>
|
||||||
|
file.type === type || file.name.endsWith(type.replace(".*", "")),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isValidType) {
|
if (!isValidType) {
|
||||||
|
@ -43,7 +43,16 @@ export const DeleteDialog: FC<DeleteDialogProps> = ({
|
|||||||
</Grid>
|
</Grid>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button variant="contained" color="error" onClick={callback} autoFocus>
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="error"
|
||||||
|
onClick={() => {
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
autoFocus
|
||||||
|
>
|
||||||
{t("button.yes")}
|
{t("button.yes")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outlined" onClick={closeFunction}>
|
<Button variant="outlined" onClick={closeFunction}>
|
||||||
|
@ -38,17 +38,23 @@ export const ContentImportDialog: FC<ContentImportDialogProps> = ({
|
|||||||
const { refetch, isFetching } = useQuery(
|
const { refetch, isFetching } = useQuery(
|
||||||
["importContent", data?.contentType?.id, attachmentId],
|
["importContent", data?.contentType?.id, attachmentId],
|
||||||
async () => {
|
async () => {
|
||||||
await apiClient.importContent(data?.contentType?.id!, attachmentId!)},
|
if (data?.contentType?.id && attachmentId) {
|
||||||
|
await apiClient.importContent(data.contentType.id, attachmentId);
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
enabled: false,
|
enabled: false,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
handleCloseDialog();
|
handleCloseDialog();
|
||||||
toast.success(t("message.success_save"));
|
toast.success(t("message.success_save"));
|
||||||
|
if (rest.callback) {
|
||||||
|
rest.callback();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t("message.internal_server_error"));
|
toast.error(t("message.internal_server_error"));
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
const handleCloseDialog = () => {
|
const handleCloseDialog = () => {
|
||||||
closeDialog();
|
closeDialog();
|
||||||
|
@ -67,7 +67,7 @@ export const Contents = () => {
|
|||||||
const { data: contentType } = useGet(String(query.id), {
|
const { data: contentType } = useGet(String(query.id), {
|
||||||
entity: EntityType.CONTENT_TYPE,
|
entity: EntityType.CONTENT_TYPE,
|
||||||
});
|
});
|
||||||
const { dataGridProps } = useFind(
|
const { dataGridProps, refetch } = useFind(
|
||||||
{ entity: EntityType.CONTENT, format: Format.FULL },
|
{ entity: EntityType.CONTENT, format: Format.FULL },
|
||||||
{
|
{
|
||||||
params: searchPayload,
|
params: searchPayload,
|
||||||
@ -161,7 +161,12 @@ export const Contents = () => {
|
|||||||
<Paper>
|
<Paper>
|
||||||
<ContentDialog {...getDisplayDialogs(addDialogCtl)} />
|
<ContentDialog {...getDisplayDialogs(addDialogCtl)} />
|
||||||
<ContentDialog {...getDisplayDialogs(editDialogCtl)} />
|
<ContentDialog {...getDisplayDialogs(editDialogCtl)} />
|
||||||
<ContentImportDialog {...getDisplayDialogs(importDialogCtl)} />
|
<ContentImportDialog
|
||||||
|
{...getDisplayDialogs(importDialogCtl)}
|
||||||
|
callback={() => {
|
||||||
|
refetch();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<DeleteDialog
|
<DeleteDialog
|
||||||
{...deleteDialogCtl}
|
{...deleteDialogCtl}
|
||||||
callback={() => {
|
callback={() => {
|
||||||
|
@ -15,7 +15,7 @@ export type DialogControlProps<T, C = never> = Omit<
|
|||||||
>;
|
>;
|
||||||
export type DialogControl<T = null, C = never> = DialogProps & {
|
export type DialogControl<T = null, C = never> = DialogProps & {
|
||||||
data?: T;
|
data?: T;
|
||||||
callback?: (data: C) => void;
|
callback?: (data?: C) => void;
|
||||||
openDialog: (data?: T) => void;
|
openDialog: (data?: T) => void;
|
||||||
closeDialog: () => void;
|
closeDialog: () => void;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user