I need to find out whether a user is in a group. If he is, then I could show or hide properties.
I have the below code, can this be used or adapted to find out whether a user is in a 'manager group'?
let grupy = sp.web.currentUser.groups.getByName("Właściciele witryny Portal UAM").users;
console.log(grupy);
One Question is about a properties and second is about current user logged.
Here are all my properties:
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration
{
let contextWeb = this.context.pageContext.web;
let permission = new SPPermission(contextWeb.permissions.value);
let hasPermission = permission.hasPermission(SPPermission.createGroups);
if(hasPermission)
{
return {
pages: [
{
header: {
description: 'Panel globalny Toolboxa',
link1: strings.Link1FieldLabel,
link2: strings.Link2FieldLabel
},
groups: [
{
groupName: 'Właściwości Toolbox',
groupFields: [
PropertyPaneHorizontalRule(),
PropertyPaneTextField('adres_Listy', {
label: "Adres listy docelowej",
disabled: !hasPermission
}),
PropertyFieldListPicker('lists', {
label: 'Wybierz listę',
selectedList: this.properties.lists,
includeHidden: false,
orderBy: PropertyFieldListPickerOrderBy.Title,
disabled: !hasPermission,
onPropertyChange: this.onPropertyPaneFieldChanged.bind(this),
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'listPickerFieldId'
}),
PropertyPaneCheckbox('checkboxProperty5', {
text: this.checkboxProperty5,
checked: true,
disabled: !hasPermission
}),
PropertyFieldPicturePicker('ToolBoxLogo', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.ToolBoxLogo,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: !hasPermission,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'ToolboxLogoId'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('zaokragloneRogi', {
label: "Podaj jak duże zaokrąglenia",
disabled: !hasPermission
}),
PropertyFieldColorPicker('color', {
label: 'Wybierz kolor tła:',
initialColor: this.properties.newValue,
onPropertyChange: this.BackgroundColor.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'colorFieldId'
}),
PropertyFieldColorPicker('colorText', {
label: 'Wybierz kolor tekstu:',
initialColor: this.properties.newValueText,
onPropertyChange: this.TextColor.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'colorTextFieldId'
}),
]
}
]
},
{
header: {
description: 'Panel do zarządzania wierszami w Toolboxie',
link1: strings.Link1FieldLabel,
link2: strings.Link2FieldLabel
},
groups: [
{
groupName: 'Widoczność wierszy - Określamy które wiersze będą widoczne',
groupFields: [
PropertyPaneHorizontalRule(),
PropertyPaneCheckbox('checkboxProperty1', {
text: this.checkboxProperty1,
checked: true
}),
PropertyPaneCheckbox('checkboxProperty2', {
text: this.checkboxProperty2,
checked: true,
}),
PropertyPaneCheckbox('checkboxProperty3', {
text: this.checkboxProperty3,
checked: true
}),
PropertyPaneCheckbox('checkboxProperty4', {
text: this.checkboxProperty4,
checked: true,
})
]
},
{
groupName: 'Wiersz 1',
groupFields: [
PropertyPaneLabel('Opis', { text: 'Za pomocą Toolboxa możesz na uczelni dodać przydatne linki.' }),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa1', {
label: "Nazwa linku nr 1",
}),
PropertyPaneTextField('link1', {
label: "Kafel nr 1"
}),
PropertyFieldPicturePicker('picture1', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture1,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId1'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa2', {
label: "Nazwa link nr 2"
}),
PropertyPaneTextField('link2', {
label: "Kafel nr 2"
}),
PropertyFieldPicturePicker('picture2', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture2,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId2'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa3', {
label: "Nazwa linku nr 3"
}),
PropertyPaneTextField('link3', {
label: "Kafel nr 3"
}),
PropertyFieldPicturePicker('picture3', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture3,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId3'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa4', {
label: "Nazwa linku nr 4"
}),
PropertyPaneTextField('link4', {
label: "Kafel nr 4"
}),
PropertyFieldPicturePicker('picture4', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture4,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId4'
}),
PropertyPaneHorizontalRule()
]
},
{
groupName: 'Wiersz 2',
groupFields: [
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa5', {
label: "Nazwa linku nr 5"
}),
PropertyPaneTextField('link5', {
label: "Kafel nr 5"
}),
PropertyFieldPicturePicker('picture5', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture5,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId5'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa6', {
label: "Nazwa linku nr 6"
}),
PropertyPaneTextField('link6', {
label: "Kafel nr 6"
}),
PropertyFieldPicturePicker('picture6', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture6,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId6'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa7', {
label: "Nazwa linku nr 7"
}),
PropertyPaneTextField('link7', {
label: "Kafel nr 7"
}),
PropertyFieldPicturePicker('picture7', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture7,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId7'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa8', {
label: "Nazwa linku nr 8"
}),
PropertyPaneTextField('link8', {
label: "Kafel nr 8"
}),
PropertyFieldPicturePicker('picture8', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture8,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId8'
}),
PropertyPaneHorizontalRule()
]
},
{
groupName: 'Wiersz 3',
groupFields: [
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa9', {
label: "Nazwa linku nr 9"
}),
PropertyPaneTextField('link9', {
label: "Kafel nr 9"
}),
PropertyFieldPicturePicker('picture9', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture9,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId9'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa10', {
label: "Nazwa linku nr 10"
}),
PropertyPaneTextField('link10', {
label: "Kafel nr 10"
}),
PropertyFieldPicturePicker('picture10', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture10,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId10'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa11', {
label: "Nazwa linku nr 11"
}),
PropertyPaneTextField('link11', {
label: "Kafel nr 11"
}),
PropertyFieldPicturePicker('picture11', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture11,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId11'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa12', {
label: "Nazwa linku nr 12"
}),
PropertyPaneTextField('link12', {
label: "Kafel nr 12"
}),
PropertyFieldPicturePicker('picture12', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture12,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId12'
}),
PropertyPaneHorizontalRule()
]
},
{
groupName: 'Wiersz 4',
groupFields: [
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa13', {
label: "Nazwa linku nr 13"
}),
PropertyPaneTextField('link13', {
label: "Kafel nr 13"
}),
PropertyFieldPicturePicker('picture13', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture13,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId13'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa14', {
label: "Nazwa linku nr 14"
}),
PropertyPaneTextField('link14', {
label: "Kafel nr 14"
}),
PropertyFieldPicturePicker('picture14', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture14,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId14'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa15', {
label: "Nazwa linku nr 15"
}),
PropertyPaneTextField('link15', {
label: "Kafel nr 15",
}),
PropertyFieldPicturePicker('picture15', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture15,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId15'
}),
PropertyPaneHorizontalRule(),
PropertyPaneTextField('Nazwa16', {
label: "Nazwa linku nr 16"
}),
PropertyPaneTextField('link16', {
label: "Kafel nr 16",
}),
PropertyFieldPicturePicker('picture16', {
label: 'Wybierz zdjęcie',
initialValue: this.properties.picture16,
readOnly: true,
previewImage: true,
allowedFileExtensions: '.gif,.jpg,.jpeg,.bmp,.dib,.tif,.tiff,.ico,.png',
disabled: false,
onPropertyChange: this.PictureChange.bind(this),
render: this.render.bind(this),
disableReactivePropertyChanges: this.disableReactivePropertyChanges,
properties: this.properties,
context: this.context,
onGetErrorMessage: null,
deferredValidationTime: 0,
key: 'picturePickerFieldId16'
}),
PropertyPaneHorizontalRule()
]
}
]
}
]
};
}
else{
return {
pages: [
{
header: {
description: 'Panel globalny Toolboxa',
link1: strings.Link1FieldLabel,
link2: strings.Link2FieldLabel
},
groups: [
{
groupName: strings.BasicGroupName,
groupFields: [
PropertyPaneTextField('description', {
label: strings.DescriptionFieldLabel
})
]
}
]
}
]
};
}
}
}