Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
Issue/tab retrieve (#498)
Browse files Browse the repository at this point in the history
* fix: add metadata list to tab retrieve

* concatenate tab query and metadata list result

* version 2.8.6

Co-authored-by: mani <manivasaga.murugesan@accenture.com>
  • Loading branch information
azlam-abdulsalam and mani authored Mar 29, 2021
1 parent ae74dfd commit 627773d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 17 deletions.
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion oclif.manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.8.5",
"version": "2.8.6",
"commands": {
"sfpowerkit:auth:login": {
"id": "sfpowerkit:auth:login",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sfpowerkit",
"version": "2.8.5",
"version": "2.8.6",
"author": {
"name": "DXatScale",
"email": "dxatscale@accenture.com"
Expand Down
15 changes: 11 additions & 4 deletions src/impl/metadata/retriever/metadataRetriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default class MetadataRetriever {
items = await this.getObjectPermissions();
} else if (this._componentType === METADATA_INFO.CustomField.xmlName) {
items = await this.getFieldsByObjectName(parent);
} else if (this._componentType === METADATA_INFO.PermissionSet.xmlName) {
items = await this.getPermissionSets();
} else if (this._componentType === "UserPermissions") {
items = await this.getUserPermissions();
} else if (this._componentType === METADATA_INFO.Layout.xmlName) {
items = await this.getLayouts();
} else if (this._componentType === METADATA_INFO.CustomTab.xmlName) {
Expand Down Expand Up @@ -72,10 +72,17 @@ export default class MetadataRetriever {
let queryUtil = new QueryExecutor(this._conn);
let items = await queryUtil.executeQuery(query, false);

return items.map((tab) => {
items.map((tab) => {
tab.fullName = tab.Name;
return tab;
});

let listMetadataItems = await this.getComponentsFromOrgUsingListMetadata();
if (listMetadataItems.length > 0) {
items = items.concat(listMetadataItems);
}

return items;
}

private async getComponentsFromOrgUsingListMetadata() {
Expand Down Expand Up @@ -146,7 +153,7 @@ export default class MetadataRetriever {
return entities;
}

public async getPermissionSets(): Promise<any[]> {
public async getUserPermissions(): Promise<any[]> {
let describeResult = await this._conn.sobject("PermissionSet").describe();
let supportedPermissions = [];
describeResult.fields.forEach((field) => {
Expand Down
2 changes: 1 addition & 1 deletion src/impl/metadata/retriever/profileRetriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export default class ProfileRetriever {
private async fetchPermissions() {
let permissionRetriever = new MetadataRetriever(
this.conn,
METADATA_INFO.PermissionSet.xmlName,
"UserPermissions",
METADATA_INFO
);
let permissionSets = await permissionRetriever.getComponents();
Expand Down
26 changes: 17 additions & 9 deletions src/impl/source/profiles/profileReconcile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ export default class ProfileReconcile extends ProfileActions {
}
}

private async removeUserPermissionNotAvailableInOrg(profileObj: Profile) {
private async removeUserPermissionNotAvailableInOrg(
profileObj: Profile,
supportedPermissions: string[]
) {
if (
profileObj.userPermissions !== undefined &&
profileObj.userPermissions.length > 0
) {
//Fetch all user permissions from the org.
let supportedPermissions = await this.fetchPermissions();

//Remove permission that are not present in the target org
profileObj.userPermissions = profileObj.userPermissions.filter(
(permission) => {
Expand Down Expand Up @@ -644,7 +644,7 @@ export default class ProfileReconcile extends ProfileActions {
private async fetchPermissions() {
let permissionRetriever = new MetadataRetriever(
this.conn,
METADATA_INFO.PermissionSet.xmlName,
"UserPermissions",
METADATA_INFO
);
let permissionSets = await permissionRetriever.getComponents();
Expand All @@ -655,6 +655,13 @@ export default class ProfileReconcile extends ProfileActions {
}

private async reconcileUserPermissions(profileObj: Profile) {
if (
profileObj.userPermissions === undefined ||
profileObj.userPermissions.length === 0
) {
return;
}

//Delete all user Permissions if the profile is standard one
let isCustom = profileObj.custom;
if (!isCustom) {
Expand All @@ -669,14 +676,15 @@ export default class ProfileReconcile extends ProfileActions {
//IS sourceonly, use ignorePermission set in sfdxProject.json file
if (MetadataFiles.sourceOnly) {
await this.removePermissionsBasedOnProjectConfig(profileObj);
} else {
await this.removeUserPermissionNotAvailableInOrg(profileObj);
}

if (MetadataFiles.sourceOnly) {
await userPermissionBuilder.handlePermissionDependency(profileObj, []);
} else {
let supportedPermissions = await this.fetchPermissions();
await this.removeUserPermissionNotAvailableInOrg(
profileObj,
supportedPermissions
);

await userPermissionBuilder.handlePermissionDependency(
profileObj,
supportedPermissions
Expand Down

0 comments on commit 627773d

Please sign in to comment.