Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into chore/add-faro-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
dvj1988 committed Dec 25, 2024
2 parents 46a6c29 + f078ec0 commit c9d4264
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 24 deletions.
11 changes: 11 additions & 0 deletions app/client/src/constants/PremiumDatasourcesConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,18 @@ export const PREMIUM_INTEGRATIONS: PremiumIntegration[] = [
name: "Salesforce",
icon: getAssetUrl(`${ASSETS_CDN_URL}/salesforce-icon.png`),
},
{
name: "Slack",
icon: getAssetUrl(`${ASSETS_CDN_URL}/slack.png`),
},
{
name: "Jira",
icon: getAssetUrl(`${ASSETS_CDN_URL}/jira.png`),
},
];

export const PREMIUM_INTEGRATION_CONTACT_FORM =
"PREMIUM_INTEGRATION_CONTACT_FORM";

export const SCHEDULE_CALL_URL =
"https://calendly.com/carina-neves-fonseca/appsmith";
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ function CreateNewDatasource({
active,
isCreating,
isOnboardingScreen,
isPremiumDatasourcesViewEnabled,
pageId,
showMostPopularPlugins,
showUnsupportedPluginDialog, // TODO: Fix this the next time the file is edited
Expand Down Expand Up @@ -172,18 +171,15 @@ function CreateNewDatasource({
parentEntityType={parentEntityType}
showMostPopularPlugins={showMostPopularPlugins}
showUnsupportedPluginDialog={showUnsupportedPluginDialog}
>
{showMostPopularPlugins && isPremiumDatasourcesViewEnabled && (
<PremiumDatasources />
)}
</NewQueryScreen>
/>
</div>
);
}

function CreateNewSaasIntegration({
active,
isCreating,
isPremiumDatasourcesViewEnabled,
pageId,
showUnsupportedPluginDialog, // TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -217,7 +213,9 @@ function CreateNewSaasIntegration({
pageId={pageId}
showSaasAPIs
showUnsupportedPluginDialog={showUnsupportedPluginDialog}
/>
>
{isPremiumDatasourcesViewEnabled && <PremiumDatasources />}
</NewApiScreen>
</div>
</>
) : null;
Expand Down Expand Up @@ -321,7 +319,6 @@ class CreateNewDatasourceTab extends React.Component<
active={false}
isCreating={isCreating}
isOnboardingScreen={!!isOnboardingScreen}
isPremiumDatasourcesViewEnabled={isPremiumDatasourcesViewEnabled}
location={location}
pageId={pageId}
showMostPopularPlugins
Expand All @@ -347,6 +344,7 @@ class CreateNewDatasourceTab extends React.Component<
<CreateNewSaasIntegration
active={false}
isCreating={isCreating}
isPremiumDatasourcesViewEnabled={isPremiumDatasourcesViewEnabled}
location={location}
pageId={pageId}
showUnsupportedPluginDialog={this.showUnsupportedPluginDialog}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ class DatasourceHomeScreen extends React.Component<Props> {
</DatasourceCard>
);
})}
{this.props.children}
</DatasourceCardsContainer>
</DatasourceHomePage>
);
Expand Down
4 changes: 3 additions & 1 deletion app/client/src/pages/Editor/IntegrationEditor/NewApi.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useEffect, useState, type ReactNode } from "react";
import { connect, useSelector } from "react-redux";
import styled from "styled-components";
import {
Expand Down Expand Up @@ -142,6 +142,7 @@ interface ApiHomeScreenProps {
apiType: string,
) => void;
isOnboardingScreen?: boolean;
children?: ReactNode;
}

type Props = ApiHomeScreenProps;
Expand Down Expand Up @@ -328,6 +329,7 @@ function NewApiScreen(props: Props) {
</CardContentWrapper>
</ApiCard>
))}
{props.children}
</ApiCardsContainer>
</StyledContainer>
);
Expand Down
4 changes: 1 addition & 3 deletions app/client/src/pages/Editor/IntegrationEditor/NewQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ class QueryHomeScreen extends React.Component<QueryHomeScreenProps> {
parentEntityType={parentEntityType}
showMostPopularPlugins={showMostPopularPlugins}
showUnsupportedPluginDialog={showUnsupportedPluginDialog}
>
{this.props.children}
</DataSourceHome>
/>
</QueryHomePage>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Flex, ModalHeader, Text, toast } from "@appsmith/ads";
import { Button, ModalFooter, ModalHeader, Text, toast } from "@appsmith/ads";
import { createMessage, PREMIUM_DATASOURCES } from "ee/constants/messages";
import type { AppState } from "ee/reducers";
import React, { useCallback } from "react";
Expand Down Expand Up @@ -97,7 +97,7 @@ const PremiumDatasourceContactForm = (
size="md"
type="email"
/>
<Flex gap="spaces-7" justifyContent="flex-end" marginTop="spaces-3">
<ModalFooter>
{shouldLearnMoreButtonBeVisible(!isFreePlanInstance) && (
<Button
aria-label="Learn more"
Expand All @@ -114,7 +114,7 @@ const PremiumDatasourceContactForm = (
!isFreePlanInstance,
)}
</Button>
</Flex>
</ModalFooter>
</FormWrapper>
</>
);
Expand Down
10 changes: 10 additions & 0 deletions app/client/src/utils/PremiumDatasourcesHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SCHEDULE_CALL_URL } from "constants/PremiumDatasourcesConstants";
import { createMessage, PREMIUM_DATASOURCES } from "ee/constants/messages";
import AnalyticsUtil from "ee/utils/AnalyticsUtil";
import { isRelevantEmail } from "utils/formhelpers";
Expand Down Expand Up @@ -58,6 +59,15 @@ export const handleSubmitEvent = (
email,
},
);

