Merge pull request #35564 from appsmithorg/hotfix/fix/35557-hidden-page

This commit is contained in:
Nidhi 2024-08-09 14:50:02 +05:30 committed by GitHub
commit 5f3474be5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 79 additions and 18 deletions

View File

@ -19,7 +19,7 @@ import * as Sentry from "@sentry/react";
import { import {
getCurrentPageDescription, getCurrentPageDescription,
getIsAutoLayout, getIsAutoLayout,
getViewModePageList, getPageList,
} from "selectors/editorSelectors"; } from "selectors/editorSelectors";
import { getThemeDetails, ThemeMode } from "selectors/themeSelectors"; import { getThemeDetails, ThemeMode } from "selectors/themeSelectors";
import { getSearchQuery } from "utils/helpers"; import { getSearchQuery } from "utils/helpers";
@ -88,7 +88,7 @@ function AppViewer(props: Props) {
const { pathname, search } = props.location; const { pathname, search } = props.location;
const { baseApplicationId, basePageId } = props.match.params; const { baseApplicationId, basePageId } = props.match.params;
const isInitialized = useSelector(getIsInitialized); const isInitialized = useSelector(getIsInitialized);
const pages = useSelector(getViewModePageList); const pages = useSelector(getPageList);
const selectedTheme = useSelector(getSelectedAppTheme); const selectedTheme = useSelector(getSelectedAppTheme);
const lightTheme = useSelector((state: AppState) => const lightTheme = useSelector((state: AppState) =>
getThemeDetails(state, ThemeMode.LIGHT), getThemeDetails(state, ThemeMode.LIGHT),

View File

@ -144,6 +144,10 @@ public class JsonSchemaMigration {
case 6: case 6:
MigrationHelperMethods.ensureXmlParserPresenceInCustomJsLibList(applicationJson); MigrationHelperMethods.ensureXmlParserPresenceInCustomJsLibList(applicationJson);
applicationJson.setServerSchemaVersion(7); applicationJson.setServerSchemaVersion(7);
case 7:
case 8:
MigrationHelperMethods.migrateThemeSettingsForAnvil(applicationJson);
applicationJson.setServerSchemaVersion(9);
default: default:
// Unable to detect the serverSchema // Unable to detect the serverSchema
} }

View File

@ -1,7 +1,5 @@
package com.appsmith.server.migrations; package com.appsmith.server.migrations;
import com.appsmith.external.annotations.FeatureFlagged;
import com.appsmith.external.enums.FeatureFlagEnum;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
@ -20,8 +18,7 @@ public class JsonSchemaVersions extends JsonSchemaVersionsFallback {
* @return an Integer which is server version * @return an Integer which is server version
*/ */
@Override @Override
@FeatureFlagged(featureFlagName = FeatureFlagEnum.release_git_autocommit_feature_enabled)
public Integer getServerVersion() { public Integer getServerVersion() {
return super.getServerVersion() + 1; return super.getServerVersion();
} }
} }

View File

@ -4,7 +4,7 @@ import org.springframework.stereotype.Component;
@Component @Component
public class JsonSchemaVersionsFallback { public class JsonSchemaVersionsFallback {
private static final Integer serverVersion = 7; private static final Integer serverVersion = 9;
public static final Integer clientVersion = 1; public static final Integer clientVersion = 1;
public Integer getServerVersion() { public Integer getServerVersion() {

View File

@ -7,6 +7,8 @@ import com.appsmith.external.models.InvisibleActionFields;
import com.appsmith.external.models.Property; import com.appsmith.external.models.Property;
import com.appsmith.server.constants.ApplicationConstants; import com.appsmith.server.constants.ApplicationConstants;
import com.appsmith.server.constants.ResourceModes; import com.appsmith.server.constants.ResourceModes;
import com.appsmith.server.domains.Application;
import com.appsmith.server.domains.ApplicationDetail;
import com.appsmith.server.domains.ApplicationPage; import com.appsmith.server.domains.ApplicationPage;
import com.appsmith.server.domains.CustomJSLib; import com.appsmith.server.domains.CustomJSLib;
import com.appsmith.server.domains.NewAction; import com.appsmith.server.domains.NewAction;
@ -1181,4 +1183,52 @@ public class MigrationHelperMethods {
} }
return pathsToRemove; return pathsToRemove;
} }
public static void migrateThemeSettingsForAnvil(ApplicationJson applicationJson) {
if (applicationJson == null || applicationJson.getExportedApplication() == null) {
return;
}
Application exportedApplication = applicationJson.getExportedApplication();
ApplicationDetail applicationDetail = exportedApplication.getApplicationDetail();
ApplicationDetail unpublishedApplicationDetail = exportedApplication.getUnpublishedApplicationDetail();
if (applicationDetail == null) {
applicationDetail = new ApplicationDetail();
exportedApplication.setApplicationDetail(applicationDetail);
}
if (unpublishedApplicationDetail == null) {
unpublishedApplicationDetail = new ApplicationDetail();
exportedApplication.setUnpublishedApplicationDetail(unpublishedApplicationDetail);
}
Application.ThemeSetting themeSetting = applicationDetail.getThemeSetting();
Application.ThemeSetting unpublishedThemeSetting = unpublishedApplicationDetail.getThemeSetting();
if (themeSetting == null) {
themeSetting = new Application.ThemeSetting();
}
if (unpublishedThemeSetting == null) {
unpublishedThemeSetting = new Application.ThemeSetting();
}
applicationDetail.setThemeSetting(themeSetting);
unpublishedApplicationDetail.setThemeSetting(unpublishedThemeSetting);
}
public static void setThemeSettings(Application.ThemeSetting themeSetting) {
if (themeSetting.getAppMaxWidth() == null) {
themeSetting.setAppMaxWidth(Application.ThemeSetting.AppMaxWidth.LARGE);
}
// since these are primitive values we don't have concept of null, hence putting it to the default of 1.
if (themeSetting.getDensity() == 0) {
themeSetting.setDensity(1);
}
if (themeSetting.getSizing() == 0) {
themeSetting.setSizing(1);
}
}
} }

