Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

feature: 新增创建Bucket #90

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ script
static
!static/package.json
.eslintcache
.history
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 更新日志
# 🚀 0.4.3
`2021.01.06`
- 🚀 新增
- 支持创建Bucket
- 文件列表操作hover提示
- 🐞 修复
- 文件列表调整
# 🚀 0.4.2
`2020.11.18`

- 🚀 新增
- 支持多AZ存储类型及归档存储类型展示
- 🐞 修复
- 修复滚动无法加载的问题
- 选中多个文件状态下分享功能未禁用
- 进入文件夹中当前选中文件数量未更新
- 删除文件后当前选中文件数量未更新
- 文件图标排列未对齐
- 上传完成文件图标显示不正确
- xmind, docx, gif, jpeg等扩展名文件的图标显示不正确
- 点击文件/文件夹命令后错误选中文件/文件夹
- 新建文件夹后成功后未清空上一次输入框中的文件夹名称
- 搜索Bucket输入不存在的Bucket名称,错误进入上传页面
- 左边sidebar首次进入后没有默认选中全部文件
- 同步盘删除映射后选择框错误选中问题
- 同步盘本地文件目录显示不全
- 同步盘checkbox显示问题
- windows环境下标题栏操作按钮缩放比例较小状态下显示不全
- windows环境下同步盘选择框样式问题

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 木休大人
Copyright (c) 2016 BAIDU

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- [Releases](https://github.com/mudio/bce-client/releases)

## License
MIT © [木休大人](https://github.com/mudio)
MIT © BAIDU

[travis-url]: https://travis-ci.org/mudio/bce-client
[travis-image]: https://img.shields.io/travis/mudio/bce-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43MjMsMC4yNmMtMC4xMzcsMC4wNDUtMC4yODEsMC4wNjctMC40MjIsMC4wOTkKCQljLTAuMDg0LDAtMC4xNjksMC0wLjI1MywwYy0wLjA5MS0wLjAyNC0wLjE4NC0wLjA0MS0wLjI3My0wLjA3MmMtMC4yOS0wLjEtMC41Mi0wLjI5MS0wLjczMy0wLjUwMQoJCWMtMC4zMy0wLjMyNS0wLjU5NS0wLjcwMy0wLjg1My0xLjA4NWMtMC40MTItMC42MTEtMC43MDQtMS4yNzktMC45MjMtMS45ODFDMi4yMzIsMTAuMzU5LDIuMTI0LDkuODQ2LDIuMDgzLDkuMzIKCQlDMi4wNzYsOS4yMzcsMi4wNjcsOS4xNTYsMi4wNiw5LjA3NXoiLz4KCTxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik05LjkzLDAuNWMwLjAyLDAuMjY1LDAuMDEyLDAuNTMtMC4wMzUsMC43OTJjLTAuMSwwLjU0Ni0wLjM0NCwxLjAyMy0wLjY5MiwxLjQ0OQoJCUM4LjksMy4xMTEsOC41NDMsMy40MTMsOC4wOTMsMy41OUM3LjgsMy43MDUsNy40OTYsMy43NTIsNy4xODIsMy43M2MtMC4wMTktMC4wMDEtMC4wMzctMC4wMDUtMC4wNi0wLjAwOAoJCWMwLTAuMTgxLTAuMDE1LTAuMzYxLDAuMDAyLTAuNTM5YzAuMTEtMS4xMjEsMS4wMjctMi4zLDIuNDM2LTIuNjMyQzkuNjUsMC41MzEsOS43NDEsMC41MTcsOS44MzEsMC41CgkJQzkuODY0LDAuNSw5Ljg5NywwLjUsOS45MywwLjV6Ii8%2BCjwvZz4KPC9zdmc%2BCg%3D%3D
Expand Down
5 changes: 3 additions & 2 deletions app/bce/components/common/SystemBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
.container div {
color: #ccc;
width: 35px;
height: 100%;
display: flex;
cursor: pointer;
line-height: 24px;
justify-content: center;
transition: 0.3s ease-in,color 0.3s ease-in;
transition: .3s ease-in, color .3s ease-in;
}

.container .exit,
Expand All @@ -22,7 +23,7 @@

.container .exit:hover {
color: #fff;
background-color: #f06a6a;
background-color: #ff4d4f;
}

.container .min:hover,
Expand Down
10 changes: 5 additions & 5 deletions app/bos/actions/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ export const commandMap = {
[MENU_UPLOAD_COMMAND]: {name: '上传', icon: 'cloud-upload', command: MENU_UPLOAD_COMMAND},
[MENU_UPLOAD_DIRECTORY_COMMAND]: {name: '上传目录', icon: 'cloud-upload', command: MENU_UPLOAD_DIRECTORY_COMMAND},
[MENU_REFRESH_COMMAND]: {name: '刷新', icon: 'refresh', command: MENU_REFRESH_COMMAND},
[MENU_COPY_COMMAND]: {name: '复制到', icon: 'copy', command: MENU_COPY_COMMAND},
[MENU_TRASH_COMMAND]: {name: '删除', icon: 'trash', command: MENU_TRASH_COMMAND},
[MENU_SHARE_COMMAND]: {name: '分享', icon: 'chain', command: MENU_SHARE_COMMAND},
[MENU_COPY_COMMAND]: {name: '复制到', icon: 'copy', title: '复制文件', command: MENU_COPY_COMMAND},
[MENU_TRASH_COMMAND]: {name: '删除', icon: 'trash', title: '删除文件', command: MENU_TRASH_COMMAND},
[MENU_SHARE_COMMAND]: {name: '分享', icon: 'chain', title: '复制链接', command: MENU_SHARE_COMMAND},
[MENU_MOVE_COMMAND]: {name: '移动到', icon: 'arrows', command: MENU_MOVE_COMMAND},
[MENU_VIEW_COMMAND]: {name: '查看', icon: 'eye', command: MENU_VIEW_COMMAND},
[MENU_RENAME_COMMAND]: {name: '重命名', icon: 'pencil', command: MENU_RENAME_COMMAND},
[MENU_DOWNLOAD_COMMAND]: {name: '下载', icon: 'cloud-download', command: MENU_DOWNLOAD_COMMAND},
[MENU_RENAME_COMMAND]: {name: '重命名', icon: 'pencil', title: '重命名文件', command: MENU_RENAME_COMMAND},
[MENU_DOWNLOAD_COMMAND]: {name: '下载', icon: 'cloud-download', title: '下载文件', command: MENU_DOWNLOAD_COMMAND},
[MENU_NEW_DIRECTORY_COMMAND]: {name: '新建文件夹', icon: 'plus', command: MENU_NEW_DIRECTORY_COMMAND},
[MENU_NEW_MAPPING_COMMAND]: {name: '创建同步盘', icon: 'plus', command: MENU_NEW_MAPPING_COMMAND}
};
10 changes: 8 additions & 2 deletions app/bos/actions/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function listMoreObjects(bucketName, prefix = '', marker = '') {
[API_TYPE]: {
types: [LIST_MORE_REQUEST, LIST_MORE_SUCCESS, LIST_MORE_FAILURE],
method: 'listObjects',
args: [bucketName, {delimiter: '/', prefix, marker, maxKeys: 200}]
args: [bucketName, {delimiter: '/', prefix, marker, maxKeys: 1000}]
}
};
}
Expand Down Expand Up @@ -126,7 +126,13 @@ export function migrationObject(config, removeSource = false) {
const objects = await client.listAllObjects(sourceBucket, sourceObject);
// 控制一下copy速率,250ms最多执行5次
const throttledTask = throttle((item, targetKey) => dispatch(
copyObject(sourceBucket, item, targetBucket, targetKey)
copyObject(
sourceBucket,
item,
targetBucket,
targetKey,
{'x-bce-storage-class': item.storageClass}
)
).then(res => {
const {error, response} = res;

Expand Down
26 changes: 24 additions & 2 deletions app/bos/api/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @author mudio([email protected])
*/

import _ from 'lodash';
import url from 'url';
import {isString} from 'util';
import {BosClient} from '@baiducloud/sdk';
Expand All @@ -22,6 +23,18 @@ export class Client extends BosClient {
this.credentials = credentials;
}

createBucket(bucketName, options) {
return super.createBucket(bucketName, options);
}

putBucketStorageclass(bucketName, storageClass, options) {
return super.putBucketStorageclass(bucketName, storageClass, options);
}

putBucketAcl(bucketName, acl, options) {
return super.putBucketAcl(bucketName, acl, options);
}

listBuckets(config = {}) {
const {forceUpdate, search} = config;

Expand All @@ -42,9 +55,15 @@ export class Client extends BosClient {

return super.listBuckets().then(res => {
const {buckets, owner} = res.body;
const response = _.cloneDeep(res.body);
// hanle multi-az property
response.buckets = response.buckets.map(bucket => ({
...bucket,
enableMultiAz: !!bucket.enableMultiAz
}));

try {
sessionStorage.setItem('buckets', JSON.stringify(res.body));
sessionStorage.setItem('buckets', JSON.stringify(response));
} catch (ex) {} // eslint-disable-line

if (search) {
Expand All @@ -54,7 +73,10 @@ export class Client extends BosClient {
};
}

return {owner, buckets};
return {
owner,
buckets
};
});
}

Expand Down
8 changes: 4 additions & 4 deletions app/bos/components/app/SideBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
align-items: center;
padding-left: 40px;
text-decoration: blink;
transition: background 0.3s ease-in,color 0.3s ease-in;
transition: background .3s ease-in, color .3s ease-in;
}

.item:before {
Expand Down Expand Up @@ -99,7 +99,7 @@
}

.active .badge {
background: rgba(10, 84, 183, 0.5);
background: rgba(10, 84, 183, .5);
color: #fff;
}

Expand All @@ -108,14 +108,14 @@
flex-flow: column nowrap;
}

.tool>span {
.tool > span {
cursor: pointer;
font-size: 12px;
color: #8692b2;
margin-left: 40px;
line-height: 24px;
}

.tool>span:hover {
.tool > span:hover {
color: #2eacfc;
}
10 changes: 7 additions & 3 deletions app/bos/components/app/SideBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class SideBar extends Component {
<NavLink to="/region"
className={`${styles.item} ${styles.region}`}
activeClassName={styles.active}
isActive={(match, location) => {
if (!location || !location.pathname || !['/upload', '/download', '/complete', '/sync'].includes(location.pathname)) {
return true;
}

return false;
}}
>
全部文件
</NavLink>
Expand Down Expand Up @@ -84,9 +91,6 @@ class SideBar extends Component {
<BrowserLink linkTo="https://cloud.baidu.com/doc/BOS/s/Ok1rk605h">
开发者文档
</BrowserLink>
<BrowserLink linkTo="https://github.com/leeight/bce-bos-uploader/">
Web Uploader
</BrowserLink>
<BrowserLink linkTo="https://github.com/baidubce/bce-sdk-js">
JavaScript SDK
</BrowserLink>
Expand Down
5 changes: 3 additions & 2 deletions app/bos/components/common/Selection.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
left: 0;
border-radius: 3px;
position: absolute;
background: rgba(68, 76, 99, 0.1);
border: 1px solid rgba(68, 76, 99, 0.2);
background: rgba(68, 76, 99, .1);
border: 1px solid rgba(68, 76, 99, .2);
}

:global .selectionItem {
Expand All @@ -37,6 +37,7 @@
color: #3b8cff;
visibility: hidden;
position: absolute;
font-size: 16px;
}

:global .selectionItem:hover .checkbox {
Expand Down
27 changes: 24 additions & 3 deletions app/bos/components/common/Selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import PropTypes from 'prop-types';
import classnames from 'classnames';
import React, {Component} from 'react';

import {
MENU_RENAME_COMMAND,
MENU_COPY_COMMAND,
MENU_SHARE_COMMAND,
MENU_DOWNLOAD_COMMAND,
MENU_TRASH_COMMAND
} from '../../actions/context';
import styles from './Selection.css';

export default class Selection extends Component {
Expand Down Expand Up @@ -87,6 +94,19 @@ export default class Selection extends Component {
evt.preventDefault();
evt.stopPropagation();

const supportCommands = [
MENU_RENAME_COMMAND,
MENU_COPY_COMMAND,
MENU_SHARE_COMMAND,
MENU_DOWNLOAD_COMMAND,
MENU_TRASH_COMMAND
].map(item => item.toString());

// 如果点击文件命令,则不选中当前文件
if (supportCommands.includes(_.get(evt, 'target.id'))) {
return;
}

const {enabled} = this.props;
const {ctrlKey, shiftKey} = evt;
const keys = Object.keys(this.__selectedCache);
Expand All @@ -112,9 +132,9 @@ export default class Selection extends Component {
}

_onKeyDown = (evt) => {
const {keyCode, ctrlKey, metaKey} = evt;
const {key, ctrlKey, metaKey} = evt;

if (keyCode === 65 && (ctrlKey || metaKey)) {
if (key === 'a' && (ctrlKey || metaKey)) {
evt.preventDefault();
this.selectAll();
}
Expand Down Expand Up @@ -249,7 +269,8 @@ export default class Selection extends Component {
);

return (
<div key={child.key}
<div
key={child.key}
className={styleName}
onClick={evt => this._onSelectItem(evt, child.key)}
onContextMenu={evt => this._onContextMenu(evt, child.key)}
Expand Down
5 changes: 3 additions & 2 deletions app/bos/components/common/SystemBar.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

.container {
height: 25px;
min-height: 24px;
display: flex;
justify-content: flex-end;
-webkit-app-region: drag;
Expand All @@ -12,8 +12,9 @@
display: flex;
cursor: pointer;
line-height: 24px;
min-height: 24px;
justify-content: center;
transition: 0.3s ease-in,color 0.3s ease-in;
transition: .3s ease-in,color .3s ease-in;
}

.title {
Expand Down
17 changes: 9 additions & 8 deletions app/bos/components/explorer/Bucket.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
.container {
display: flex;
width: 90px;
min-height: 80px;
height: 90px;
color: #666;
cursor: pointer;
margin: 5px 0 0 5px;
border-radius: 5px;
flex-flow: column wrap;
align-self: flex-start;
align-items: center;
justify-content: center;
justify-content: flex-start;
user-select: none;
}

Expand All @@ -19,15 +19,16 @@
}

.text {
display: inline-flex;
flex: auto;
width: 90%;
width: 95%;
font-size: 12px;
overflow: hidden;
text-align: center;
align-items: center;
overflow: hidden;
display: -webkit-box;
word-wrap: break-word;
word-break: break-all;
justify-content: center;
-webkit-line-clamp: 2;
text-overflow: ellipsis;
-webkit-box-orient: vertical;
}

.bucketicon {
Expand Down
5 changes: 4 additions & 1 deletion app/bos/components/explorer/Bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import PropTypes from 'prop-types';
import React, {Component} from 'react';
import {Tooltip} from 'antd';

import styles from './Bucket.css';

Expand All @@ -31,7 +32,9 @@ export default class Bucket extends Component {
return (
<div className={styles.container} onClick={this._triggerClick}>
<i className={`${styles.bucketicon} asset-bucket`} />
<span className={styles.text} alt={item.creationDate}>{item.name}</span>
<Tooltip placement="bottom" title={item.name}>
<span className={styles.text} alt={item.creationDate}>{item.name}</span>
</Tooltip>
</div>
);
}
Expand Down
9 changes: 9 additions & 0 deletions app/bos/components/explorer/BucketCreate.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

.link {
color: #1890ff;
cursor: pointer;
}

.tipFocus {
color: #f7a73f;
}
Loading