Skip to content

After claiming size limit of 250MB storage, the Upload File button will be disable #2674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
3 changes: 3 additions & 0 deletions client/modules/IDE/components/AssetSize.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const formatPercent = (percent) => {
return `${Math.round(percentUsed)}%`;
};

export const getCurrentSize = (totalSize) => prettyBytes(totalSize);
export const getSizeLimit = () => prettyBytes(MAX_SIZE_B);

/* Eventually, this copy should be Total / 250 MB Used */
const AssetSize = ({ totalSize }) => {
if (totalSize === undefined) {
Expand Down
33 changes: 25 additions & 8 deletions client/modules/IDE/components/FileNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import DownArrowIcon from '../../../images/down-filled-triangle.svg';
import FolderRightIcon from '../../../images/triangle-arrow-right.svg';
import FolderDownIcon from '../../../images/triangle-arrow-down.svg';
import FileIcon from '../../../images/file.svg';
import { sizeLimit, currentSize } from './AssetSize';

function parseFileName(name) {
const nameArray = name.split('.');
Expand Down Expand Up @@ -148,6 +149,12 @@ class FileNode extends React.Component {
setTimeout(this.hideFileOptions, 0);
};

notifyStorageLimitReached = () => {
alert(
'Your storage reached 250MB, please delete some files to add new ones.'
);
};

handleClickDelete = () => {
const prompt = this.props.t('Common.DeleteConfirmation', {
name: this.props.name
Expand Down Expand Up @@ -360,14 +367,24 @@ class FileNode extends React.Component {
</li>
{this.props.authenticated && (
<li>
<button
aria-label={t('FileNode.UploadFileARIA')}
onClick={this.handleClickUploadFile}
onBlur={this.onBlurComponent}
onFocus={this.onFocusComponent}
>
{t('FileNode.UploadFile')}
</button>
{currentSize < sizeLimit ? (
<button
className="sidebar__file-item-option"
aria-label="FileNode.UploadFileARIA"
onClick={this.handleClickUploadFile}
onBlur={this.onBlurComponent}
onFocus={this.onFocusComponent}
>
{t('FileNode.UploadFile')}
</button>
) : (
<button
className="sidebar__file-item-option"
onClick={this.notifyStorageLimitReached}
>
{t('FileNode.UploadFile')}
</button>
)}
</li>
)}
</React.Fragment>
Expand Down