started removing reducers
This commit is contained in:
@@ -2,15 +2,12 @@ import Header from "../Header";
|
||||
import MainSection from "../MainSection";
|
||||
import Uploader from "../Uploader";
|
||||
import React from "react";
|
||||
import UploadOverlay from "../UploadOverlay";
|
||||
import HomepageSpinner from "../HomepageSpinner";
|
||||
import MobileContextMenuContainer from "../MobileContextMenu";
|
||||
import ShareModelWrapper from "../ShareModelWrapper";
|
||||
import PhotoViewer from "../PhotoViewer";
|
||||
import { useAppSelector } from "../../hooks/store";
|
||||
|
||||
const Homepage = () => {
|
||||
const photoID = useAppSelector((state) => state.photoViewer.id);
|
||||
return (
|
||||
<div>
|
||||
<HomepageSpinner />
|
||||
@@ -20,12 +17,8 @@ const Homepage = () => {
|
||||
<div className="flex space-between">
|
||||
<MainSection />
|
||||
<Uploader />
|
||||
{photoID.length === 0 ? undefined : <PhotoViewer />}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<UploadOverlay />
|
||||
<ShareModelWrapper />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -32,9 +32,10 @@ class LoginPageContainer extends React.Component {
|
||||
}
|
||||
|
||||
loginWithToken = async () => {
|
||||
console.log("login with token");
|
||||
const loginSuccessful = await this.props.dispatch(startLoginCheck());
|
||||
const loginRedirectRoute =
|
||||
this.props.location.state?.from?.pathname || this.props.currentRoute;
|
||||
this.props.location.state?.from?.pathname || "/home";
|
||||
if (loginSuccessful) {
|
||||
this.props.navigate(loginRedirectRoute);
|
||||
}
|
||||
@@ -250,7 +251,6 @@ const mapStateToProps = (state) => ({
|
||||
id: state.auth.id,
|
||||
loginFailed: state.main.loginFailed,
|
||||
loginFailedCode: state.main.loginFailedCode,
|
||||
currentRoute: state.routes.currentRoute,
|
||||
createNewAccount: state.main.createNewAccount,
|
||||
});
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ import PhotoViewerPopup from "../PhotoViewerPopup";
|
||||
import FileInfoPopup from "../FileInfoPopup";
|
||||
|
||||
const MainSection = memo(() => {
|
||||
const moverID = useAppSelector((state) => state.mover.id);
|
||||
const showPopup = useAppSelector((state) => state.popupFile.showPopup);
|
||||
const selectedItem = useAppSelector((state) => state.selected.popupModal);
|
||||
const { isMedia } = useUtils();
|
||||
return (
|
||||
@@ -32,8 +30,6 @@ const MainSection = memo(() => {
|
||||
<FileInfoPopup />
|
||||
) : undefined}
|
||||
|
||||
{moverID.length === 0 ? undefined : <MoverMenu />}
|
||||
|
||||
<div className="flex flex-row h-screen w-screen pt-16">
|
||||
<LeftSection />
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
import React from "react";
|
||||
|
||||
const ShareMenu = React.forwardRef((props, ref) => {
|
||||
|
||||
if (props.shareSelected === "") {
|
||||
|
||||
return (
|
||||
<div className="sharemenu sharemenu--gone" ref={ref}>
|
||||
|
||||
</div>
|
||||
)
|
||||
|
||||
} else {
|
||||
|
||||
return (
|
||||
<div div className="sharemenu"
|
||||
ref={ref}>
|
||||
|
||||
{props.shareSelected.metadata.link ?
|
||||
|
||||
<div className="sharemenu--block">
|
||||
<img className="sharemenu__close-button" onClick={props.hide} src="/images/close_icon.png"/>
|
||||
<div className="sharemenu__link__wrapper">
|
||||
<img onClick={props.copyLink} className="sharemenu__image" src="/images/copy.svg"/>
|
||||
<p onClick={props.copyLink} className="sharemenu__title">{props.state.title}</p>
|
||||
</div>
|
||||
<button className="sharemenu__button__public" onClick={props.removeLink}>Remove Link</button>
|
||||
|
||||
</div>
|
||||
|
||||
:
|
||||
<div className="sharemenu--block">
|
||||
<img className="sharemenu__close-button" onClick={props.hide} src="/images/close_icon.png"/>
|
||||
<button className="sharemenu__button__public" onClick={props.makePublic}>Make Public</button>
|
||||
<p className="sharemenu__subtitle">Or</p>
|
||||
<button className="sharemenu__button__public" onClick={props.makeOne}>Create One Time Link</button>
|
||||
</div>
|
||||
}
|
||||
|
||||
</div>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
export default ShareMenu
|
||||
@@ -1,218 +0,0 @@
|
||||
import ShareMenu from "./ShareMenu";
|
||||
import {editFile} from "../../actions/files"
|
||||
import {editSelectedItem, setShareSelected, editShareSelected} from "../../actions/selectedItem"
|
||||
import env from "../../enviroment/envFrontEnd";
|
||||
import axios from "../../axiosInterceptor";
|
||||
import Swal from "sweetalert2"
|
||||
import copy from "copy-text-to-clipboard";
|
||||
import {connect} from "react-redux";
|
||||
import React from "react";
|
||||
|
||||
const currentURL = env.url;
|
||||
|
||||
class ShareMenuContainer extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.wrapperRef = React.createRef();
|
||||
|
||||
this.showingSwal = false;
|
||||
|
||||
this.state = {
|
||||
title: "No Link"
|
||||
}
|
||||
}
|
||||
|
||||
handleClickOutside = (e) => {
|
||||
|
||||
if (this.wrapperRef && !this.wrapperRef.current.contains(event.target) && !this.showingSwal) {
|
||||
|
||||
this.props.dispatch(setShareSelected(""))
|
||||
}
|
||||
}
|
||||
|
||||
hide = () => {
|
||||
|
||||
this.props.dispatch(setShareSelected(""))
|
||||
}
|
||||
|
||||
componentWillUnmount = () => {
|
||||
document.removeEventListener('mousedown', this.handleClickOutside);
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
document.addEventListener('mousedown', this.handleClickOutside);
|
||||
}
|
||||
|
||||
componentDidUpdate = () => {
|
||||
if (!this.props.shareSelected.metadata) return;
|
||||
const shareURL = this.props.shareSelected.metadata.drive ? this.props.shareSelected.metadata.link : `/download-page/${this.props.shareSelected._id}/${this.props.shareSelected.metadata.link}`
|
||||
if (this.props.shareSelected.metadata.link && shareURL !== this.state.title) {
|
||||
|
||||
this.setState(() => {
|
||||
return {
|
||||
title: shareURL
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
makePublic = () => {
|
||||
|
||||
this.showingSwal = true;
|
||||
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "Making this public, will allow anyone to have access to it",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, make public'
|
||||
}).then((result) => {
|
||||
|
||||
this.showingSwal = false;
|
||||
|
||||
if (result.value) {
|
||||
|
||||
const url = this.props.shareSelected.metadata.drive ? `/file-service-google/make-public/${this.props.shareSelected._id}` : `/file-service/make-public/${this.props.shareSelected._id}`;
|
||||
|
||||
axios.patch(url, undefined).then((results) => {
|
||||
|
||||
this.props.dispatch(editFile(this.props.shareSelected._id,{"metadata": {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: results.data,
|
||||
linkType: "public"
|
||||
}}))
|
||||
|
||||
this.props.dispatch(editSelectedItem({link: results.data,
|
||||
linkType: "public"}))
|
||||
|
||||
|
||||
this.props.dispatch(editShareSelected({"metadata": {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: results.data,
|
||||
linkType: "public"
|
||||
}}))
|
||||
|
||||
const shareURL = this.props.shareSelected.metadata.drive ? results.data : `${currentURL}/download-page/${this.props.shareSelected._id}/${this.props.shareSelected.metadata.link}`
|
||||
|
||||
this.setState(() => {
|
||||
return {
|
||||
title: shareURL
|
||||
}
|
||||
})
|
||||
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
makeOne = () => {
|
||||
|
||||
this.showingSwal = true;
|
||||
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "One time link, will allow anyone to access this file once",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, create link'
|
||||
}).then((result) => {
|
||||
|
||||
this.showingSwal = false;
|
||||
|
||||
if (result.value) {
|
||||
|
||||
axios.patch(`/file-service/make-one/${this.props.shareSelected._id}`, undefined).then((results) => {
|
||||
|
||||
this.props.dispatch(editFile(this.props.shareSelected._id,{"metadata": {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: results.data,
|
||||
linkType: "one"
|
||||
}}))
|
||||
|
||||
this.props.dispatch(editSelectedItem({link: results.data,
|
||||
linkType: "one"}))
|
||||
|
||||
|
||||
this.props.dispatch(editShareSelected({"metadata": {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: results.data,
|
||||
linkType: "one"
|
||||
}}))
|
||||
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
removeLink = () => {
|
||||
|
||||
const url = this.props.shareSelected.metadata.drive ? `/file-service-google/remove-link/${this.props.shareSelected._id}` : `/file-service/remove-link/${this.props.shareSelected._id}`
|
||||
|
||||
axios.delete(url, {
|
||||
}).then(() => {
|
||||
|
||||
this.props.dispatch(editFile(this.props.shareSelected._id,{"metadata": {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: undefined,
|
||||
linkType: undefined
|
||||
}}))
|
||||
|
||||
this.props.dispatch(editSelectedItem({link: undefined,
|
||||
linkType: undefined}))
|
||||
|
||||
|
||||
this.props.dispatch(editShareSelected({"metadata": {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: undefined,
|
||||
linkType: undefined
|
||||
}}))
|
||||
}).catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
}
|
||||
|
||||
copyLink = () => {
|
||||
|
||||
const shareURL = this.props.shareSelected.metadata.drive ? this.state.title : `${currentURL}/download-page/${this.props.shareSelected._id}/${this.props.shareSelected.metadata.link}`
|
||||
|
||||
copy(shareURL)
|
||||
|
||||
Swal.fire("Link Copied")
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
return <ShareMenu
|
||||
hide={this.hide}
|
||||
removeLink={this.removeLink}
|
||||
makeOne={this.makeOne}
|
||||
makePublic={this.makePublic}
|
||||
removeLink={this.removeLink}
|
||||
copyLink={this.copyLink}
|
||||
ref={this.wrapperRef}
|
||||
state={this.state}
|
||||
{...this.props}/>
|
||||
}
|
||||
}
|
||||
|
||||
const connectStateToProps = (state) => ({
|
||||
|
||||
shareSelected: state.selectedItem.shareSelected
|
||||
})
|
||||
|
||||
export default connect(connectStateToProps)(ShareMenuContainer);
|
||||
@@ -1,594 +0,0 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { editFile } from "../../actions/files";
|
||||
import axios from "../../axiosInterceptor";
|
||||
import env from "../../enviroment/envFrontEnd";
|
||||
import capitalize from "../../utils/capitalize";
|
||||
import bytes from "bytes";
|
||||
import copy from "copy-text-to-clipboard";
|
||||
import {
|
||||
setShareSelected,
|
||||
editSelectedItem,
|
||||
editShareSelected,
|
||||
} from "../../actions/selectedItem";
|
||||
import SpinnerImage from "../SpinnerImage";
|
||||
import SpinnerPage from "../SpinnerPage";
|
||||
import Swal from "sweetalert2";
|
||||
|
||||
const currentURL = env.url;
|
||||
|
||||
class ShareModelContainer extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
shareableLink: "Fetching Link...",
|
||||
loaded: false,
|
||||
sendTo: "",
|
||||
emailSent: false,
|
||||
copySelected: false,
|
||||
public: false,
|
||||
shared: false,
|
||||
};
|
||||
|
||||
this.lastLoadedID = "";
|
||||
}
|
||||
|
||||
componentDidMount = () => {
|
||||
const id = this.props.shareSelected._id;
|
||||
|
||||
//`/file-service/info/${id}`
|
||||
|
||||
const url = this.props.shareSelected.metadata.drive
|
||||
? `/file-service-google/info/${id}`
|
||||
: `/file-service/info/${id}`;
|
||||
|
||||
axios
|
||||
.get(url)
|
||||
.then((response) => {
|
||||
console.log("file info response", response.data);
|
||||
|
||||
const linkType = response.data.metadata.linkType;
|
||||
|
||||
const shareURL = this.props.shareSelected.metadata.drive
|
||||
? response.data.metadata.link
|
||||
: `${currentURL}/download-page/${this.props.shareSelected._id}/${this.props.shareSelected.metadata.link}`;
|
||||
|
||||
console.log("share link type", linkType, response.data);
|
||||
|
||||
this.setState(() => ({
|
||||
...this.state,
|
||||
shared: linkType ? true : false,
|
||||
loaded: true,
|
||||
shareableLink: shareURL,
|
||||
}));
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log("Cannot get share file data", e);
|
||||
});
|
||||
};
|
||||
|
||||
componentDidUpdate = () => {
|
||||
// console.log("share model updated");
|
||||
// if (this.lastLoadedID !== this.props.shareSelected._id && this.props.shareSelected !== "") {
|
||||
// if (this.props.shareSelected.metadata.link && !this.props.shareSelected.metadata.drive) {
|
||||
// console.log("link already exists");
|
||||
// this.lastLoadedID = this.props.shareSelected._id;
|
||||
// const shareURL = this.props.shareSelected.metadata.drive ? results.data : `${currentURL}/download-page/${this.props.shareSelected._id}/${this.props.shareSelected.metadata.link}`
|
||||
// return this.setState(() => {
|
||||
// return {
|
||||
// ...this.state,
|
||||
// shareableLink: shareURL,
|
||||
// loaded: true,
|
||||
// public: true
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
// this.lastLoadedID = this.props.shareSelected._id;
|
||||
// console.log("share props", this.props.shareSelected)
|
||||
// const url = this.props.shareSelected.metadata.drive ? currentURL +`/file-service-google/make-public/${this.props.shareSelected._id}` : currentURL +`/file-service/make-public/${this.props.shareSelected._id}`;
|
||||
// console.log("share", url)
|
||||
// axios.patch(url, undefined).then((results) => {
|
||||
// this.props.shareSelected.metadata.link = results.data;
|
||||
// this.props.dispatch(editFile(this.props.shareSelected._id,{"metadata": {
|
||||
// ...this.props.shareSelected.metadata,
|
||||
// link: results.data,
|
||||
// linkType: "public"
|
||||
// }}));
|
||||
// const shareURL = this.props.shareSelected.metadata.drive ? results.data : `${currentURL}/download-page/${this.props.shareSelected._id}/${this.props.shareSelected.metadata.link}`
|
||||
// this.setState(() => {
|
||||
// return {
|
||||
// ...this.state,
|
||||
// shareableLink: shareURL,
|
||||
// loaded: true,
|
||||
// public: true
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
};
|
||||
|
||||
sendEmail = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (this.state.sendTo.length === 0 || !this.state.loaded) return;
|
||||
|
||||
if (!this.state.shared) {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "You must share the file first",
|
||||
text: "Select make public or make one time before sending email",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("sending email share request");
|
||||
|
||||
const data = {
|
||||
file: {
|
||||
_id: this.props.shareSelected._id,
|
||||
resp: this.state.sendTo,
|
||||
},
|
||||
};
|
||||
|
||||
axios
|
||||
.post("/file-service/send-share-email", data)
|
||||
.then((response) => {
|
||||
console.log("sent email share");
|
||||
|
||||
this.setState(() => {
|
||||
return {
|
||||
...this.state,
|
||||
emailSent: true,
|
||||
};
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log("share file email failed", err);
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Cannot send share email",
|
||||
text: "An error occurred when sending share email",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
onChangeEmail = (e) => {
|
||||
const value = e.target.value;
|
||||
|
||||
this.setState(() => {
|
||||
return {
|
||||
...this.state,
|
||||
sendTo: value,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
closeShareModel = () => {
|
||||
this.props.dispatch(setShareSelected(""));
|
||||
this.setState(() => {
|
||||
return {
|
||||
shareableLink: "Fetching Link...",
|
||||
loaded: false,
|
||||
sendTo: "",
|
||||
emailSent: false,
|
||||
copySelected: false,
|
||||
public: false,
|
||||
};
|
||||
});
|
||||
this.lastLoadedID = "";
|
||||
};
|
||||
|
||||
copyClick = () => {
|
||||
if (!this.state.loaded) return;
|
||||
|
||||
copy(this.state.shareableLink);
|
||||
|
||||
console.log("link copied");
|
||||
|
||||
this.setState(
|
||||
() => {
|
||||
return {
|
||||
...this.state,
|
||||
copySelected: true,
|
||||
};
|
||||
},
|
||||
() => {
|
||||
console.log("new state set");
|
||||
|
||||
window.setTimeout(() => {
|
||||
this.setState(() => {
|
||||
return {
|
||||
...this.state,
|
||||
copySelected: false,
|
||||
};
|
||||
});
|
||||
}, 750);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
removePublicLink = async () => {
|
||||
const url = this.props.shareSelected.metadata.drive
|
||||
? `/file-service-google/remove-link/${this.props.shareSelected._id}`
|
||||
: `/file-service/remove-link/${this.props.shareSelected._id}`;
|
||||
|
||||
axios
|
||||
.delete(url, {})
|
||||
.then(() => {
|
||||
this.props.dispatch(
|
||||
editFile(this.props.shareSelected._id, {
|
||||
metadata: {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: undefined,
|
||||
linkType: undefined,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
this.props.dispatch(
|
||||
editSelectedItem({ link: undefined, linkType: undefined })
|
||||
);
|
||||
|
||||
this.props.dispatch(
|
||||
editShareSelected({
|
||||
metadata: {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: undefined,
|
||||
linkType: undefined,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
this.setState(() => ({
|
||||
...this.state,
|
||||
shared: false,
|
||||
}));
|
||||
|
||||
//this.closeShareModel();
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Cannot remove public link",
|
||||
text: "An error occurred when removing public link",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
makePublic = () => {
|
||||
this.showingSwal = true;
|
||||
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
text: "Making this public, will allow anyone to have access to it",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Yes, make public",
|
||||
}).then((result) => {
|
||||
this.showingSwal = false;
|
||||
|
||||
if (result.value) {
|
||||
const url = this.props.shareSelected.metadata.drive
|
||||
? `/file-service-google/make-public/${this.props.shareSelected._id}`
|
||||
: `/file-service/make-public/${this.props.shareSelected._id}`;
|
||||
|
||||
axios
|
||||
.patch(url, undefined)
|
||||
.then((results) => {
|
||||
this.props.dispatch(
|
||||
editFile(this.props.shareSelected._id, {
|
||||
metadata: {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: results.data,
|
||||
linkType: "public",
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
this.props.dispatch(
|
||||
editSelectedItem({ link: results.data, linkType: "public" })
|
||||
);
|
||||
|
||||
this.props.dispatch(
|
||||
editShareSelected({
|
||||
metadata: {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: results.data,
|
||||
linkType: "public",
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
const shareURL = this.props.shareSelected.metadata.drive
|
||||
? results.data
|
||||
: `${currentURL}/download-page/${this.props.shareSelected._id}/${results.data}`;
|
||||
|
||||
this.setState(() => ({
|
||||
...this.state,
|
||||
shared: true,
|
||||
shareableLink: shareURL,
|
||||
}));
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Cannot make public",
|
||||
text: "An error occurred when making file public",
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
makeOne = () => {
|
||||
this.showingSwal = true;
|
||||
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
text: "One time link, will allow anyone to access this file once",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Yes, create link",
|
||||
}).then((result) => {
|
||||
this.showingSwal = false;
|
||||
|
||||
if (result.value) {
|
||||
axios
|
||||
.patch(
|
||||
`/file-service/make-one/${this.props.shareSelected._id}`,
|
||||
undefined
|
||||
)
|
||||
.then((results) => {
|
||||
this.props.dispatch(
|
||||
editFile(this.props.shareSelected._id, {
|
||||
metadata: {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: results.data,
|
||||
linkType: "one",
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
this.props.dispatch(
|
||||
editSelectedItem({ link: results.data, linkType: "one" })
|
||||
);
|
||||
|
||||
this.props.dispatch(
|
||||
editShareSelected({
|
||||
metadata: {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: results.data,
|
||||
linkType: "one",
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
this.setState(() => ({
|
||||
...this.state,
|
||||
shared: true,
|
||||
}));
|
||||
|
||||
const shareURL = this.props.shareSelected.metadata.drive
|
||||
? results.data
|
||||
: `${currentURL}/download-page/${this.props.shareSelected._id}/${results.data}`;
|
||||
|
||||
this.setState(() => ({
|
||||
...this.state,
|
||||
shared: true,
|
||||
shareableLink: shareURL,
|
||||
}));
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Cannot make one time public link",
|
||||
text: "An error occurred when making one time public link",
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
removeLink = () => {
|
||||
const url = this.props.shareSelected.metadata.drive
|
||||
? `/file-service-google/remove-link/${this.props.shareSelected._id}`
|
||||
: `/file-service/remove-link/${this.props.shareSelected._id}`;
|
||||
|
||||
axios
|
||||
.delete(url, {})
|
||||
.then(() => {
|
||||
this.props.dispatch(
|
||||
editFile(this.props.shareSelected._id, {
|
||||
metadata: {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: undefined,
|
||||
linkType: undefined,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
this.props.dispatch(
|
||||
editSelectedItem({ link: undefined, linkType: undefined })
|
||||
);
|
||||
|
||||
this.props.dispatch(
|
||||
editShareSelected({
|
||||
metadata: {
|
||||
...this.props.shareSelected.metadata,
|
||||
link: undefined,
|
||||
linkType: undefined,
|
||||
},
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Cannot remove public link",
|
||||
text: "An error occurred when removing public link",
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div
|
||||
className="modal__wrap"
|
||||
style={
|
||||
this.props.shareSelected !== ""
|
||||
? { display: "block" }
|
||||
: { display: "none" }
|
||||
}
|
||||
>
|
||||
<div className="inner__modal">
|
||||
<div className="share__modal">
|
||||
<div className="share__head">
|
||||
<div className="share__type">
|
||||
<img src="/assets/extension1.svg" alt="extension" />
|
||||
</div>
|
||||
<div className="share__info">
|
||||
<p>
|
||||
{this.props.shareSelected !== ""
|
||||
? capitalize(this.props.shareSelected.filename)
|
||||
: ""}
|
||||
</p>
|
||||
<span>
|
||||
{this.props.shareSelected !== ""
|
||||
? bytes(this.props.shareSelected.length)
|
||||
: 0}
|
||||
</span>
|
||||
</div>
|
||||
<div className="close__modal">
|
||||
<a>
|
||||
<img
|
||||
src="/assets/close.svg"
|
||||
alt="close"
|
||||
onClick={this.closeShareModel}
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div className="share__recipient">
|
||||
<p>Send to:</p>
|
||||
<form onSubmit={this.sendEmail}>
|
||||
<div className="group__input float__span">
|
||||
<input
|
||||
onChange={this.onChangeEmail}
|
||||
value={this.state.sendTo}
|
||||
type="text"
|
||||
placeholder="Email Address"
|
||||
/>
|
||||
{/* <span>Email address</span> */}
|
||||
</div>
|
||||
<div className="group__submit">
|
||||
<input type="submit" value="Send" />
|
||||
</div>
|
||||
</form>
|
||||
<div
|
||||
className="share__success"
|
||||
style={
|
||||
this.state.emailSent
|
||||
? { display: "block" }
|
||||
: { display: "none" }
|
||||
}
|
||||
>
|
||||
<p>
|
||||
<span>
|
||||
<img src="/assets/success.svg" alt="success" />
|
||||
</span>{" "}
|
||||
Email sent successfully
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="share-model-spinner-wrapper"
|
||||
style={!this.state.loaded ? {} : { display: "none" }}
|
||||
>
|
||||
<SpinnerPage />
|
||||
</div>
|
||||
<div
|
||||
className="share-model-share-buttons-wrapper"
|
||||
style={
|
||||
!this.state.shared && this.state.loaded
|
||||
? {}
|
||||
: { display: "none" }
|
||||
}
|
||||
>
|
||||
<div className="share-button__wrapper">
|
||||
<button
|
||||
onClick={this.makePublic}
|
||||
className="button popup-window__button"
|
||||
>
|
||||
Make Public
|
||||
</button>
|
||||
</div>
|
||||
<div className="share-button__wrapper">
|
||||
<button
|
||||
onClick={this.makeOne}
|
||||
style={
|
||||
this.props.shareSelected.metadata.drive
|
||||
? { display: "none" }
|
||||
: {}
|
||||
}
|
||||
className="button popup-window__button"
|
||||
>
|
||||
Make One Time Link
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="get__share--link"
|
||||
style={this.state.shared ? {} : { display: "none" }}
|
||||
>
|
||||
<p>File link:</p>
|
||||
<div className="get__link">
|
||||
<div
|
||||
className="copied__wrap"
|
||||
style={
|
||||
this.state.copySelected
|
||||
? { display: "block" }
|
||||
: { display: "none" }
|
||||
}
|
||||
>
|
||||
<p>
|
||||
<img src="/assets/copiedcheck.svg" alt="check" /> Copied
|
||||
</p>
|
||||
</div>
|
||||
<input type="text" value={this.state.shareableLink} readonly />
|
||||
<a onClick={this.copyClick}>
|
||||
<img src="/assets/copy.svg" alt="copy" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="share-button__wrapper"
|
||||
style={this.state.shared ? {} : { display: "none" }}
|
||||
>
|
||||
<button
|
||||
onClick={this.removePublicLink}
|
||||
className="button popup-window__button"
|
||||
>
|
||||
Remove Public Access
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const connectStoreToProp = (state) => ({
|
||||
shareSelected: state.selectedItem.shareSelected,
|
||||
});
|
||||
|
||||
export default connect(connectStoreToProp)(ShareModelContainer);
|
||||
@@ -1,24 +0,0 @@
|
||||
import React from "react";
|
||||
import {connect} from "react-redux";
|
||||
import ShareModel from "../ShareModel";
|
||||
|
||||
class ShareModelWrapper extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{this.props.shareSelected !== "" ? <ShareModel/> : undefined}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const connectPropToStore = (state) => ({
|
||||
shareSelected: state.selectedItem.shareSelected
|
||||
})
|
||||
|
||||
export default connect(connectPropToStore)(ShareModelWrapper)
|
||||
@@ -1,23 +0,0 @@
|
||||
import React from "react";
|
||||
|
||||
const UploadOverlay = (props) => (
|
||||
<div
|
||||
onClick={props.closeOverlay}
|
||||
className="upload__overlay"
|
||||
draggable="true"
|
||||
onDrop={props.onDragDropEvent}
|
||||
onDragOver={props.onDragOverEvent}
|
||||
onDragLeave={props.onDragLeaveEvent}
|
||||
onDragEnter={props.onDragEnterEvent}
|
||||
style={props.uploadOverlayOpen ? { display: "block" } : { display: "none" }}
|
||||
>
|
||||
<div className="inner__upload">
|
||||
<div className="upload__image">
|
||||
<img src="/assets/upload.svg" alt="upload" />
|
||||
</div>
|
||||
<p>Drop your files anywhere to start uploading</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default UploadOverlay;
|
||||
@@ -1,61 +0,0 @@
|
||||
import React from "react";
|
||||
import {connect} from "react-redux"
|
||||
import { startAddFile } from "../../actions/files";
|
||||
import { closeUploadOverlay } from "../../actions/main";
|
||||
import UploadOverlay from "./UploadOverlay";
|
||||
|
||||
class UploadOverlayContainer extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
onDragDropEvent = (e) => {
|
||||
|
||||
e.preventDefault()
|
||||
|
||||
const fileInput = e.dataTransfer;
|
||||
|
||||
this.props.dispatch(startAddFile(fileInput, this.props.parent, this.props.parentList, this.props.storageSwitcher))
|
||||
this.closeOverlay()
|
||||
}
|
||||
|
||||
onDragEnterEvent = (e) => {
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
onDragLeaveEvent = (e) => {
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
onDragOverEvent = (e) => {
|
||||
e.preventDefault()
|
||||
}
|
||||
|
||||
closeOverlay = () => {
|
||||
|
||||
this.props.dispatch(closeUploadOverlay());
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
|
||||
<UploadOverlay
|
||||
closeOverlay={this.closeOverlay}
|
||||
onDragDropEvent={this.onDragDropEvent}
|
||||
onDragOverEvent={this.onDragOverEvent}
|
||||
onDragLeaveEvent={this.onDragLeaveEvent}
|
||||
onDragEnterEvent={this.onDragEnterEvent}
|
||||
{...this.props}/>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const connectStoreToProp = (state) => ({
|
||||
uploadOverlayOpen: state.main.uploadOverlayOpen,
|
||||
parent: state.parent.parent,
|
||||
parentList: state.parent.parentList,
|
||||
storageSwitcher: state.storageSwitcher.selected
|
||||
})
|
||||
|
||||
export default connect(connectStoreToProp)(UploadOverlayContainer);
|
||||
+15
-15
@@ -27,25 +27,25 @@ const store = configureStore({
|
||||
reducer: {
|
||||
auth: authReducer,
|
||||
main: mainReducer,
|
||||
files: fileReducer,
|
||||
folders: folderReducer,
|
||||
// files: fileReducer,
|
||||
// folders: folderReducer,
|
||||
filter: filterReducer,
|
||||
selected: selectedReducer,
|
||||
leftSection: leftSectionReducer,
|
||||
selectedItem: selectedItemReducer,
|
||||
// selectedItem: selectedItemReducer,
|
||||
uploads: uploadsReducer,
|
||||
storage: storageReducer,
|
||||
quickFiles: quickFilesReducer,
|
||||
popupFile: popupFilesReducer,
|
||||
settings: settingsReducer,
|
||||
parent: parentReducer,
|
||||
addOptions: addOptionsReducer,
|
||||
photoViewer: photoViewerReducer,
|
||||
routes: routesReducer,
|
||||
mover: moverReducer,
|
||||
folderTree: folderTreeReducer,
|
||||
storageSwitcher: uploadStorageSwitcherReducer,
|
||||
mobileContextMenu: mobileContextMenuReducer,
|
||||
// storage: storageReducer,
|
||||
// quickFiles: quickFilesReducer,
|
||||
// popupFile: popupFilesReducer,
|
||||
// settings: settingsReducer,
|
||||
// parent: parentReducer,
|
||||
// addOptions: addOptionsReducer,
|
||||
// photoViewer: photoViewerReducer,
|
||||
// routes: routesReducer,
|
||||
// mover: moverReducer,
|
||||
// folderTree: folderTreeReducer,
|
||||
// storageSwitcher: uploadStorageSwitcherReducer,
|
||||
// mobileContextMenu: mobileContextMenuReducer,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user