Skip to content

Commit 3a7a682

Browse files
committed
#206 - Added hideButton property to Placeholder
1 parent cf24ac5 commit 3a7a682

File tree

7 files changed

+23
-15
lines changed

7 files changed

+23
-15
lines changed

CHANGELOG.JSON

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"`PeoplePicker`: Allow the people picker to search on site level and on tenant level [#97](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/97)",
1212
"`ListView`: Added support for filtering [#99](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/99)",
1313
"`PeoplePicker`: Make the titleText property not required [#184](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/184)",
14+
"`Placeholder`: Added the ability to specify if the button can be hidden [#206](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/206)",
1415
"Updated the `office-ui-fabric-react` to the same version as in SPFx 1.7.0"
1516
],
1617
"fixes": [

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- `PeoplePicker`: Allow the people picker to search on site level and on tenant level [#97](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/97)
1313
- `ListView`: Added support for filtering [#99](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/99)
1414
- `PeoplePicker`: Make the titleText property not required [#184](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/184)
15+
- `Placeholder`: Added the ability to specify if the button can be hidden [#206](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/206)
1516
- Updated the `office-ui-fabric-react` to the same version as in SPFx 1.7.0
1617

1718
### Fixes

docs/documentation/docs/about/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- `PeoplePicker`: Allow the people picker to search on site level and on tenant level [#97](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/97)
1313
- `ListView`: Added support for filtering [#99](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/99)
1414
- `PeoplePicker`: Make the titleText property not required [#184](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/184)
15+
- `Placeholder`: Added the ability to specify if the button can be hidden [#206](https://github.com/SharePoint/sp-dev-fx-controls-react/issues/206)
1516
- Updated the `office-ui-fabric-react` to the same version as in SPFx 1.7.0
1617

1718
### Fixes

docs/documentation/docs/controls/Placeholder.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ The placeholder control can be configured with the following properties:
4444
| description | string | yes | Text description for the placeholder. This appears bellow the Icon and IconText. |
4545
| iconName | string | yes | The name of the icon that will be used in the placeholder. This is the same name as you can find on the Office UI Fabric icons page: [Office UI Fabric icons](https://dev.office.com/fabric#/styles/icons). For example: `Page` or `Add`. |
4646
| iconText | string | yes | Heading text which is displayed next to the icon. |
47+
| hideButton | boolean | no | Specify if you want to hide the button. Default is `false`. |
4748
| onConfigure | function | no | onConfigure handler for the button. The button is optional. |
4849

4950
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/Placeholder)

src/controls/placeholder/IPlaceholderComponent.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,20 @@ export interface IPlaceholderProps {
2121
* Optional: As the button is optional.
2222
*/
2323
buttonLabel?: string;
24-
/**
25-
* onConfigure handler for the button.
26-
* Optional: As the button is optional.
27-
*/
28-
onConfigure?: () => void;
2924
/**
3025
* This className is applied to the root element of content. Use this to
3126
* apply custom styles to the placeholder.
3227
*/
3328
contentClassName?: string;
29+
/**
30+
* Specify if you want to hide the config button
31+
*/
32+
hideButton?: boolean;
33+
/**
34+
* onConfigure handler for the button.
35+
* Optional: As the button is optional.
36+
*/
37+
onConfigure?: () => void;
3438
}
3539

3640
export interface IPlaceholderState {

src/controls/placeholder/PlaceholderComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class Placeholder extends React.Component<IPlaceholderProps, IPlaceholder
5454
* @param nextState
5555
*/
5656
public shouldComponentUpdate(nextProps: IPlaceholderProps, nextState: IPlaceholderState): boolean {
57-
return this.state.width !== nextState.width;
57+
return this.state.width !== nextState.width || this.props.hideButton !== nextProps.hideButton;
5858
}
5959

6060
/**
@@ -101,7 +101,7 @@ export class Placeholder extends React.Component<IPlaceholderProps, IPlaceholder
101101
{this.props.children}
102102
<div className={styles.placeholderDescription}>
103103
{
104-
this.props.buttonLabel &&
104+
(this.props.buttonLabel && !this.props.hideButton) &&
105105
<PrimaryButton
106106
text={this.props.buttonLabel}
107107
ariaLabel={this.props.buttonLabel}

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { WebPartTitle } from '../../../WebPartTitle';
1414
import { TaxonomyPicker, IPickerTerms } from '../../../TaxonomyPicker';
1515
import { ListPicker } from '../../../ListPicker';
1616
import { IFrameDialog } from '../../../IFrameDialog';
17-
import { Environment, EnvironmentType } from '@microsoft/sp-core-library';
17+
import { Environment, EnvironmentType, DisplayMode } from '@microsoft/sp-core-library';
1818
import { SecurityTrimmedControl, PermissionLevel } from '../../../SecurityTrimmedControl';
1919
import { SPPermission } from '@microsoft/sp-page-context';
2020
import { PeoplePicker, PrincipalType } from '../../../PeoplePicker';
@@ -235,6 +235,13 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
235235
title={this.props.title}
236236
updateProperty={this.props.updateProperty} />
237237

238+
<Placeholder iconName='Edit'
239+
iconText='Configure your web part'
240+
description='Please configure the web part.'
241+
buttonLabel='Configure'
242+
hideButton={this.props.displayMode === DisplayMode.Read}
243+
onConfigure={this._onConfigure} />
244+
238245
<PeoplePicker context={this.props.context}
239246
titleText="People Picker (Group not found)"
240247
webAbsoluteUrl={this.props.context.pageContext.site.absoluteUrl}
@@ -487,13 +494,6 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
487494
<SiteBreadcrumb context={this.props.context} />
488495
</div>
489496

490-
<Placeholder
491-
iconName='Edit'
492-
iconText='Configure your web part'
493-
description='Please configure the web part.'
494-
buttonLabel='Configure'
495-
onConfigure={this._onConfigure} />
496-
497497
<p><a href="javascript:;" onClick={this.deleteItem}>Deletes second item</a></p>
498498
</div>
499499
);

0 commit comments

Comments
 (0)