-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #983 from umbraco/improvement-data-type-repo-split
Improvement: Data Type Repository split
- Loading branch information
Showing
82 changed files
with
718 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...es/entity-actions/create/create.action.ts → ...pe/entity-actions/create/create.action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
39 changes: 39 additions & 0 deletions
39
src/packages/core/data-type/repository/copy/data-type-copy.repository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { UmbDataTypeRepositoryBase } from '../data-type-repository-base.js'; | ||
import { UmbDataTypeDetailRepository } from '../detail/data-type-detail.repository.js'; | ||
import { UmbDataTypeCopyServerDataSource } from './data-type-copy.server.data-source.js'; | ||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; | ||
import { UmbCopyDataSource, UmbCopyRepository } from '@umbraco-cms/backoffice/repository'; | ||
|
||
export class UmbCopyDataTypeRepository extends UmbDataTypeRepositoryBase implements UmbCopyRepository { | ||
#copySource: UmbCopyDataSource; | ||
#detailRepository: UmbDataTypeDetailRepository; | ||
|
||
constructor(host: UmbControllerHost) { | ||
super(host); | ||
this.#copySource = new UmbDataTypeCopyServerDataSource(this); | ||
this.#detailRepository = new UmbDataTypeDetailRepository(this); | ||
} | ||
|
||
async copy(id: string, targetId: string | null) { | ||
await this._init; | ||
const { data: dataTypeCopyId, error } = await this.#copySource.copy(id, targetId); | ||
if (error) return { error }; | ||
|
||
if (dataTypeCopyId) { | ||
const { data: dataTypeCopy } = await this.#detailRepository.requestById(dataTypeCopyId); | ||
if (!dataTypeCopy) throw new Error('Could not find copied data type'); | ||
|
||
// TODO: Be aware about this responsibility. | ||
this._treeStore!.appendItems([dataTypeCopy]); | ||
// only update the target if its not the root | ||
if (targetId) { | ||
this._treeStore!.updateItem(targetId, { hasChildren: true }); | ||
} | ||
|
||
const notification = { data: { message: `Data type copied` } }; | ||
this._notificationContext!.peek('positive', notification); | ||
} | ||
|
||
return { data: dataTypeCopyId }; | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { UmbCopyDataTypeRepository } from './data-type-copy.repository.js'; | ||
export { COPY_DATA_TYPE_REPOSITORY_ALIAS } from './manifests.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { UmbCopyDataTypeRepository } from './data-type-copy.repository.js'; | ||
import type { ManifestRepository } from '@umbraco-cms/backoffice/extension-registry'; | ||
|
||
export const COPY_DATA_TYPE_REPOSITORY_ALIAS = 'Umb.Repository.DataType.Copy'; | ||
|
||
const copyRepository: ManifestRepository = { | ||
type: 'repository', | ||
alias: COPY_DATA_TYPE_REPOSITORY_ALIAS, | ||
name: 'Copy Data Type Repository', | ||
api: UmbCopyDataTypeRepository, | ||
}; | ||
|
||
export const manifests = [copyRepository]; |
38 changes: 38 additions & 0 deletions
38
src/packages/core/data-type/repository/data-type-repository-base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { UMB_DATA_TYPE_TREE_STORE_CONTEXT, UmbDataTypeTreeStore } from '../tree/data-type.tree.store.js'; | ||
import { UMB_DATA_TYPE_ITEM_STORE_CONTEXT, UmbDataTypeItemStore } from './item/data-type-item.store.js'; | ||
import { UMB_DATA_TYPE_STORE_CONTEXT, UmbDataTypeDetailStore } from './detail/data-type-detail.store.js'; | ||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; | ||
import { UMB_NOTIFICATION_CONTEXT_TOKEN, UmbNotificationContext } from '@umbraco-cms/backoffice/notification'; | ||
import { UmbRepositoryBase } from '@umbraco-cms/backoffice/repository'; | ||
|
||
export class UmbDataTypeRepositoryBase extends UmbRepositoryBase { | ||
protected _init: Promise<unknown>; | ||
|
||
protected _detailStore?: UmbDataTypeDetailStore; | ||
protected _treeStore?: UmbDataTypeTreeStore; | ||
protected _itemStore?: UmbDataTypeItemStore; | ||
|
||
protected _notificationContext?: UmbNotificationContext; | ||
|
||
constructor(host: UmbControllerHost) { | ||
super(host); | ||
|
||
this._init = Promise.all([ | ||
this.consumeContext(UMB_DATA_TYPE_STORE_CONTEXT, (instance) => { | ||
this._detailStore = instance; | ||
}).asPromise(), | ||
|
||
this.consumeContext(UMB_DATA_TYPE_TREE_STORE_CONTEXT, (instance) => { | ||
this._treeStore = instance; | ||
}).asPromise(), | ||
|
||
this.consumeContext(UMB_DATA_TYPE_ITEM_STORE_CONTEXT, (instance) => { | ||
this._itemStore = instance; | ||
}).asPromise(), | ||
|
||
this.consumeContext(UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { | ||
this._notificationContext = instance; | ||
}).asPromise(), | ||
]); | ||
} | ||
} |
Oops, something went wrong.