System Config view only shows panel which logged in user has permission for (#418)
* Do not show distributionSetType on SystemConfig if user do not have any repository permissions Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com> * Log exception if occurs Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com> * Use PermChecker for checking which panel to show Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com> * Remove unused private field Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>
This commit is contained in:
committed by
Kai Zimmermann
parent
1beb2875fa
commit
63ab80ab7b
@@ -12,6 +12,7 @@ import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
|||||||
import org.eclipse.hawkbit.repository.SystemManagement;
|
import org.eclipse.hawkbit.repository.SystemManagement;
|
||||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||||
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||||
|
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.I18N;
|
import org.eclipse.hawkbit.ui.utils.I18N;
|
||||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||||
@@ -29,9 +30,9 @@ import com.vaadin.ui.VerticalLayout;
|
|||||||
/**
|
/**
|
||||||
* Default DistributionSet Panel.
|
* Default DistributionSet Panel.
|
||||||
*/
|
*/
|
||||||
public class DefaultDistributionSetTypeLayout extends BaseConfigurationView implements ConfigurationGroup {
|
public class DefaultDistributionSetTypeLayout extends BaseConfigurationView {
|
||||||
|
|
||||||
private static final long serialVersionUID = 17896542758L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final transient SystemManagement systemManagement;
|
private final transient SystemManagement systemManagement;
|
||||||
|
|
||||||
@@ -41,13 +42,20 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView impl
|
|||||||
|
|
||||||
private TenantMetaData tenantMetaData;
|
private TenantMetaData tenantMetaData;
|
||||||
|
|
||||||
private final ComboBox combobox;
|
final ComboBox combobox;
|
||||||
|
|
||||||
private final Label changeIcon;
|
final Label changeIcon;
|
||||||
|
|
||||||
DefaultDistributionSetTypeLayout(final SystemManagement systemManagement,
|
DefaultDistributionSetTypeLayout(final SystemManagement systemManagement,
|
||||||
final DistributionSetManagement distributionSetManagement, final I18N i18n) {
|
final DistributionSetManagement distributionSetManagement, final I18N i18n,
|
||||||
|
final SpPermissionChecker permChecker) {
|
||||||
this.systemManagement = systemManagement;
|
this.systemManagement = systemManagement;
|
||||||
|
combobox = SPUIComponentProvider.getComboBox(null, "330", null, null, false, "", "label.combobox.tag");
|
||||||
|
changeIcon = new Label();
|
||||||
|
|
||||||
|
if (!permChecker.hasReadDistributionPermission()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final Panel rootPanel = new Panel();
|
final Panel rootPanel = new Panel();
|
||||||
rootPanel.setSizeFull();
|
rootPanel.setSizeFull();
|
||||||
@@ -75,7 +83,6 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView impl
|
|||||||
final Iterable<DistributionSetType> distributionSetTypeCollection = distributionSetManagement
|
final Iterable<DistributionSetType> distributionSetTypeCollection = distributionSetManagement
|
||||||
.findDistributionSetTypesAll(pageReq);
|
.findDistributionSetTypesAll(pageReq);
|
||||||
|
|
||||||
combobox = SPUIComponentProvider.getComboBox(null, "330", null, null, false, "", "label.combobox.tag");
|
|
||||||
combobox.setId(UIComponentIdProvider.SYSTEM_CONFIGURATION_DEFAULTDIS_COMBOBOX);
|
combobox.setId(UIComponentIdProvider.SYSTEM_CONFIGURATION_DEFAULTDIS_COMBOBOX);
|
||||||
combobox.setNullSelectionAllowed(false);
|
combobox.setNullSelectionAllowed(false);
|
||||||
for (final DistributionSetType distributionSetType : distributionSetTypeCollection) {
|
for (final DistributionSetType distributionSetType : distributionSetTypeCollection) {
|
||||||
@@ -91,7 +98,6 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView impl
|
|||||||
combobox.addValueChangeListener(event -> selectDistributionSetValue());
|
combobox.addValueChangeListener(event -> selectDistributionSetValue());
|
||||||
hlayout.addComponent(combobox);
|
hlayout.addComponent(combobox);
|
||||||
|
|
||||||
changeIcon = new Label();
|
|
||||||
changeIcon.setIcon(FontAwesome.CHECK);
|
changeIcon.setIcon(FontAwesome.CHECK);
|
||||||
hlayout.addComponent(changeIcon);
|
hlayout.addComponent(changeIcon);
|
||||||
changeIcon.setVisible(false);
|
changeIcon.setVisible(false);
|
||||||
@@ -99,7 +105,6 @@ public class DefaultDistributionSetTypeLayout extends BaseConfigurationView impl
|
|||||||
vlayout.addComponent(hlayout);
|
vlayout.addComponent(hlayout);
|
||||||
rootPanel.setContent(vlayout);
|
rootPanel.setContent(vlayout);
|
||||||
setCompositionRoot(rootPanel);
|
setCompositionRoot(rootPanel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetType getCurrentDistributionSetType() {
|
private DistributionSetType getCurrentDistributionSetType() {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.eclipse.hawkbit.repository.SystemManagement;
|
|||||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||||
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||||
import org.eclipse.hawkbit.ui.HawkbitUI;
|
import org.eclipse.hawkbit.ui.HawkbitUI;
|
||||||
|
import org.eclipse.hawkbit.ui.SpPermissionChecker;
|
||||||
import org.eclipse.hawkbit.ui.UiProperties;
|
import org.eclipse.hawkbit.ui.UiProperties;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
@@ -79,9 +80,9 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
|
|||||||
final DistributionSetManagement distributionSetManagement,
|
final DistributionSetManagement distributionSetManagement,
|
||||||
final TenantConfigurationManagement tenantConfigurationManagement,
|
final TenantConfigurationManagement tenantConfigurationManagement,
|
||||||
final SecurityTokenGenerator securityTokenGenerator,
|
final SecurityTokenGenerator securityTokenGenerator,
|
||||||
final ControllerPollProperties controllerPollProperties) {
|
final ControllerPollProperties controllerPollProperties, final SpPermissionChecker permChecker) {
|
||||||
this.defaultDistributionSetTypeLayout = new DefaultDistributionSetTypeLayout(systemManagement,
|
this.defaultDistributionSetTypeLayout = new DefaultDistributionSetTypeLayout(systemManagement,
|
||||||
distributionSetManagement, i18n);
|
distributionSetManagement, i18n, permChecker);
|
||||||
this.authenticationConfigurationView = new AuthenticationConfigurationView(i18n, tenantConfigurationManagement,
|
this.authenticationConfigurationView = new AuthenticationConfigurationView(i18n, tenantConfigurationManagement,
|
||||||
securityTokenGenerator);
|
securityTokenGenerator);
|
||||||
this.pollingConfigurationView = new PollingConfigurationView(i18n, controllerPollProperties,
|
this.pollingConfigurationView = new PollingConfigurationView(i18n, controllerPollProperties,
|
||||||
@@ -96,7 +97,9 @@ public class TenantConfigurationDashboardView extends CustomComponent implements
|
|||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
configurationViews.add(defaultDistributionSetTypeLayout);
|
if (defaultDistributionSetTypeLayout.getComponentCount() > 0) {
|
||||||
|
configurationViews.add(defaultDistributionSetTypeLayout);
|
||||||
|
}
|
||||||
configurationViews.add(authenticationConfigurationView);
|
configurationViews.add(authenticationConfigurationView);
|
||||||
configurationViews.add(pollingConfigurationView);
|
configurationViews.add(pollingConfigurationView);
|
||||||
if (customConfigurationViews != null) {
|
if (customConfigurationViews != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user