PromucFlow_constructor/app/client/src/pages/Editor/ToggleModeButton.tsx
albinAppsmith ced4ffa179
fix: Remove guided tour code (#30387)
## Description

Removed the guided tour code.

#### PR fixes following issue(s)
Fixes https://github.com/appsmithorg/appsmith/issues/30332

#### Type of change

- Bug fix (non-breaking change which fixes an issue)
- Chore (housekeeping or task changes that don't impact user perception)

## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [ ] Manual
- [ ] JUnit
- [ ] Jest
- [ ] Cypress
>
>
#### Test Plan
> Add Testsmith test cases links that relate to this PR
>
>
#### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
>
>
>
## Checklist:
#### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Chores**
  - Streamlined onboarding process by removing guided tour features.
- Refined action and message management for a more intuitive user
experience.
  - Enhanced property controls generation for better user interaction.

- **Refactor**
- Simplified various components by removing unnecessary guided tour
logic.
  - Improved application and page sagas for more efficient operation.
  - Refined editor components for a smoother user interface.

- **Documentation**
  - Updated message constants for clearer user guidance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-01-24 16:31:21 +05:30

53 lines
1.6 KiB
TypeScript

import React, { useCallback } from "react";
import { useDispatch, useSelector } from "react-redux";
import { Tooltip, ToggleButton } from "design-system";
import type { AppState } from "@appsmith/reducers";
import { APP_MODE } from "entities/App";
import { getAppMode } from "@appsmith/selectors/applicationSelectors";
import { setPreviewModeInitAction } from "actions/editorActions";
import { previewModeSelector } from "selectors/editorSelectors";
import { createMessage, EDITOR_HEADER } from "@appsmith/constants/messages";
function ToggleModeButton() {
const dispatch = useDispatch();
const isPreviewMode = useSelector(previewModeSelector);
const appMode = useSelector(getAppMode);
const mode = useSelector((state: AppState) => state.entities.app.mode);
const isViewMode = mode === APP_MODE.PUBLISHED;
const onClickPreviewModeButton = useCallback(() => {
dispatch(setPreviewModeInitAction(!isPreviewMode));
}, [dispatch, setPreviewModeInitAction, isPreviewMode]);
if (isViewMode) return null;
return (
<Tooltip
content={
<>
{createMessage(EDITOR_HEADER.previewTooltip.text)}
<span style={{ marginLeft: 20 }}>
{createMessage(EDITOR_HEADER.previewTooltip.shortcut)}
</span>
</>
}
isDisabled={appMode !== APP_MODE.EDIT}
placement="bottom"
>
<ToggleButton
data-testid={`${isPreviewMode ? "preview" : "edit"}-mode`}
icon="play-line"
isSelected={isPreviewMode}
onClick={onClickPreviewModeButton}
size="md"
/>
</Tooltip>
);
}
export default ToggleModeButton;