Skip to content

Commit 7fde38c

Browse files
authored
Merge pull request #499 from joelfmrodrigues/add-folder-explorer
add folder explorer control
2 parents 2322a33 + 12e5f62 commit 7fde38c

24 files changed

+3662
-2981
lines changed
6.8 KB
Loading
8.87 KB
Loading
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# FolderExplorer control
2+
3+
This control allows you to explore a folder structure by clinking on a folder to load it's sub-folders and using a breadcrumb navigation to navigate back to a previous level.
4+
It also allows the user to create a new folder at the current level being explored.
5+
6+
Here is an example of the control:
7+
8+
![FolderExplorer](../assets/FolderExplorer.png)
9+
10+
`FolderExplorer` folder creation:
11+
12+
![FolderExplorer add folder](../assets/FolderExplorer-new.png)
13+
14+
## How to use this control in your solutions
15+
16+
- Check that you installed the `@pnp/spfx-controls-react` dependency. Check out the [getting started](../../#getting-started) page for more information about installing the dependency.
17+
- Import the control into your component:
18+
19+
```TypeScript
20+
import { FolderExplorer, IFolder } from "@pnp/spfx-controls-react/lib/FolderExplorer";
21+
```
22+
23+
- Use the `FolderExplorer` control in your code as follows:
24+
25+
```TypeScript
26+
<FolderExplorer
27+
context={this.props.context}
28+
rootFolder={{
29+
Name: 'Documents',
30+
ServerRelativeUrl: `/sites/TestSite/Shared Documents`
31+
}}
32+
defaultFolder={{
33+
Name: 'Documents',
34+
ServerRelativeUrl: `/sites/TestSite/Shared Documents`
35+
}}
36+
onSelect={this._onFolderSelect}
37+
canCreateFolders={true}
38+
/>
39+
```
40+
41+
- The `onSelect` change event returns the selected folder and can be implemented as follows:
42+
43+
```TypeScript
44+
private _onFolderSelect = (folder: IFolder): void => {
45+
console.log('selected folder', folder);
46+
}
47+
```
48+
49+
## Implementation
50+
51+
The `FolderExplorer` control can be configured with the following properties:
52+
53+
| Property | Type | Required | Description |
54+
| ---- | ---- | ---- | ---- |
55+
| context | WebPartContext \| ExtensionContext | yes | The context object of the SPFx loaded webpart or customizer. |
56+
| rootFolder | IFolder | yes | The lowest level folder that can be explored. This can be the root folder of a library. |
57+
| defaultFolder | IFolder | yes | The default folder to be explored. |
58+
| canCreateFolders | boolean | no | Allow current user to create folders on the target location. If enabled, you need to ensure that the user has the required permissions. |
59+
| hiddenBreadcrumb | boolean | no | Hide the breadcrumb control. |
60+
| hiddenFilterBox | boolean | no | Hide the filter box |
61+
| onSelect | (folder: IFolder): void | no | Callback function called after a folder is selected. |
62+
63+
64+
65+
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/FolderExplorer)

docs/documentation/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ The following controls are currently available:
3939
- [DateTimePicker](./controls/DateTimePicker) (DateTime Picker)
4040
- [FilePicker](./controls/FilePicker) (control that allows to browse and select a file from various places)
4141
- [FileTypeIcon](./controls/FileTypeIcon) (Control that shows the icon of a specified file path or application)
42+
- [FolderExplorer](./controls/FolderExplorer) (Control that allows to browse the folders and sub-folders from a root folder)
4243
- [GridLayout](./controls/GridLayout) (control that renders a responsive grid layout for your web parts)
4344
- [IFrameDialog](./controls/IFrameDialog) (renders a Dialog with an iframe as a content)
4445
- [ListItemPicker](./controls/ListItemPicker) (allows to select one or more items from a list)

docs/documentation/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ nav:
1616
- DateTimePicker: 'controls/DateTimePicker.md'
1717
- FilePicker: 'controls/FilePicker.md'
1818
- FileTypeIcon: 'controls/FileTypeIcon.md'
19+
- FolderExplorer: 'controls/FolderExplorer.md'
1920
- GridLayout: 'controls/GridLayout.md'
2021
- IFrameDialog: 'controls/IFrameDialog.md'
2122
- IFramePanel: 'controls/IFramePanel.md'

0 commit comments

Comments
 (0)