const scheduleACallUrl =
!isBusinessOrEnterprise && validRelevantEmail
? `${SCHEDULE_CALL_URL}?email=${email}`
: "";

if (scheduleACallUrl) {
window.open(scheduleACallUrl, "_blank");
}
};

export const getContactFormModalTitle = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ private Mono<User> checkAndCreateUser(OAuth2User oAuth2User, OAuth2UserRequest u

String username = oAuth2User.getName();

return repository
.findByEmail(username)
.switchIfEmpty(repository.findFirstByEmailIgnoreCaseOrderByCreatedAtDesc(username))
return this.findByUsername(username)
.switchIfEmpty(Mono.defer(() -> {
User newUser = new User();
newUser.setName(oAuth2User.getName());
Expand All @@ -76,4 +74,10 @@ private Mono<User> checkAndCreateUser(OAuth2User oAuth2User, OAuth2UserRequest u
error -> new AppsmithOAuth2AuthenticationException(
new OAuth2Error(error.getAppErrorCode().toString(), error.getMessage(), "")));
}

protected Mono<User> findByUsername(String email) {
return repository
.findByEmail(email)
.switchIfEmpty(repository.findFirstByEmailIgnoreCaseOrderByCreatedAtDesc(email));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ public Mono<User> checkAndCreateUser(OidcUser oidcUser, OidcUserRequest userRequ

String username = (!StringUtils.isEmpty(oidcUser.getEmail())) ? oidcUser.getEmail() : oidcUser.getName();

return repository
.findByEmail(username)
.switchIfEmpty(repository.findFirstByEmailIgnoreCaseOrderByCreatedAtDesc(username))
return this.findByUsername(username)
.switchIfEmpty(Mono.defer(() -> {
User newUser = new User();
if (oidcUser.getUserInfo() != null) {
Expand Down Expand Up @@ -82,4 +80,10 @@ public Mono<User> checkAndCreateUser(OidcUser oidcUser, OidcUserRequest userRequ
error -> new AppsmithOAuth2AuthenticationException(
new OAuth2Error(error.getAppErrorCode().toString(), error.getMessage(), "")));
}

protected Mono<User> findByUsername(String email) {
return repository
.findByEmail(email)
.switchIfEmpty(repository.findFirstByEmailIgnoreCaseOrderByCreatedAtDesc(email));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.springframework.data.mongodb.core.query.UpdateDefinition;
import reactor.core.publisher.Mono;

import java.util.Set;

public interface CustomUserRepositoryCE extends AppsmithRepository<User> {

Mono<User> findByEmail(String email, AclPermission aclPermission);
Expand All @@ -14,5 +16,7 @@ public interface CustomUserRepositoryCE extends AppsmithRepository<User> {

Mono<Boolean> isUsersEmpty();

Set<String> getSystemGeneratedUserEmails();

Mono<Integer> updateById(String id, UpdateDefinition updateObj);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public Mono<Boolean> isUsersEmpty() {
.map(count -> count == 0);
}

protected Set<String> getSystemGeneratedUserEmails() {
@Override
public Set<String> getSystemGeneratedUserEmails() {
Set<String> systemGeneratedEmails = new HashSet<>();
systemGeneratedEmails.add(FieldName.ANONYMOUS_USER);
return systemGeneratedEmails;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public interface UserServiceCE extends CrudService<User, String> {

Flux<User> getAllByEmails(Set<String> emails, AclPermission permission);

Mono<User> signupIfAllowed(User user);

Mono<User> updateWithoutPermission(String id, User update);

Mono<Boolean> resendEmailVerification(ResendEmailVerificationDTO resendEmailVerificationDTO, String redirectUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,8 @@ public Mono<UserSignupDTO> createUser(User user) {
* @param user User object representing the user to be created/enabled.
* @return Publishes the user object, after having been saved.
*/
private Mono<User> signupIfAllowed(User user) {
@Override
public Mono<User> signupIfAllowed(User user) {
boolean isAdminUser = false;

if (!commonConfig.getAdminEmails().contains(user.getEmail())) {
Expand Down

0 comments on commit c9d4264

Please sign in to comment.