Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ render(
| logoUrl | string | | *See the [developer docs](https://developer.box.com/docs/box-content-explorer#section-options).* |
| sharedLink | string | | *See the [developer docs](https://developer.box.com/docs/box-content-explorer#section-options).* |
| sharedLinkPassword | string | | *See the [developer docs](https://developer.box.com/docs/box-content-explorer#section-options).* |
| defaultView | string | `files` | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |

### Keyboard Shortcuts
*See the [developer docs](https://developer.box.com/docs/box-content-explorer#section-keyboard-shortcuts).*
Expand Down Expand Up @@ -135,6 +136,9 @@ render(
| logoUrl | string | | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |
| sharedLink | string | | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |
| sharedLinkPassword | string | | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |
| chooseButtonLabel | string | | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |
| cancelButtonLabel | string | | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |
| defaultView | string | `files` | *See the [developer docs](https://developer.box.com/docs/box-content-picker#section-options).* |

### Keyboard Shortcuts
*See the [developer docs](https://developer.box.com/docs/box-content-picker#section-keyboard-shortcuts).*
Expand Down
31 changes: 21 additions & 10 deletions src/components/ContentExplorer/ContentExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ import {
TYPE_FILE,
TYPE_WEBLINK,
TYPE_FOLDER,
CLIENT_NAME_CONTENT_EXPLORER
CLIENT_NAME_CONTENT_EXPLORER,
DEFAULT_VIEW_FILES,
DEFAULT_VIEW_RECENTS
} from '../../constants';
import type {
BoxItem,
Expand All @@ -50,7 +52,8 @@ import type {
SortBy,
Access,
BoxItemPermission,
Token
Token,
DefaultView
} from '../../flowTypes';
import '../fonts.scss';
import '../base.scss';
Expand Down Expand Up @@ -85,6 +88,7 @@ type Props = {
onSelect: Function,
onUpload: Function,
onNavigate: Function,
defaultView: DefaultView,
logoUrl?: string,
sharedLink?: string,
sharedLinkPassword?: string
Expand Down Expand Up @@ -131,7 +135,8 @@ type DefaultProps = {|
onCreate: Function,
onSelect: Function,
onUpload: Function,
onNavigate: Function
onNavigate: Function,
defaultView: DefaultView
|};

class ContentExplorer extends Component<DefaultProps, Props, State> {
Expand Down Expand Up @@ -167,7 +172,8 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
onCreate: noop,
onSelect: noop,
onUpload: noop,
onNavigate: noop
onNavigate: noop,
defaultView: DEFAULT_VIEW_FILES
};

/**
Expand Down Expand Up @@ -237,11 +243,16 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
* @return {void}
*/
componentDidMount() {
const { currentFolderId }: Props = this.props;
const { defaultView, currentFolderId }: Props = this.props;
this.rootElement = ((document.getElementById(this.id): any): HTMLElement);
// $FlowFixMe: child will exist
this.appElement = this.rootElement.firstElementChild;
this.fetchFolder(currentFolderId);

if (defaultView === DEFAULT_VIEW_RECENTS) {
this.showRecents(true);
} else {
this.fetchFolder(currentFolderId);
}
}

/**
Expand Down Expand Up @@ -541,7 +552,7 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
* @param {Boolean|void} [forceFetch] To void cache
* @return {void}
*/
recents = (forceFetch: boolean = false) => {
showRecents = (forceFetch: boolean = false) => {
const { rootFolderId }: Props = this.props;
const { sortBy, sortDirection }: State = this.state;

Expand Down Expand Up @@ -648,7 +659,7 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
if (view === VIEW_FOLDER) {
this.fetchFolder(id, false);
} else if (view === VIEW_RECENTS) {
this.recents();
this.showRecents();
} else if (view === VIEW_SEARCH) {
this.search(searchQuery);
} else {
Expand Down Expand Up @@ -835,7 +846,7 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
if (view === VIEW_FOLDER) {
this.fetchFolder(parentId, false);
} else if (view === VIEW_RECENTS) {
this.recents();
this.showRecents();
} else if (view === VIEW_SEARCH) {
this.search(searchQuery);
} else {
Expand Down Expand Up @@ -1100,7 +1111,7 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
break;
case 'r':
if (this.globalModifier) {
this.recents();
this.showRecents(true);
event.preventDefault();
}
break;
Expand Down
30 changes: 24 additions & 6 deletions src/components/ContentPicker/ContentPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ import {
TYPE_FILE,
TYPE_FOLDER,
TYPE_WEBLINK,
CLIENT_NAME_CONTENT_PICKER
CLIENT_NAME_CONTENT_PICKER,
DEFAULT_VIEW_FILES,
DEFAULT_VIEW_RECENTS
} from '../../constants';
import type {
BoxItem,
Expand All @@ -46,7 +48,8 @@ import type {
SortBy,
Access,
BoxItemPermission,
Token
Token,
DefaultView
} from '../../flowTypes';
import '../fonts.scss';
import '../base.scss';
Expand Down Expand Up @@ -75,6 +78,9 @@ type Props = {
isTouch: boolean,
className: string,
measureRef: Function,
defaultView: DefaultView,
chooseButtonLabel?: string,
cancelButtonLabel?: string,
logoUrl?: string,
sharedLink?: string,
sharedLinkPassword?: string
Expand Down Expand Up @@ -110,7 +116,8 @@ type DefaultProps = {|
apiHost: string,
uploadHost: string,
clientName: string,
className: string
className: string,
defaultView: DefaultView
|};

const defaultType = `${TYPE_FILE},${TYPE_WEBLINK}`;
Expand Down Expand Up @@ -141,7 +148,8 @@ class ContentPicker extends Component<DefaultProps, Props, State> {
className: '',
apiHost: DEFAULT_HOSTNAME_API,
uploadHost: DEFAULT_HOSTNAME_UPLOAD,
clientName: CLIENT_NAME_CONTENT_PICKER
clientName: CLIENT_NAME_CONTENT_PICKER,
defaultView: DEFAULT_VIEW_FILES
};

/**
Expand Down Expand Up @@ -227,7 +235,13 @@ class ContentPicker extends Component<DefaultProps, Props, State> {
this.rootElement = ((document.getElementById(this.id): any): HTMLElement);
// $FlowFixMe: child will exist
this.appElement = this.rootElement.firstElementChild;
this.fetchFolder();

const { defaultView }: Props = this.props;
if (defaultView === DEFAULT_VIEW_RECENTS) {
this.showRecents(true);
} else {
this.fetchFolder();
}
}

/**
Expand Down Expand Up @@ -924,7 +938,9 @@ class ContentPicker extends Component<DefaultProps, Props, State> {
uploadHost,
isSmall,
className,
measureRef
measureRef,
chooseButtonLabel,
cancelButtonLabel
}: Props = this.props;
const {
view,
Expand Down Expand Up @@ -996,6 +1012,8 @@ class ContentPicker extends Component<DefaultProps, Props, State> {
onChoose={this.choose}
onCancel={this.cancel}
getLocalizedMessage={getLocalizedMessage}
chooseButtonLabel={chooseButtonLabel}
cancelButtonLabel={cancelButtonLabel}
/>
</div>
{canUpload && !!this.appElement
Expand Down
12 changes: 8 additions & 4 deletions src/components/ContentPicker/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ type Props = {
hasHitSelectionLimit: boolean,
getLocalizedMessage: Function,
onChoose: Function,
onCancel: Function
onCancel: Function,
chooseButtonLabel?: string,
cancelButtonLabel?: string
};

const Footer = ({
Expand All @@ -23,7 +25,9 @@ const Footer = ({
hasHitSelectionLimit,
onCancel,
onChoose,
getLocalizedMessage
getLocalizedMessage,
chooseButtonLabel,
cancelButtonLabel
}: Props) =>
<div className='bcp-footer'>
<div className='bcp-footer-left'>
Expand All @@ -41,10 +45,10 @@ const Footer = ({
</div>
<div className='bcp-footer-right'>
<Button onClick={onCancel}>
{getLocalizedMessage('buik.footer.button.cancel')}
{cancelButtonLabel || getLocalizedMessage('buik.footer.button.cancel')}
</Button>
<PrimaryButton onClick={onChoose}>
{getLocalizedMessage('buik.footer.button.choose')}
{chooseButtonLabel || getLocalizedMessage('buik.footer.button.choose')}
</PrimaryButton>
</div>
</div>;
Expand Down
9 changes: 1 addition & 8 deletions src/components/Header/Header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@
}

.buik-search {
flex: 1;
padding-left: 20px;

input[type="search"] {
width: 300px;

.buik-is-small & {
width: 205px;
}
}
}
}
12 changes: 4 additions & 8 deletions src/components/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,6 @@
outline: 0;
}

/* stylelint-disable selector-no-vendor-prefix */
&::-webkit-input-placeholder,
&::-moz-placeholder,
&::-ms-input-placeholder {
color: $see-see;
}
/* stylelint-enable selector-no-vendor-prefix */

&:invalid {
border: 1px solid $red;
}
Expand All @@ -187,6 +179,10 @@
&:hover {
border-color: $efive;
}

&::placeholder {
color: $see-see;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export const DEFAULT_HOSTNAME_UPLOAD = 'https://upload.box.com';
export const DEFAULT_CONTAINER = 'body';
export const DEFAULT_ROOT = '0';
export const DEFAULT_SEARCH_DEBOUNCE = 500;
export const DEFAULT_VIEW_FILES: 'files' = 'files';
export const DEFAULT_VIEW_RECENTS: 'recents' = 'recents';
export const BOX_BLUE = '#0061d5';
export const BOX_BLUE_LIGHT = '#dbe8f8';
export const COLOR_RED = '#c82341';
Expand Down
5 changes: 4 additions & 1 deletion src/flowTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ import {
FIELD_NAME,
FIELD_MODIFIED_AT,
FIELD_INTERACTED_AT,
FIELD_SIZE
FIELD_SIZE,
DEFAULT_VIEW_RECENTS,
DEFAULT_VIEW_FILES
} from './constants';

export type Token = string | Function;
Expand All @@ -51,6 +53,7 @@ export type StringMap = { [string]: string };
export type StringAnyMap = { [string]: any };
export type ItemAPI = FolderAPI | FileAPI | WebLinkAPI;
export type Access = typeof ACCESS_COLLAB | typeof ACCESS_COMPANY | typeof ACCESS_OPEN;
export type DefaultView = typeof DEFAULT_VIEW_RECENTS | typeof DEFAULT_VIEW_FILES;
export type View =
| typeof VIEW_ERROR
| typeof VIEW_SELECTED
Expand Down
5 changes: 4 additions & 1 deletion test/pickers-no-react.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ <h1>Folder Picker (max 3 items / token generator / cannot upload)</h1>
autoFocus: true,
sortBy: 'modified_at',
sortDirection: 'DESC',
chooseButtonLabel: 'add',
cancelButtonLabel: 'X',
logoUrl: 'https://d30y9cdsu7xlg0.cloudfront.net/png/12458-200.png'
});
window.fp = filePicker1;
Expand All @@ -133,7 +135,8 @@ <h1>Folder Picker (max 3 items / token generator / cannot upload)</h1>
container: '.filePicker2',
logoUrl: 'https://d30y9cdsu7xlg0.cloudfront.net/png/12458-200.png',
extensions: ['pdf', 'doc', 'docx', 'ppt', 'pptx'],
maxSelectable: 3
maxSelectable: 3,
defaultView: 'recents'
});


Expand Down