mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
Merge pull request #1262 from makeplane/develop
promote: develop to stage-relaease
This commit is contained in:
commit
9529ddb393
@ -9,6 +9,8 @@ import { useDropzone } from "react-dropzone";
|
||||
import { Transition, Dialog } from "@headlessui/react";
|
||||
// services
|
||||
import fileServices from "services/file.service";
|
||||
// hooks
|
||||
import useWorkspaceDetails from "hooks/use-workspace-details";
|
||||
// ui
|
||||
import { PrimaryButton, SecondaryButton } from "components/ui";
|
||||
// icons
|
||||
@ -35,6 +37,8 @@ export const ImageUploadModal: React.FC<Props> = ({
|
||||
const router = useRouter();
|
||||
const { workspaceSlug } = router.query;
|
||||
|
||||
const { workspaceDetails } = useWorkspaceDetails();
|
||||
|
||||
const onDrop = useCallback((acceptedFiles: File[]) => {
|
||||
setImage(acceptedFiles[0]);
|
||||
}, []);
|
||||
@ -62,12 +66,7 @@ export const ImageUploadModal: React.FC<Props> = ({
|
||||
setIsImageUploading(false);
|
||||
setImage(null);
|
||||
|
||||
if (value) {
|
||||
const index = value.indexOf(".com");
|
||||
const asset = value.substring(index + 5);
|
||||
|
||||
fileServices.deleteUserFile(asset);
|
||||
}
|
||||
if (value) fileServices.deleteUserFile(value);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
@ -81,12 +80,7 @@ export const ImageUploadModal: React.FC<Props> = ({
|
||||
setIsImageUploading(false);
|
||||
setImage(null);
|
||||
|
||||
if (value) {
|
||||
const index = value.indexOf(".com");
|
||||
const asset = value.substring(index + 5);
|
||||
|
||||
fileServices.deleteFile(asset);
|
||||
}
|
||||
if (value && workspaceDetails) fileServices.deleteFile(workspaceDetails.id, value);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
|
@ -90,10 +90,7 @@ const Profile: NextPage = () => {
|
||||
|
||||
setIsRemoving(true);
|
||||
|
||||
const index = url.indexOf(".com");
|
||||
const asset = url.substring(index + 5);
|
||||
|
||||
fileService.deleteUserFile(asset).then(() => {
|
||||
fileService.deleteUserFile(url).then(() => {
|
||||
if (updateUser)
|
||||
userService
|
||||
.updateUser({ avatar: "" })
|
||||
|
@ -111,10 +111,7 @@ const WorkspaceSettings: NextPage = () => {
|
||||
|
||||
setIsImageRemoving(true);
|
||||
|
||||
const index = url.indexOf(".com");
|
||||
const asset = url.substring(index + 5);
|
||||
|
||||
fileService.deleteFile(asset).then(() => {
|
||||
fileService.deleteFile(activeWorkspace.id, url).then(() => {
|
||||
workspaceService
|
||||
.updateWorkspace(activeWorkspace.slug, { logo: "" }, user)
|
||||
.then((res) => {
|
||||
|
@ -40,8 +40,11 @@ class FileServices extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async deleteFile(asset: string): Promise<any> {
|
||||
return this.delete(`/api/workspaces/file-assets/${asset}/`)
|
||||
async deleteFile(workspaceId: string, assetUrl: string): Promise<any> {
|
||||
const lastIndex = assetUrl.lastIndexOf("/");
|
||||
const assetId = assetUrl.substring(lastIndex + 1);
|
||||
|
||||
return this.delete(`/api/workspaces/file-assets/${workspaceId}/${assetId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
@ -56,8 +59,11 @@ class FileServices extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async deleteUserFile(asset: string): Promise<any> {
|
||||
return this.delete(`/api/users/file-assets/${asset}`)
|
||||
async deleteUserFile(assetUrl: string): Promise<any> {
|
||||
const lastIndex = assetUrl.lastIndexOf("/");
|
||||
const assetId = assetUrl.substring(lastIndex + 1);
|
||||
|
||||
return this.delete(`/api/users/file-assets/${assetId}`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
|
Loading…
Reference in New Issue
Block a user