From 621a01ba3b2b17632df8a68f5c5b97fe97929bc2 Mon Sep 17 00:00:00 2001 From: matias-portainer <104775949+matias-portainer@users.noreply.github.com> Date: Mon, 13 Mar 2023 09:01:27 -0300 Subject: [PATCH] fix(upgrade): remove yellow upgrade banner EE-5141 (#8640) --- api/datastore/test_data/output_24_to_latest.json | 6 ++---- api/http/handler/users/user_update.go | 10 ++-------- api/portainer.go | 2 -- .../components/theme/theme-settings.controller.js | 10 ---------- app/portainer/components/theme/theme-settings.html | 10 ---------- app/portainer/users/types.ts | 1 - app/react-tools/test-mocks.ts | 1 - .../UsersSelector/UsersSelector.mocks.ts | 1 - .../CreateTeamForm/CreateTeamForm.mocks.ts | 2 -- .../sidebar/UpgradeBEBanner/UpgradeBEBanner.tsx | 14 ++------------ app/react/test-utils/withUserProvider.tsx | 1 - 11 files changed, 6 insertions(+), 52 deletions(-) diff --git a/api/datastore/test_data/output_24_to_latest.json b/api/datastore/test_data/output_24_to_latest.json index be2d36f8d..6b0b59c70 100644 --- a/api/datastore/test_data/output_24_to_latest.json +++ b/api/datastore/test_data/output_24_to_latest.json @@ -905,8 +905,7 @@ }, "Role": 1, "ThemeSettings": { - "color": "", - "subtleUpgradeButton": false + "color": "" }, "TokenIssueAt": 0, "UserTheme": "", @@ -936,8 +935,7 @@ }, "Role": 1, "ThemeSettings": { - "color": "", - "subtleUpgradeButton": false + "color": "" }, "TokenIssueAt": 0, "UserTheme": "", diff --git a/api/http/handler/users/user_update.go b/api/http/handler/users/user_update.go index 43d8b4dab..844f38806 100644 --- a/api/http/handler/users/user_update.go +++ b/api/http/handler/users/user_update.go @@ -18,8 +18,6 @@ import ( type themePayload struct { // Color represents the color theme of the UI Color *string `json:"color" example:"dark" enums:"dark,light,highcontrast,auto"` - // SubtleUpgradeButton indicates if the upgrade banner should be displayed in a subtle way - SubtleUpgradeButton *bool `json:"subtleUpgradeButton" example:"false"` } type userUpdatePayload struct { @@ -33,11 +31,11 @@ type userUpdatePayload struct { func (payload *userUpdatePayload) Validate(r *http.Request) error { if govalidator.Contains(payload.Username, " ") { - return errors.New("Invalid username. Must not contain any whitespace") + return errors.New("invalid username. Must not contain any whitespace") } if payload.Role != 0 && payload.Role != 1 && payload.Role != 2 { - return errors.New("Invalid role value. Value must be one of: 1 (administrator) or 2 (regular user)") + return errors.New("invalid role value. Value must be one of: 1 (administrator) or 2 (regular user)") } return nil } @@ -120,10 +118,6 @@ func (handler *Handler) userUpdate(w http.ResponseWriter, r *http.Request) *http if payload.Theme.Color != nil { user.ThemeSettings.Color = *payload.Theme.Color } - - if payload.Theme.SubtleUpgradeButton != nil { - user.ThemeSettings.SubtleUpgradeButton = *payload.Theme.SubtleUpgradeButton - } } if payload.Role != 0 { diff --git a/api/portainer.go b/api/portainer.go index e6ed05361..f4133047d 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -1286,8 +1286,6 @@ type ( UserThemeSettings struct { // Color represents the color theme of the UI Color string `json:"color" example:"dark" enums:"dark,light,highcontrast,auto"` - // SubtleUpgradeButton indicates if the upgrade banner should be displayed in a subtle way - SubtleUpgradeButton bool `json:"subtleUpgradeButton"` } // Webhook represents a url webhook that can be used to update a service diff --git a/app/portainer/components/theme/theme-settings.controller.js b/app/portainer/components/theme/theme-settings.controller.js index 3c6bb47eb..c0d5b9922 100644 --- a/app/portainer/components/theme/theme-settings.controller.js +++ b/app/portainer/components/theme/theme-settings.controller.js @@ -13,7 +13,6 @@ export default class ThemeSettingsController { this.UserService = UserService; this.setThemeColor = this.setThemeColor.bind(this); - this.setSubtleUpgradeButton = this.setSubtleUpgradeButton.bind(this); } async setThemeColor(color) { @@ -29,13 +28,6 @@ export default class ThemeSettingsController { }); } - async setSubtleUpgradeButton(value) { - return this.$async(async () => { - this.state.subtleUpgradeButton = value; - this.updateThemeSettings({ subtleUpgradeButton: value }); - }); - } - async updateThemeSettings(theme) { try { if (!this.state.isDemo) { @@ -57,7 +49,6 @@ export default class ThemeSettingsController { userId: null, themeColor: 'auto', isDemo: state.application.demoEnvironment.enabled, - subtleUpgradeButton: false, }; this.state.availableThemes = options; @@ -67,7 +58,6 @@ export default class ThemeSettingsController { const user = await this.UserService.user(this.state.userId); this.state.themeColor = user.ThemeSettings.color || this.state.themeColor; - this.state.subtleUpgradeButton = !!user.ThemeSettings.subtleUpgradeButton; } catch (err) { notifyError('Failure', err, 'Unable to get user details'); } diff --git a/app/portainer/components/theme/theme-settings.html b/app/portainer/components/theme/theme-settings.html index e3fa245e8..58f2dc752 100644 --- a/app/portainer/components/theme/theme-settings.html +++ b/app/portainer/components/theme/theme-settings.html @@ -9,16 +9,6 @@ Dark and High-contrast theme are experimental. Some UI components might not display properly.

- -
- -
diff --git a/app/portainer/users/types.ts b/app/portainer/users/types.ts index 5b5a9ecf4..4b47362b8 100644 --- a/app/portainer/users/types.ts +++ b/app/portainer/users/types.ts @@ -22,6 +22,5 @@ export type User = { }; ThemeSettings: { color: 'dark' | 'light' | 'highcontrast' | 'auto'; - subtleUpgradeButton: boolean; }; }; diff --git a/app/react-tools/test-mocks.ts b/app/react-tools/test-mocks.ts index fc8d3fe39..6efc2bb0b 100644 --- a/app/react-tools/test-mocks.ts +++ b/app/react-tools/test-mocks.ts @@ -19,7 +19,6 @@ export function createMockUsers( PortainerAuthorizations: {}, ThemeSettings: { color: 'auto', - subtleUpgradeButton: false, }, })); } diff --git a/app/react/components/UsersSelector/UsersSelector.mocks.ts b/app/react/components/UsersSelector/UsersSelector.mocks.ts index 2ebc35b7f..a245054e3 100644 --- a/app/react/components/UsersSelector/UsersSelector.mocks.ts +++ b/app/react/components/UsersSelector/UsersSelector.mocks.ts @@ -26,7 +26,6 @@ export function createMockUser(id: number, username: string): UserViewModel { AuthenticationMethod: '', ThemeSettings: { color: 'auto', - subtleUpgradeButton: false, }, }; } diff --git a/app/react/portainer/users/teams/ListView/CreateTeamForm/CreateTeamForm.mocks.ts b/app/react/portainer/users/teams/ListView/CreateTeamForm/CreateTeamForm.mocks.ts index e2e196cea..aa599082d 100644 --- a/app/react/portainer/users/teams/ListView/CreateTeamForm/CreateTeamForm.mocks.ts +++ b/app/react/portainer/users/teams/ListView/CreateTeamForm/CreateTeamForm.mocks.ts @@ -22,7 +22,6 @@ export function mockExampleData() { Role: 2, ThemeSettings: { color: 'auto', - subtleUpgradeButton: false, }, EndpointAuthorizations: {}, PortainerAuthorizations: { @@ -50,7 +49,6 @@ export function mockExampleData() { Role: 2, ThemeSettings: { color: 'auto', - subtleUpgradeButton: false, }, EndpointAuthorizations: {}, PortainerAuthorizations: { diff --git a/app/react/sidebar/UpgradeBEBanner/UpgradeBEBanner.tsx b/app/react/sidebar/UpgradeBEBanner/UpgradeBEBanner.tsx index 132a8e398..17ada31dd 100644 --- a/app/react/sidebar/UpgradeBEBanner/UpgradeBEBanner.tsx +++ b/app/react/sidebar/UpgradeBEBanner/UpgradeBEBanner.tsx @@ -65,19 +65,13 @@ function UpgradeBEBanner() { return null; } - const subtleButton = userQuery.data.ThemeSettings.subtleUpgradeButton; - return ( <>