Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add web spotlight entity #61

Merged
merged 10 commits into from
Aug 14, 2024
Merged

Add web spotlight entity #61

merged 10 commits into from
Aug 14, 2024

Conversation

JiriLojda
Copy link
Member

Motivation

Which issue does this fix? Fixes #issue number

If no issue exists, what is the fix or new feature? Were there any reasons to fix/implement things that are not obvious?

Checklist

  • Code follows coding conventions held in this repo
  • Automated tests have been added
  • Tests are passing
  • Docs have been updated (if applicable)
  • Temporary settings (e.g. variables used during development and testing) have been reverted to defaults

How to test

If manual testing is required, what are the steps?

@JiriLojda JiriLojda requested a review from a team as a code owner August 8, 2024 10:45
@JiriLojda JiriLojda force-pushed the add_webSpotlight_entity branch from 3c405a0 to 69cf9d7 Compare August 8, 2024 10:55
src/modules/sync/printDiff.ts Outdated Show resolved Hide resolved
@@ -43,14 +43,17 @@ export const sync = async (client: ManagementClient, diff: DiffModel, logOptions
logInfo(logOptions, "standard", "Updating content types and adding their references");
await updateContentTypesAndAddReferences(client, diff.contentTypes);

logInfo(logOptions, "standard", "Updating web spotlight");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add here comment, that the web_spotlight will use already existing type and never use the option to create one, that was added earlier :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what you mean

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean explaining the order of these operations. As we first create all the types, when enabling Web Spotlight we don't have to worry that the type we are referencing won't exist. Due to this we always use the option when we provide the root_type parameter. We never use null when enabling Web Spotlight. Ideally, we would also update the diagram in the images :D

src/modules/sync/utils/getContentModel.ts Show resolved Hide resolved
tests/unit/utils/requests.test.ts Show resolved Hide resolved
@JiriLojda JiriLojda force-pushed the add_webSpotlight_entity branch 3 times, most recently from bc7027a to e71dcbf Compare August 12, 2024 16:58
@@ -21,6 +22,18 @@ export const spacesEntity: EntityDefinition<ReadonlyArray<SpaceContracts.ISpaceC
.withData({
name: importSpace.name,
codename: importSpace.codename,
collections: importSpace.collections?.map(c => ({
id: getRequired(context.collectionIdsByOldIds, c.id ?? "missing-collection-id", "collection"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a comment on line 16 that should be removed


if (diffModel.webSpotlight.change !== "none") {
logInfo(logOptions, "standard", chalk.blue.bold("\nWEB SPOTLIGHT:"));
switch (diffModel.webSpotlight.change) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const messsage = match(diffModel.webSpotlight)
      .with({change: 'activate'} , ({rootTypeCodename}) => `Web Spotlight is to be activated with root type: ${chalk.green(rootTypeCodename)}`)
      .with({change: "changeRootType"}, ({rootTypeCodename}) => `Web Spotlight root type is changed to: ${chalk.green(rootTypeCodename)}`)
      .with({change: "deactivate"}, () => "Web Spotlight is to be deactivated")
      .exhaustive();

logInfo(logOptions, "standard", messsage);

@@ -300,6 +303,21 @@ const transformTaxonomyOperations = (
} as unknown as TaxonomyModels.IModifyTaxonomyData;
};

const updateWebSpotlight = (client: ManagementClient, diffModel: WebSpotlightDiffModel): Promise<unknown> => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const updateWebSpotlight = (client: ManagementClient, diffModel: WebSpotlightDiffModel): Promise<unknown> =>
  match(diffModel)
    .with({ change: "none" }, () => Promise.resolve())
    .with({ change: "deactivate" }, () => client.deactivateWebSpotlight().toPromise())
    .with(
      { change: P.union("activate", "changeRootType") },
      ({ rootTypeCodename }) =>
        client.activateWebSpotlight().withData({ root_type: { codename: rootTypeCodename } }).toPromise(),
    )
    .exhaustive();

@JiriLojda JiriLojda force-pushed the add_webSpotlight_entity branch 2 times, most recently from b2ff989 to 1d6618c Compare August 14, 2024 08:04
@JiriLojda JiriLojda force-pushed the add_webSpotlight_entity branch from 1d6618c to af67c7e Compare August 14, 2024 08:49
@JiriLojda JiriLojda merged commit d57eb2a into main Aug 14, 2024
3 checks passed
@JiriLojda JiriLojda deleted the add_webSpotlight_entity branch August 14, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants