-
Notifications
You must be signed in to change notification settings - Fork 1.3k
GUI whitelabel runtime system #8942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7727b28
Add first version
BryanMLima 65e83c2
Add guithemedetails join
BryanMLima 69ce3db
Update since and remove extra line
BryanMLima cdb6e89
Limit information on API response for non admin users
BryanMLima 1af256b
Add base files for preset themes
BryanMLima ccfa622
Add miising license
BryanMLima 90c966b
Revert cookie check
BryanMLima 40af044
Fix imports
BryanMLima 0d3bee5
Fix pre-commit
BryanMLima 4b45e09
Address log4j2 string to format review and add license to css files
BryanMLima 25c5551
Fix infinite loading
BryanMLima 412c146
Move event details to service implementation
BryanMLima 10ab939
Move view to a specific view file
BryanMLima 6a3f8ea
Refactoring gui theme classes
BryanMLima 6915fd6
Normalize package name
BryanMLima a79a546
Address Henrique review
BryanMLima 1a547d7
Fix create table SQL
BryanMLima dd8233f
Add interface for Dao classes
BryanMLima 17fade4
Remove extra tabs
BryanMLima b26c8d5
Address unauthorized call when 2FA is enabled
BryanMLima 65fcd8f
Merge remote-tracking branch 'upstream/main' into whitelabel-gui
BryanMLima 9e4db1d
Resolve conflicts
hsato03 6374971
Remove trailing whitespaces
hsato03 c5f3efd
Apply suggestions from code review
bernardodemarco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add first version
- Loading branch information
commit 7727b28980b58139be226af765356739bd423686
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/CreateGuiThemeCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package org.apache.cloudstack.api.command.user.gui.themes; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.ApiErrorCode; | ||
| import org.apache.cloudstack.api.BaseCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.ServerApiException; | ||
| import org.apache.cloudstack.api.response.GuiThemeResponse; | ||
| import org.apache.cloudstack.context.CallContext; | ||
| import org.apache.cloudstack.gui.themes.GuiThemeVO; | ||
| import org.apache.cloudstack.gui.themes.GuiThemeService; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @APICommand(name = "createGuiTheme", description = "Creates a customized GUI theme for a set of Common Names (fixed or wildcard), a set of domain UUIDs, and/or a set of " + | ||
| "account UUIDs.", responseObject = GuiThemeResponse.class, entityType = {GuiThemeVO.class}, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, | ||
| since = "4.18.0.4-scclouds", authorized = {RoleType.Admin}) | ||
| public class CreateGuiThemeCmd extends BaseCmd { | ||
|
|
||
| @Inject | ||
| GuiThemeService guiThemeService; | ||
|
|
||
| @Parameter(name = ApiConstants.NAME, required = true, type = CommandType.STRING, length = 2048, description = "A name to identify the theme.") | ||
| private String name; | ||
|
|
||
| @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, length = 4096, description = "A description for the theme.") | ||
| private String description; | ||
|
|
||
| @Parameter(name = ApiConstants.CSS, type = CommandType.STRING, length = 65535, description = "The CSS to be retrieved and imported into the GUI " + | ||
| "when matching the theme access configurations.") | ||
| private String css; | ||
|
|
||
| @Parameter(name = ApiConstants.JSON_CONFIGURATION, type = CommandType.STRING, length = 65535, description = "The JSON with the configurations to be " + | ||
| "retrieved and imported into the GUI when matching the theme access configurations.") | ||
| private String jsonConfiguration; | ||
|
|
||
| @Parameter(name = ApiConstants.COMMON_NAMES, type = CommandType.STRING, length = 65535, description = "A set of Common Names (CN) (fixed or " + | ||
| "wildcard) separated by comma that can retrieve the theme; e.g.: *acme.com,acme2.com") | ||
| private String commonNames; | ||
|
|
||
| @Parameter(name = ApiConstants.DOMAIN_IDS, type = CommandType.STRING, length = 65535, description = "A set of domain UUIDs (also known as ID for " + | ||
| "the end-user) separated by comma that can retrieve the theme.") | ||
| private String domainIds; | ||
|
|
||
| @Parameter(name = ApiConstants.ACCOUNT_IDS, type = CommandType.STRING, length = 65535, description = "A set of account UUIDs (also known as ID for" + | ||
| " the end-user) separated by comma that can retrieve the theme.") | ||
| private String accountIds; | ||
|
|
||
| @Parameter(name = ApiConstants.IS_PUBLIC, type = CommandType.BOOLEAN, description = "Defines whether a theme can be retrieved by anyone when only " + | ||
| "the `commonNames` is informed. If the `domainIds` or `accountIds` is informed, it is considered as `false`.") | ||
| private Boolean isPublic = true; | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
|
||
| public String getCss() { | ||
| return css; | ||
| } | ||
|
|
||
| public String getJsonConfiguration() { | ||
| return jsonConfiguration; | ||
| } | ||
|
|
||
| public String getCommonNames() { | ||
| return commonNames; | ||
| } | ||
|
|
||
| public String getDomainIds() { | ||
| return domainIds; | ||
| } | ||
|
|
||
| public String getAccountIds() { | ||
| return accountIds; | ||
| } | ||
|
|
||
| public Boolean getPublic() { | ||
| return isPublic; | ||
| } | ||
|
|
||
| public void setIsPublic(Boolean isPublic) { | ||
| this.isPublic = isPublic; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| CallContext.current().setEventDetails(String.format("Name: %s, AccountIDs: %s, DomainIDs: %s, CommonNames: %s", getName(), getAccountIds(), getDomainIds(), getCommonNames())); | ||
| GuiThemeVO guiThemeVO = guiThemeService.createGuiTheme(this); | ||
|
|
||
| if (guiThemeVO == null) { | ||
| throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create the GUI theme."); | ||
| } | ||
|
|
||
| GuiThemeResponse response = _responseGenerator.createGuiThemeResponse(guiThemeVO); | ||
| response.setResponseName(getCommandName()); | ||
| this.setResponseObject(response); | ||
| } | ||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return CallContext.current().getCallingAccountId(); | ||
| } | ||
| } |
109 changes: 109 additions & 0 deletions
109
api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/ListGuiThemesCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package org.apache.cloudstack.api.command.user.gui.themes; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.BaseListCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.response.AccountResponse; | ||
| import org.apache.cloudstack.api.response.DomainResponse; | ||
| import org.apache.cloudstack.api.response.GuiThemeResponse; | ||
| import org.apache.cloudstack.api.response.ListResponse; | ||
| import org.apache.cloudstack.gui.themes.GuiThemeVO; | ||
| import org.apache.cloudstack.gui.themes.GuiThemeService; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @APICommand(name = "listGuiThemes", description = "Lists GUI themes.", responseObject = GuiThemeResponse.class, entityType = {GuiThemeVO.class}, | ||
| since = "4.18.0.4-scclouds", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin, RoleType.User, RoleType.DomainAdmin, RoleType.ResourceAdmin}) | ||
| public class ListGuiThemesCmd extends BaseListCmd { | ||
|
|
||
| @Inject | ||
| GuiThemeService guiThemeService; | ||
|
|
||
| @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The theme ID.", entityType = GuiThemeResponse.class) | ||
| private Long id; | ||
|
|
||
| @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "The name of the theme.") | ||
| private String name; | ||
|
|
||
| @Parameter(name = ApiConstants.COMMON_NAME, type = CommandType.STRING, description = "The internet Common Name (CN) to be filtered.") | ||
| private String commonName; | ||
|
|
||
| @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "The ID of the domain to be filtered.") | ||
| private Long domainId; | ||
|
|
||
| @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = "The ID of the account to be filtered.") | ||
| private Long accountId; | ||
|
|
||
| @Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "Whether to list all themes.") | ||
| private boolean listAll = false; | ||
|
|
||
| @Parameter(name = ApiConstants.SHOW_REMOVED, type = CommandType.BOOLEAN, description = "Whether to list removed themes.") | ||
| private boolean showRemoved = false; | ||
|
|
||
| @Parameter(name = ApiConstants.SHOW_PUBLIC, type = CommandType.BOOLEAN, description = "Whether to list public themes.") | ||
| private Boolean showPublic; | ||
|
|
||
| @Parameter(name = ApiConstants.LIST_ONLY_DEFAULT_THEME, type = CommandType.BOOLEAN, description = "Whether to only list the default theme.") | ||
| private boolean listOnlyDefaultTheme = false; | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public String getCommonName() { | ||
| return commonName; | ||
| } | ||
|
|
||
| public Long getDomainId() { | ||
| return domainId; | ||
| } | ||
|
|
||
| public Long getAccountId() { | ||
| return accountId; | ||
| } | ||
|
|
||
| public boolean getListAll() { | ||
| return listAll; | ||
| } | ||
|
|
||
| public boolean getShowRemoved() { | ||
| return showRemoved; | ||
| } | ||
|
|
||
| public Boolean getShowPublic() { | ||
| return showPublic; | ||
| } | ||
|
|
||
| public boolean getListOnlyDefaultTheme() { | ||
| return listOnlyDefaultTheme; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| ListResponse<GuiThemeResponse> response = guiThemeService.listGuiThemes(this); | ||
| response.setResponseName(getCommandName()); | ||
| this.setResponseObject(response); | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
api/src/main/java/org/apache/cloudstack/api/command/user/gui/themes/RemoveGuiThemeCmd.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package org.apache.cloudstack.api.command.user.gui.themes; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.BaseCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.response.GuiThemeResponse; | ||
| import org.apache.cloudstack.api.response.SuccessResponse; | ||
| import org.apache.cloudstack.context.CallContext; | ||
| import org.apache.cloudstack.gui.themes.GuiThemeVO; | ||
| import org.apache.cloudstack.gui.themes.GuiThemeService; | ||
|
|
||
| import javax.inject.Inject; | ||
|
|
||
| @APICommand(name = "removeGuiTheme", description = "Removes an existing GUI theme.", responseObject = GuiThemeResponse.class, entityType = {GuiThemeVO.class}, | ||
| since = "4.18.0.4-scclouds", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.Admin}) | ||
| public class RemoveGuiThemeCmd extends BaseCmd { | ||
|
|
||
| @Inject | ||
| GuiThemeService guiThemeService; | ||
|
|
||
| @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = GuiThemeResponse.class, required = true, | ||
| description = "The unique identifier of the GUI theme to be removed.") | ||
| private Long id; | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| CallContext.current().setEventDetails(String.format("ID: %s", getId())); | ||
| guiThemeService.removeGuiTheme(this); | ||
| final SuccessResponse response = new SuccessResponse(); | ||
| response.setResponseName(getCommandName()); | ||
| response.setSuccess(true); | ||
| setResponseObject(response); | ||
| } | ||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return CallContext.current().getCallingAccountId(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.