* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { Link } from '@sonarsource/echoes-react';
+import { Button, Link, Modal } from '@sonarsource/echoes-react';
import { FormattedMessage } from 'react-intl';
-import { Modal } from '~design-system';
import { translate } from '../../helpers/l10n';
interface Props {
+ isOpen?: boolean;
onClose: () => void;
}
-export default function LicensePromptModal({ onClose }: Readonly<Props>) {
+export default function LicensePromptModal({ isOpen, onClose }: Readonly<Props>) {
return (
<Modal
- body={
+ isOpen={isOpen ?? false}
+ content={
<FormattedMessage
defaultMessage={translate('license.prompt.description')}
id="license.prompt.description"
}}
/>
}
- headerTitle={translate('license.prompt.title')}
- onClose={onClose}
- secondaryButtonLabel={translate('cancel')}
+ onOpenChange={(open) => !open && onClose()}
+ title={translate('license.prompt.title')}
+ secondaryButton={<Button onClick={onClose}>{translate('cancel')}</Button>}
/>
);
}
*/
import { Button, ButtonVariety, Modal, ModalSize } from '@sonarsource/echoes-react';
-import { useContext, useEffect, useState } from 'react';
+import { debounce } from 'lodash';
+import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
import { useIntl } from 'react-intl';
import { CallBackProps } from 'react-joyride';
import { SpotlightTour, SpotlightTourStep } from '~design-system';
const [step, setStep] = useState(1);
const [runManually, setRunManually] = useState(false);
+ const dismissedTour = currentUser.dismissedNotices[NoticeType.MODE_TOUR];
+
const nextStep = () => {
if (step === MAX_STEPS) {
document.dispatchEvent(new CustomEvent(CustomEvents.OpenHelpMenu));
}
};
- const dismissTour = () => {
+ const dismissTourWithDebounce = useMemo(
+ () =>
+ debounce(() => {
+ dismissNotice(NoticeType.MODE_TOUR)
+ .then(() => {
+ updateDismissedNotices(NoticeType.MODE_TOUR, true);
+ })
+ .catch(() => {
+ /* noop */
+ });
+ }, 500),
+ [updateDismissedNotices],
+ );
+
+ const dismissTour = useCallback(() => {
document.dispatchEvent(new CustomEvent(CustomEvents.CloseHelpMenu));
setStep(6);
- dismissNotice(NoticeType.MODE_TOUR)
- .then(() => {
- updateDismissedNotices(NoticeType.MODE_TOUR, true);
- })
- .catch(() => {
- /* noop */
- });
- };
+ if (!dismissedTour) {
+ dismissTourWithDebounce();
+ }
+ }, [dismissedTour, dismissTourWithDebounce]);
const onToggle = (props: CallBackProps) => {
switch (props.action) {
const isAdmin = currentUser.permissions?.global.includes(Permissions.Admin);
const isAdminOrQGAdmin =
isAdmin || currentUser.permissions?.global.includes(Permissions.QualityGateAdmin);
- const dismissedTour = currentUser.dismissedNotices[NoticeType.MODE_TOUR];
useEffect(() => {
if (currentUser.isLoggedIn && !isAdminOrQGAdmin && !dismissedTour) {
dismissTour();
}
- }, [currentUser.isLoggedIn, isAdminOrQGAdmin, dismissedTour]);
+ }, [currentUser.isLoggedIn, isAdminOrQGAdmin, dismissedTour, dismissTour]);
if (!runManually && (currentUser.dismissedNotices[NoticeType.MODE_TOUR] || !isAdminOrQGAdmin)) {
return null;
steps={steps}
run={step > maxModalSteps}
continuous
- disableOverlay={step === 5}
+ disableOverlay={false}
showProgress={step !== 5}
stepIndex={step - maxModalSteps - 1}
nextLabel={intl.formatMessage({ id: 'next' })}
settings.mode.save=Save the mode. The current mode will be switched to {isStandardMode, select, true {Standard Experience} other {Multi-Quality Rule Mode}}
settings.mode.save.success=This instance is now in {isStandardMode, select, true {Standard Experience} other {Multi-Quality Rule Mode}}.
-mode.standard.advertisement=Looking for Bugs, Vulnerabilities, or Code Smells? If your team prefers working with these types, change it in the <a>settings</a>
-mode.mqr.advertisement=Looking for Security, Reliability, and Maintainability issues? If your team prefers working with software qualities, change it in the <a>settings</a>
+mode.standard.advertisement=Looking for Security, Reliability, and Maintainability issues? If your team prefers working with software qualities, change it in the <a>settings</a>
+mode.mqr.advertisement=Looking for Bugs, Vulnerabilities, or Code Smells? If your team prefers working with these types, change it in the <a>settings</a>
settings.mode.mqr.advertisement=If your team prefers working with Vulnerabilities, Bugs, and Code Smells, change it in the <a>Mode section</a> of General Settings
settings.mode.standard.advertisement=If your team prefers working with Security, Reliability, and Maintainability issues, change it in the <a>Mode section</a> of General Settings