View File

@ -12,6 +12,7 @@ import com.appsmith.server.services.LayoutActionService;
import com.appsmith.server.solutions.ActionPermission; import com.appsmith.server.solutions.ActionPermission;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -33,6 +34,14 @@ public class ActionClonePageServiceCEImpl implements ClonePageServiceCE<NewActio
actionDTO.setBranchName(clonePageMetaDTO.getBranchName()); actionDTO.setBranchName(clonePageMetaDTO.getBranchName());
actionDTO.setPageId(clonePageMetaDTO.getClonedPageDTO().getId()); actionDTO.setPageId(clonePageMetaDTO.getClonedPageDTO().getId());
boolean isJsAction = StringUtils.hasLength(actionDTO.getCollectionId());
if (isJsAction) {
String newCollectionId =
clonePageMetaDTO.getOldToNewCollectionIds().get(actionDTO.getCollectionId());
actionDTO.setCollectionId(newCollectionId);
}
/* /*
* - Now create the new action from the template of the source action. * - Now create the new action from the template of the source action.
* - Use CLONE_PAGE context to make sure that page / application clone quirks are * - Use CLONE_PAGE context to make sure that page / application clone quirks are
@ -45,7 +54,7 @@ public class ActionClonePageServiceCEImpl implements ClonePageServiceCE<NewActio
// Indicates that source of action creation is clone page action // Indicates that source of action creation is clone page action
cloneActionDTO.setSource(ActionCreationSourceTypeEnum.CLONE_PAGE); cloneActionDTO.setSource(ActionCreationSourceTypeEnum.CLONE_PAGE);
copyNestedNonNullProperties(actionDTO, cloneActionDTO); copyNestedNonNullProperties(actionDTO, cloneActionDTO);
return layoutActionService.createAction(cloneActionDTO, eventContext, Boolean.FALSE); return layoutActionService.createAction(cloneActionDTO, eventContext, isJsAction);
}) })
.then(); .then();
} }

View File

@ -2505,8 +2505,6 @@ public class ImportServiceTests {
StepVerifier.create(resultMonoWithDiscardOperation) StepVerifier.create(resultMonoWithDiscardOperation)
.assertNext(application -> { .assertNext(application -> {
assertThat(application.getWorkspaceId()).isNotNull(); assertThat(application.getWorkspaceId()).isNotNull();
assertThat(application.getUnpublishedApplicationDetail()).isNull();
assertThat(application.getPublishedApplicationDetail()).isNull();
}) })
.verifyComplete(); .verifyComplete();
} }

View File

@ -78,9 +78,6 @@ public class JsonSchemaMigrationTest {
gitFileSystemTestHelper.getApplicationJson(this.getClass().getResource("application.json")); gitFileSystemTestHelper.getApplicationJson(this.getClass().getResource("application.json"));
ArtifactExchangeJson artifactExchangeJson = jsonSchemaMigration.migrateArtifactToLatestSchema(applicationJson); ArtifactExchangeJson artifactExchangeJson = jsonSchemaMigration.migrateArtifactToLatestSchema(applicationJson);
assertThat(artifactExchangeJson.getServerSchemaVersion())
.isNotEqualTo(jsonSchemaVersionsFallback.getServerVersion());
assertThat(artifactExchangeJson.getServerSchemaVersion()).isEqualTo(jsonSchemaVersions.getServerVersion()); assertThat(artifactExchangeJson.getServerSchemaVersion()).isEqualTo(jsonSchemaVersions.getServerVersion());
assertThat(artifactExchangeJson.getClientSchemaVersion()).isEqualTo(jsonSchemaVersions.getClientVersion()); assertThat(artifactExchangeJson.getClientSchemaVersion()).isEqualTo(jsonSchemaVersions.getClientVersion());
assertThat(artifactExchangeJson.getClientSchemaVersion()) assertThat(artifactExchangeJson.getClientSchemaVersion())
@ -103,8 +100,6 @@ public class JsonSchemaMigrationTest {
jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson); jsonSchemaMigration.migrateApplicationJsonToLatestSchema(applicationJson);
StepVerifier.create(applicationJsonMono) StepVerifier.create(applicationJsonMono)
.assertNext(appJson -> { .assertNext(appJson -> {
assertThat(appJson.getServerSchemaVersion())
.isNotEqualTo(jsonSchemaVersionsFallback.getServerVersion());
assertThat(appJson.getServerSchemaVersion()).isEqualTo(jsonSchemaVersions.getServerVersion()); assertThat(appJson.getServerSchemaVersion()).isEqualTo(jsonSchemaVersions.getServerVersion());
assertThat(appJson.getClientSchemaVersion()).isEqualTo(jsonSchemaVersions.getClientVersion()); assertThat(appJson.getClientSchemaVersion()).isEqualTo(jsonSchemaVersions.getClientVersion());
assertThat(appJson.getClientSchemaVersion()) assertThat(appJson.getClientSchemaVersion())

View File

@ -50,9 +50,7 @@ public class JsonSchemaVersionsTest {
Mockito.when(featureFlagService.getCachedTenantFeatureFlags()) Mockito.when(featureFlagService.getCachedTenantFeatureFlags())
.thenAnswer((Answer<CachedFeatures>) invocations -> cachedFeatures); .thenAnswer((Answer<CachedFeatures>) invocations -> cachedFeatures);
assertThat(jsonSchemaVersions.getServerVersion()).isNotEqualTo(jsonSchemaVersionsFallback.getServerVersion()); assertThat(jsonSchemaVersions.getServerVersion()).isEqualTo(jsonSchemaVersionsFallback.getServerVersion());
assertThat(jsonSchemaVersions.getServerVersion()).isEqualTo(jsonSchemaVersionsFallback.getServerVersion() + 1);
assertThat(jsonSchemaVersions.getClientVersion()).isEqualTo(jsonSchemaVersionsFallback.getClientVersion()); assertThat(jsonSchemaVersions.getClientVersion()).isEqualTo(jsonSchemaVersionsFallback.getClientVersion());
} }
} }

View File

@ -746,6 +746,16 @@ public class PageServiceTest {
assertThat(collections.get(0).getUnpublishedCollection().getPageId()) assertThat(collections.get(0).getUnpublishedCollection().getPageId())
.isEqualTo(clonedPage.getId()); .isEqualTo(clonedPage.getId());
NewAction actionWithCollection = actions.stream()
.filter(newAction -> StringUtils.hasLength(
newAction.getUnpublishedAction().getCollectionId()))
.findFirst()
.orElse(null);
// Confirm that js action has correct collection id reference
assertThat(actionWithCollection.getUnpublishedAction().getCollectionId())
.isEqualTo(collections.get(0).getId());
// Check if the parent page collections are not altered // Check if the parent page collections are not altered
List<ActionCollection> parentPageCollections = tuple.getT4(); List<ActionCollection> parentPageCollections = tuple.getT4();
assertThat(parentPageCollections).hasSize(1); assertThat(parentPageCollections).hasSize(1);