PromucFlow_constructor/app/client/src/pages/common/datasourceAuth/AuthMessage.tsx
Tanvi Bhakta 4fca7da51d
fix: ads-v2 fixes (#23543)
## Description

Notion Issues: 

1. Issues with link component:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=4121a76714cb49f2ba76d20fbeab9766&pm=s
2. GraphQL code editor heading color:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=82bbeaa2749642268eada28fcf5ec6a6&pm=s
3. tooltip on long JS Object names:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=353552b086de45329390bd4dfae98ee4&pm=s
4. Multiple scroll bars on response tab:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=111515d90ec5447687b1b573d64bd6eb&pm=s
5. Save and delete buttons:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=1ac1fed293994b51b4c31bc44dd2d736&pm=s
6. Js Objects always on tooltip:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=59f3e5b452d24ab9aa05e9fdd169113f&pm=s
7. Error message alignment:
https://www.notion.so/appsmith/f353d8c6bd664f79ad858a42010cdfc8?v=f04cde23f6424aeb9d5a6e389cd172bd&p=a6f2cc4e79994b77894c0293d50be3b9&pm=s
8. Max width of field on Admin settings page:
https://www.notion.so/appsmith/Text-boxes-too-small-in-Auth-Pages-ef2d0fb97f8247848113f9a419e3da09?pvs=4


Other issues:
1. Added data testid for branch create spinner.
7. Fix: branch name button have a fixed width even if text length is
small.


#### Type of change
- Bug fix (non-breaking change which fixes an issue)


## 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
- [ ] 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
- [ ] My code follows the style guidelines of this project
- [ ] 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
- [ ] 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/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#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

---------

Co-authored-by: Parthvi Goswami <parthvigoswami@Parthvis-MacBook-Pro.local>
Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com>
Co-authored-by: Preet Sidhu <preetsidhu.bits@gmail.com>
Co-authored-by: Ashok Kumar M <35134347+marks0351@users.noreply.github.com>
Co-authored-by: rahulramesha <rahul@appsmith.com>
Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
Co-authored-by: Vijetha-Kaja <vijetha@appsmith.com>
Co-authored-by: Apple <nandan@thinkify.io>
Co-authored-by: Arsalan Yaldram <arsalanyaldram0211@outlook.com>
Co-authored-by: albinAppsmith <87797149+albinAppsmith@users.noreply.github.com>
Co-authored-by: Aswath K <aswath.sana@gmail.com>
Co-authored-by: Ankita Kinger <ankita@appsmith.com>
Co-authored-by: Aman Agarwal <aman@appsmith.com>
Co-authored-by: Sangeeth Sivan <74818788+berzerkeer@users.noreply.github.com>
Co-authored-by: Saroj <43822041+sarojsarab@users.noreply.github.com>
Co-authored-by: Aishwarya-U-R <91450662+Aishwarya-U-R@users.noreply.github.com>
Co-authored-by: Parthvi <80334441+Parthvi12@users.noreply.github.com>
Co-authored-by: Vijetha-Kaja <119562824+Vijetha-Kaja@users.noreply.github.com>
Co-authored-by: Ayush Pahwa <ayushpahwa96@gmail.com>
Co-authored-by: Rohit Agarwal <rohit_agarwal@live.in>
2023-05-29 13:40:41 +08:00

98 lines
2.9 KiB
TypeScript

import type { AppState } from "@appsmith/reducers";
import { redirectAuthorizationCode } from "actions/datasourceActions";
import type { CalloutKind } from "design-system";
import { Callout } from "design-system";
import type { Datasource } from "entities/Datasource";
import { ActionType } from "entities/Datasource";
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { getPluginTypeFromDatasourceId } from "selectors/entitiesSelector";
import styled from "styled-components";
import {
setGlobalSearchQuery,
toggleShowGlobalSearchModal,
} from "actions/globalSearchActions";
import AnalyticsUtil from "utils/AnalyticsUtil";
import {
GOOGLE_SHEETS_AUTHORIZE_DATASOURCE,
GOOGLE_SHEETS_LEARN_MORE,
createMessage,
} from "@appsmith/constants/messages";
const StyledAuthMessage = styled.div<{ isInViewMode: boolean }>`
width: fit-content;
${(props) =>
!props.isInViewMode &&
`margin-top: var(--ads-v2-spaces-5);margin-bottom: var(--ads-v2-spaces-4);`}
`;
type AuthMessageProps = {
// We can handle for other action types as well eg. save, delete etc.
actionType?: string;
datasource: Datasource;
description: string;
pageId?: string;
style?: any;
calloutType?: CalloutKind;
isInViewMode?: boolean;
};
export default function AuthMessage(props: AuthMessageProps) {
const {
actionType,
calloutType = "error",
datasource,
description,
pageId,
style = {},
isInViewMode = false,
} = props;
const dispatch = useDispatch();
const pluginType = useSelector((state: AppState) =>
getPluginTypeFromDatasourceId(state, datasource.id),
);
const handleOauthAuthorization: any = (e: React.MouseEvent) => {
e.preventDefault();
if (!pluginType || !pageId) return;
dispatch(redirectAuthorizationCode(pageId, datasource.id, pluginType));
};
const handleDocumentationClick: any = (e: React.MouseEvent) => {
e.stopPropagation();
e.preventDefault();
const query = "Google Sheets";
dispatch(setGlobalSearchQuery(query));
dispatch(toggleShowGlobalSearchModal());
AnalyticsUtil.logEvent("OPEN_OMNIBAR", {
source: "DATASOURCE_DOCUMENTATION_CLICK",
query,
});
};
return (
<StyledAuthMessage isInViewMode={isInViewMode} style={style}>
<Callout
kind={calloutType}
links={
actionType === ActionType.AUTHORIZE
? [
{
children: createMessage(GOOGLE_SHEETS_AUTHORIZE_DATASOURCE),
onClick: handleOauthAuthorization,
},
]
: actionType === ActionType.DOCUMENTATION
? [
{
children: createMessage(GOOGLE_SHEETS_LEARN_MORE),
onClick: handleDocumentationClick,
},
]
: undefined
}
>
{description}
</Callout>
</StyledAuthMessage>
);
}