*/
import * as React from 'react';
import ProjectKeyInput from '../../components/common/ProjectKeyInput';
-import { Button, SubmitButton } from '../../components/controls/buttons';
import ConfirmButton from '../../components/controls/ConfirmButton';
+import { Button, SubmitButton } from '../../components/controls/buttons';
import MandatoryFieldsExplanation from '../../components/ui/MandatoryFieldsExplanation';
import { translate, translateWithParameters } from '../../helpers/l10n';
import { validateProjectKey } from '../../helpers/projects';
export default function UpdateForm(props: UpdateFormProps) {
const { component } = props;
- const [newKey, setNewKey] = React.useState<string | undefined>(undefined);
- const value = newKey !== undefined ? newKey : component.key;
- const hasChanged = value !== component.key;
+ const [newKey, setNewKey] = React.useState(component.key);
+ const hasChanged = newKey !== component.key;
- const validationResult = validateProjectKey(value);
+ const validationResult = validateProjectKey(newKey);
const error =
validationResult === ProjectKeyValidationResult.Valid
? undefined
}}
touched={hasChanged}
placeholder={translate('update_key.new_key')}
- projectKey={value}
+ projectKey={newKey}
autofocus
/>
disabled={!hasChanged}
id="update-key-reset"
onClick={() => {
- setNewKey(undefined);
+ setNewKey(component.key);
}}
type="reset"
>
minLength={2}
onChange={this.handleSearch}
placeholder={translate('projects.search')}
- value={this.props.query.search || ''}
+ value={this.props.query.search ?? ''}
/>
</div>
);
{visibilityForm && (
<ChangeDefaultVisibilityForm
- defaultVisibility={defaultProjectVisibility || Visibility.Public}
+ defaultVisibility={defaultProjectVisibility ?? Visibility.Public}
onClose={this.closeVisiblityForm}
onConfirm={this.props.onChangeDefaultProjectVisibility}
/>
import { translate, translateWithParameters } from '../../helpers/l10n';
import { formatMeasure } from '../../helpers/measures';
import { ParsedAnalysis, Serie } from '../../types/project-activity';
-import { Button } from '../controls/buttons';
import Modal from '../controls/Modal';
+import { Button } from '../controls/buttons';
import DateFormatter from '../intl/DateFormatter';
import TimeFormatter from '../intl/TimeFormatter';
import { Alert } from '../ui/Alert';
</td>
{metrics.map((metric) => (
<td key={metric} className="thin nowrap">
- {values[metric] || '-'}
+ {values[metric] ?? '-'}
</td>
))}
<td>
selectedDate={this.state.selectedDate}
series={graphSeries}
graphDescription={
- ariaLabel ||
+ ariaLabel ??
translateWithParameters(
'project_activity.graphs.explanation_x',
uniqBy(graphSeries, 'name')
WrappedComponent: React.ComponentType<P>,
hocName: string
) {
- const wrappedDisplayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
+ const wrappedDisplayName = WrappedComponent.displayName ?? WrappedComponent.name ?? 'Component';
return `${hocName}(${wrappedDisplayName})`;
}
import { generateToken, getTokens, revokeToken } from '../../../api/user-tokens';
import { translate } from '../../../helpers/l10n';
import {
- computeTokenExpirationDate,
EXPIRATION_OPTIONS,
+ computeTokenExpirationDate,
getAvailableExpirationOptions,
} from '../../../helpers/tokens';
import { TokenExpiration, TokenType, UserToken } from '../../../types/token';
import { LoggedInUser } from '../../../types/users';
import DocumentationTooltip from '../../common/DocumentationTooltip';
import Link from '../../common/Link';
-import { Button, DeleteButton, SubmitButton } from '../../controls/buttons';
import Radio from '../../controls/Radio';
import Select from '../../controls/Select';
+import { Button, DeleteButton, SubmitButton } from '../../controls/buttons';
import AlertErrorIcon from '../../icons/AlertErrorIcon';
import AlertSuccessIcon from '../../icons/AlertSuccessIcon';
import ProjectTokenScopeInfo from '../components/ProjectTokenScopeInfo';
canContinue = () => {
const { existingToken, selection, token } = this.state;
- const validExistingToken = existingToken.match(TOKEN_FORMAT_REGEX) != null;
+ const validExistingToken = TOKEN_FORMAT_REGEX.exec(existingToken) != null;
return (
(selection === 'generate' && token != null) ||
(selection === 'use-existing' && existingToken && validExistingToken)
onChange={this.handleTokenNameChange}
required
type="text"
- value={tokenName || ''}
+ value={tokenName ?? ''}
/>
</div>
<div className="display-flex-column spacer-left big-spacer-right">
renderUseExistingOption = () => {
const { existingToken } = this.state;
- const validInput = !existingToken || existingToken.match(TOKEN_FORMAT_REGEX) != null;
+ const validInput = !existingToken || TOKEN_FORMAT_REGEX.exec(existingToken) != null;
return (
<div className="big-spacer-top">