/*
* SonarQube
* Copyright (C) 2009-2021 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
import GlobalMessagesContainer from '../../app/components/GlobalMessagesContainer';
import { Location } from '../../components/hoc/withRouter';
import { SubmitButton } from '../../sonar-ui-common/components/controls/buttons';
import { Alert } from '../../sonar-ui-common/components/ui/Alert';
import MandatoryFieldMarker from '../../sonar-ui-common/components/ui/MandatoryFieldMarker';
import MandatoryFieldsExplanation from '../../sonar-ui-common/components/ui/MandatoryFieldsExplanation';
import { translate } from '../../sonar-ui-common/helpers/l10n';
import { getReturnUrl } from '../../sonar-ui-common/helpers/urls';
import Unauthorized from '../sessions/components/Unauthorized';
import { DEFAULT_ADMIN_PASSWORD } from './constants';
export interface ChangeAdminPasswordAppRendererProps {
passwordValue: string;
confirmPasswordValue: string;
onConfirmPasswordChange: (password: string) => void;
onPasswordChange: (password: string) => void;
onSubmit: () => void;
canAdmin?: boolean;
canSubmit?: boolean;
submitting: boolean;
success: boolean;
location: Location;
}
export default function ChangeAdminPasswordAppRenderer(props: ChangeAdminPasswordAppRendererProps) {
const {
canAdmin,
canSubmit,
confirmPasswordValue,
passwordValue,
location,
submitting,
success
} = props;
if (!canAdmin) {
return
{translate('users.change_admin_password.form.success')}
{/* We must not use Link here, because we need a refresh of the /api/navigation/global call. */} {translate('users.change_admin_password.form.continue_to_app')}{translate('users.change_admin_password.header')}
{translate('users.change_admin_password.description')}
> )}