From 0376bc7cc176f23bbb615467b8b576dae658ecbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Fri, 13 Jun 2025 13:07:20 +0200 Subject: [PATCH] Fix license upload when already set by env variable (#30974) * Fix license upload when already set by env variable * Add tooltip * Fix tests and texts * Fix snapshots * Add disabled styles to secondary button --------- Co-authored-by: Mattermost Build --- .../license_settings.test.tsx.snap | 9 +++++ .../enterprise_edition_left_panel.test.tsx | 1 + .../enterprise_edition_left_panel.tsx | 35 +++++++++++++------ .../license_settings.test.tsx | 1 + .../license_settings/license_settings.tsx | 4 ++- webapp/channels/src/i18n/en.json | 1 + .../src/sass/components/_buttons.scss | 8 +++++ 7 files changed, 48 insertions(+), 11 deletions(-) diff --git a/webapp/channels/src/components/admin_console/license_settings/__snapshots__/license_settings.test.tsx.snap b/webapp/channels/src/components/admin_console/license_settings/__snapshots__/license_settings.test.tsx.snap index 1de52df271..4d76a4ee65 100644 --- a/webapp/channels/src/components/admin_console/license_settings/__snapshots__/license_settings.test.tsx.snap +++ b/webapp/channels/src/components/admin_console/license_settings/__snapshots__/license_settings.test.tsx.snap @@ -310,6 +310,7 @@ exports[`components/admin_console/license_settings/LicenseSettings should match handleChange={[Function]} handleRemove={[Function]} isDisabled={false} + isLicenseSetByEnvVar={false} isTrialLicense={false} license={ Object { @@ -461,6 +462,7 @@ exports[`components/admin_console/license_settings/LicenseSettings should match handleChange={[Function]} handleRemove={[Function]} isDisabled={false} + isLicenseSetByEnvVar={false} isTrialLicense={false} license={ Object { @@ -600,6 +602,7 @@ exports[`components/admin_console/license_settings/LicenseSettings should match handleChange={[Function]} handleRemove={[Function]} isDisabled={false} + isLicenseSetByEnvVar={false} isTrialLicense={false} license={ Object { @@ -739,6 +742,7 @@ exports[`components/admin_console/license_settings/LicenseSettings should match handleChange={[Function]} handleRemove={[Function]} isDisabled={false} + isLicenseSetByEnvVar={false} isTrialLicense={false} license={ Object { @@ -878,6 +882,7 @@ exports[`components/admin_console/license_settings/LicenseSettings should match handleChange={[Function]} handleRemove={[Function]} isDisabled={true} + isLicenseSetByEnvVar={false} isTrialLicense={false} license={ Object { @@ -1017,6 +1022,7 @@ exports[`components/admin_console/license_settings/LicenseSettings should match handleChange={[Function]} handleRemove={[Function]} isDisabled={false} + isLicenseSetByEnvVar={false} isTrialLicense={false} license={ Object { @@ -1146,6 +1152,7 @@ exports[`components/admin_console/license_settings/LicenseSettings should match handleChange={[Function]} handleRemove={[Function]} isDisabled={false} + isLicenseSetByEnvVar={false} isTrialLicense={true} license={ Object { @@ -1846,6 +1853,7 @@ exports[`components/admin_console/license_settings/LicenseSettings should match handleChange={[Function]} handleRemove={[Function]} isDisabled={false} + isLicenseSetByEnvVar={false} isTrialLicense={false} license={ Object { @@ -1987,6 +1995,7 @@ exports[`components/admin_console/license_settings/LicenseSettings should match handleChange={[Function]} handleRemove={[Function]} isDisabled={false} + isLicenseSetByEnvVar={false} isTrialLicense={false} license={ Object { diff --git a/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.test.tsx b/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.test.tsx index 5fc2fc8b04..56c572b70d 100644 --- a/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.test.tsx +++ b/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.test.tsx @@ -94,6 +94,7 @@ describe('components/admin_console/license_settings/enterprise_edition/enterpris handleChange: jest.fn(), fileInputRef: React.createRef(), statsActiveUsers: 1, + isLicenseSetByEnvVar: false, }; test('should format the Users field', () => { diff --git a/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.tsx b/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.tsx index cb9cef78e4..43afc6921c 100644 --- a/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.tsx +++ b/webapp/channels/src/components/admin_console/license_settings/enterprise_edition/enterprise_edition_left_panel.tsx @@ -4,7 +4,7 @@ import classNames from 'classnames'; import React, {useEffect, useState} from 'react'; import type {RefObject} from 'react'; -import {FormattedDate, FormattedMessage, FormattedNumber, FormattedTime, defineMessages, useIntl} from 'react-intl'; +import {FormattedDate, FormattedMessage, FormattedNumber, FormattedTime, defineMessage, defineMessages, useIntl} from 'react-intl'; import type {ClientLicense} from '@mattermost/types/config'; @@ -13,6 +13,7 @@ import {Client4} from 'mattermost-redux/client'; import useOpenPricingModal from 'components/common/hooks/useOpenPricingModal'; import useOpenSalesLink from 'components/common/hooks/useOpenSalesLink'; import Tag from 'components/widgets/tag/tag'; +import WithTooltip from 'components/with_tooltip'; import {FileTypes} from 'utils/constants'; import {calculateOverageUserActivated} from 'utils/overage_team'; @@ -35,6 +36,7 @@ export interface EnterpriseEditionProps { fileInputRef: RefObject; handleChange: () => void; statsActiveUsers: number; + isLicenseSetByEnvVar: boolean; } export const messages = defineMessages({ @@ -52,6 +54,7 @@ const EnterpriseEditionLeftPanel = ({ fileInputRef, handleChange, statsActiveUsers, + isLicenseSetByEnvVar, }: EnterpriseEditionProps) => { const {formatMessage} = useIntl(); const [unsanitizedLicense, setUnsanitizedLicense] = useState(license); @@ -148,6 +151,7 @@ const EnterpriseEditionLeftPanel = ({ handleChange, statsActiveUsers, expirationDays, + isLicenseSetByEnvVar, ) } @@ -245,6 +249,7 @@ const renderLicenseContent = ( handleChange: () => void, statsActiveUsers: number, expirationDays: number, + isLicenseSetByEnvVar: boolean, ) => { // Note: DO NOT LOCALISE THESE STRINGS. Legally we can not since the license is in English. @@ -284,7 +289,7 @@ const renderLicenseContent = (
{licenseValues.map(renderLicenseValues(statsActiveUsers, parseInt(license.Users, 10), expirationDays))}
- {renderAddNewLicenseButton(fileInputRef, handleChange)} + {renderAddNewLicenseButton(fileInputRef, handleChange, isLicenseSetByEnvVar)} {renderRemoveButton(handleRemove, isDisabled, removing)}
); @@ -293,18 +298,28 @@ const renderLicenseContent = ( const renderAddNewLicenseButton = ( fileInputRef: RefObject, handleChange: () => void, + isLicenseSetByEnvVar: boolean, ) => { return ( <> - + + { upgradedFromTE: false, enterpriseReady: true, totalUsers: 10, + environmentConfig: {}, isMySql: false, actions: { getLicenseConfig: jest.fn(), diff --git a/webapp/channels/src/components/admin_console/license_settings/license_settings.tsx b/webapp/channels/src/components/admin_console/license_settings/license_settings.tsx index abb846e797..2b6236a084 100644 --- a/webapp/channels/src/components/admin_console/license_settings/license_settings.tsx +++ b/webapp/channels/src/components/admin_console/license_settings/license_settings.tsx @@ -5,7 +5,7 @@ import React from 'react'; import {FormattedMessage, defineMessages} from 'react-intl'; import type {StatusOK} from '@mattermost/types/client4'; -import type {ClientLicense} from '@mattermost/types/config'; +import type {ClientLicense, EnvironmentConfig} from '@mattermost/types/config'; import type {ServerError} from '@mattermost/types/errors'; import type {ServerLimits} from '@mattermost/types/limits'; import type {GetFilteredUsersStatsOpts, UsersStats} from '@mattermost/types/users'; @@ -45,6 +45,7 @@ type Props = { totalUsers: number; isDisabled: boolean; prevTrialLicense: ClientLicense; + environmentConfig: Partial; isMySql: boolean; actions: { getLicenseConfig: () => void; @@ -321,6 +322,7 @@ export default class LicenseSettings extends React.PureComponent { fileInputRef={this.fileInputRef} handleChange={this.handleChange} statsActiveUsers={this.props.totalUsers || 0} + isLicenseSetByEnvVar={Boolean(this.props.environmentConfig?.ServiceSettings?.LicenseFileLocation)} /> ); diff --git a/webapp/channels/src/i18n/en.json b/webapp/channels/src/i18n/en.json index 5fb8f77121..86082e1dc3 100644 --- a/webapp/channels/src/i18n/en.json +++ b/webapp/channels/src/i18n/en.json @@ -1560,6 +1560,7 @@ "admin.license.renewalCard.reviewNumbers": "Review your numbers below to ensure you renew for the right number of users.", "admin.license.renewalCard.usersNumbers_active": "Active Users: ", "admin.license.renewalCard.usersNumbers_licensed": "Licensed Users: ", + "admin.license.setByEnvVar": "License location is set by environment variable", "admin.license.title": "Edition and License", "admin.license.Trial": "Trial", "admin.license.trial-request.accept-terms": "By clicking Start trial, I agree to the Mattermost Software and Services License Agreement, Privacy Policy, and receiving product emails.", diff --git a/webapp/channels/src/sass/components/_buttons.scss b/webapp/channels/src/sass/components/_buttons.scss index ad09537338..14050dd13a 100644 --- a/webapp/channels/src/sass/components/_buttons.scss +++ b/webapp/channels/src/sass/components/_buttons.scss @@ -269,6 +269,14 @@ button { } } + &:disabled, + &:disabled:hover, + &:disabled:active { + border-color: rgba(var(--center-channel-color-rgb), 0.32); + background: transparent; + color: rgba(var(--center-channel-color-rgb), 0.32) !important; + } + &:hover { background-color: rgb(var(--button-bg-rgb), 0.08); }