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

feat(project): add hidden changeMessagesEnabled action #83

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/repositories/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import { maskSecretValue } from '../lib/masking'
import { Writable } from '../types'
import { AbstractRepository, RepositoryContext } from './abstract'

// https://docs.commercetools.com/api/releases/2018-10-08-delete-messages-after-days
export interface changeMessagesEnabled {
readonly action: 'changeMessagesEnabled';
readonly messagesEnabled: boolean;
}

export class ProjectRepository extends AbstractRepository<Project> {
get(context: RepositoryContext): Project | null {
const resource = this._storage.getProject(context.projectKey)
Expand All @@ -41,7 +47,8 @@ export class ProjectRepository extends AbstractRepository<Project> {

actions: Partial<
Record<
ProjectUpdateAction['action'],
// https://docs.commercetools.com/api/releases/2018-10-08-delete-messages-after-days
ProjectUpdateAction['action'] | 'changeMessagesEnabled',
(
context: RepositoryContext,
resource: Writable<Project>,
Expand Down Expand Up @@ -85,6 +92,13 @@ export class ProjectRepository extends AbstractRepository<Project> {
resource.messages.enabled = messagesConfiguration.enabled
resource.messages.deleteDaysAfterCreation = messagesConfiguration.deleteDaysAfterCreation
},
changeMessagesEnabled: (
context: RepositoryContext,
resource: Writable<Project>,
{ messagesEnabled }: { messagesEnabled: boolean }
) => {
resource.messages.enabled = messagesEnabled
},
changeProductSearchIndexingEnabled: (
context: RepositoryContext,
resource: Writable<Project>,
Expand Down