fix(fe/panel_sharings): introduce rows layout in sharing panel
This commit is contained in:
parent
fc3ecc5543
commit
e60804401e
4 changed files with 121 additions and 87 deletions
|
@ -250,6 +250,14 @@
|
||||||
padding: 1rem 0 1rem 0;
|
padding: 1rem 0 1rem 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.theme-default .upload-item .error {
|
||||||
|
font-size: 1.4rem;
|
||||||
|
padding: 1rem;
|
||||||
|
color: #f1c40f;
|
||||||
|
margin: 1rem 0 0 0;
|
||||||
|
background-color: #2c3e50;
|
||||||
|
}
|
||||||
|
|
||||||
.theme-default #sharing-list .desc {
|
.theme-default #sharing-list .desc {
|
||||||
background-color: #ecf0f1;
|
background-color: #ecf0f1;
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { ICoreState, MsgProps, UIProps } from "./core_state";
|
||||||
import { LoginProps } from "./pane_login";
|
import { LoginProps } from "./pane_login";
|
||||||
import { Flexbox } from "./layout/flexbox";
|
import { Flexbox } from "./layout/flexbox";
|
||||||
import { Container } from "./layout/container";
|
import { Container } from "./layout/container";
|
||||||
import { getIcon } from "./visual/icons";
|
import { Rows, Row } from "./layout/rows";
|
||||||
|
|
||||||
export interface SharingsProps {
|
export interface SharingsProps {
|
||||||
sharings: List<string>;
|
sharings: List<string>;
|
||||||
|
@ -35,54 +35,42 @@ export class SharingsPanel extends React.Component<Props, State, {}> {
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteSharing = async (dirPath: string) => {
|
deleteSharing = async (dirPath: string) => {
|
||||||
return updater()
|
try {
|
||||||
.deleteSharing(dirPath)
|
const deleteStatus = await updater().deleteSharing(dirPath);
|
||||||
.then((status: string) => {
|
if (deleteStatus !== "") {
|
||||||
if (status !== "") {
|
throw deleteStatus;
|
||||||
alertMsg(getErrMsg(this.props.msg.pkg, "op.fail", status));
|
}
|
||||||
} else {
|
updater().setSharing(false);
|
||||||
updater().setSharing(false);
|
|
||||||
return this.listSharings();
|
await this.listSharings();
|
||||||
|
} catch (e: any) {
|
||||||
|
alertMsg(getErrMsg(this.props.msg.pkg, "op.fail", status));
|
||||||
}
|
}
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
listSharings = async () => {
|
listSharings = async () => {
|
||||||
return updater()
|
const status = await updater().listSharings();
|
||||||
.listSharings()
|
|
||||||
.then((status: string) => {
|
|
||||||
if (status !== "") {
|
if (status !== "") {
|
||||||
alertMsg(getErrMsg(this.props.msg.pkg, "op.fail", status));
|
alertMsg(getErrMsg(this.props.msg.pkg, "op.fail", status));
|
||||||
}
|
}
|
||||||
this.props.update(updater().updateFilesInfo);
|
this.props.update(updater().updateFilesInfo);
|
||||||
this.props.update(updater().updateSharingsInfo);
|
this.props.update(updater().updateSharingsInfo);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
makeRows = (sharings: List<string>): List<Row> => {
|
||||||
const nameWidthClass = `item-name item-name-${
|
const sharingRows = sharings.map((dirPath: string) => {
|
||||||
this.props.ui.isVertical ? "vertical" : "horizontal"
|
|
||||||
} pointer`;
|
|
||||||
|
|
||||||
const sharingList = this.props.sharingsInfo.sharings.map(
|
|
||||||
(dirPath: string) => {
|
|
||||||
const sharingURL = `${
|
const sharingURL = `${
|
||||||
document.location.href.split("?")[0]
|
document.location.href.split("?")[0]
|
||||||
}?dir=${encodeURIComponent(dirPath)}`;
|
}?dir=${encodeURIComponent(dirPath)}`;
|
||||||
|
|
||||||
return (
|
const row1 = (
|
||||||
<div className="sharing-item" key={dirPath}>
|
|
||||||
<Flexbox
|
|
||||||
children={List([
|
|
||||||
<Flexbox
|
<Flexbox
|
||||||
children={List([
|
children={List([
|
||||||
<RiFolderSharedFill
|
<RiFolderSharedFill
|
||||||
size="3rem"
|
size="3rem"
|
||||||
className="purple0-font margin-r-m"
|
className="purple0-font margin-r-m"
|
||||||
/>,
|
/>,
|
||||||
<span className={nameWidthClass}>{dirPath}</span>,
|
<span>{dirPath}</span>,
|
||||||
])}
|
|
||||||
/>,
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
@ -93,21 +81,51 @@ export class SharingsPanel extends React.Component<Props, State, {}> {
|
||||||
</button>,
|
</button>,
|
||||||
])}
|
])}
|
||||||
childrenStyles={List([
|
childrenStyles={List([
|
||||||
{ alignItems: "center" },
|
{ flex: "0 0 auto", alignItems: "center" },
|
||||||
{ alignItems: "center", justifyContent: "flex-end" },
|
{ alignItems: "center", justifyContent: "flex-start" },
|
||||||
{ alignItems: "center", justifyContent: "flex-end" },
|
{
|
||||||
|
flex: "0 0 auto",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
},
|
||||||
])}
|
])}
|
||||||
/>
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const elem = (
|
||||||
|
<div className="sharing-item" key={dirPath}>
|
||||||
|
{row1}
|
||||||
<div className="desc">{sharingURL}</div>
|
<div className="desc">{sharingURL}</div>
|
||||||
<div className="hr grey0-bg"></div>
|
<div className="hr grey0-bg"></div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const list =
|
return {
|
||||||
this.props.sharingsInfo.sharings.size === 0 ? (
|
elem,
|
||||||
|
sortVals: List([dirPath]),
|
||||||
|
val: dirPath,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return sharingRows;
|
||||||
|
};
|
||||||
|
|
||||||
|
updateSharings = (sharings: List<Object>) => {
|
||||||
|
const newSharings = sharings as List<string>;
|
||||||
|
updater().updateSharings(newSharings);
|
||||||
|
this.props.update(updater().updateSharingsInfo);
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const sharingRows = this.makeRows(this.props.sharingsInfo.sharings);
|
||||||
|
const view = (
|
||||||
|
<Rows
|
||||||
|
rows={sharingRows}
|
||||||
|
sortKeys={List([this.props.msg.pkg.get("item.path")])}
|
||||||
|
updateRows={this.updateSharings}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
const noSharingView = (
|
||||||
<Container>
|
<Container>
|
||||||
<Flexbox
|
<Flexbox
|
||||||
children={List([
|
children={List([
|
||||||
|
@ -127,6 +145,11 @@ export class SharingsPanel extends React.Component<Props, State, {}> {
|
||||||
])}
|
])}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
|
);
|
||||||
|
|
||||||
|
const list =
|
||||||
|
this.props.sharingsInfo.sharings.size === 0 ? (
|
||||||
|
noSharingView
|
||||||
) : (
|
) : (
|
||||||
<Container>
|
<Container>
|
||||||
<Flexbox
|
<Flexbox
|
||||||
|
@ -151,9 +174,10 @@ export class SharingsPanel extends React.Component<Props, State, {}> {
|
||||||
|
|
||||||
<span></span>,
|
<span></span>,
|
||||||
])}
|
])}
|
||||||
|
className="margin-b-l"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{sharingList}
|
{view}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,6 @@ export class UploadingsPanel extends React.Component<Props, State, {}> {
|
||||||
const fileName = pathParts[pathParts.length - 1];
|
const fileName = pathParts[pathParts.length - 1];
|
||||||
const progress = Math.floor((uploading.uploaded / uploading.size) * 100);
|
const progress = Math.floor((uploading.uploaded / uploading.size) * 100);
|
||||||
|
|
||||||
// const title = <Flexbox children={List([])} />;
|
|
||||||
|
|
||||||
const op = (
|
const op = (
|
||||||
<div className="item-op">
|
<div className="item-op">
|
||||||
<button
|
<button
|
||||||
|
@ -206,7 +204,7 @@ export class UploadingsPanel extends React.Component<Props, State, {}> {
|
||||||
<Container>
|
<Container>
|
||||||
<Flexbox
|
<Flexbox
|
||||||
children={List([
|
children={List([
|
||||||
<span className="upload-item">
|
<span className="margin-b-l">
|
||||||
<Flexbox
|
<Flexbox
|
||||||
children={List([
|
children={List([
|
||||||
<RiUploadCloudFill
|
<RiUploadCloudFill
|
||||||
|
|
|
@ -267,6 +267,10 @@ export class Updater {
|
||||||
this.props.uploadingsInfo.uploadings = uploadings;
|
this.props.uploadingsInfo.uploadings = uploadings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateSharings = (sharings: List<string>) => {
|
||||||
|
this.props.sharingsInfo.sharings = sharings;
|
||||||
|
};
|
||||||
|
|
||||||
moveHere = async (
|
moveHere = async (
|
||||||
srcDir: string,
|
srcDir: string,
|
||||||
dstDir: string,
|
dstDir: string,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue