Skip to content

Commit

Permalink
Rework RequiredAdminLevel to UserRoleFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
FyreByrd committed Oct 8, 2024
1 parent d6b2e01 commit c043733
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 67 deletions.
55 changes: 30 additions & 25 deletions source/SIL.AppBuilder.Portal/common/public/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ export enum ActionType {
/**
* The administrative requirements of the workflow.
* Examples:
* - If the flow has `RequiredAdminLevel.High` it will include extra state to represent the organizational approval process
* - If the flow has `RequiredAdminLevel.Low` it will not include those states, but there are still some states that require action from an OrgAdmin to complete certain actions
* - If the flow has `RequiredAdminLevel.None` none of the states or actions for the workflow instance will require an OrgAdmin.
* - If the flow has `UserRoleFeature.RequireApprovalProcess` it will include extra state to represent the organizational approval process
* - If the flow has `UserRoleFeature.RequireAdminConfiguration` it will not include those states, but there are still some states that require action from an OrgAdmin to complete certain actions
* - If the flow has `UserRoleFeature.None` none of the states or actions for the workflow instance will require an OrgAdmin.
*
* Any state or transition can have a list of specified `RequiredAdminLevel`s. What this means is that those states and transitions will be included in a workflow instance ONLY when the instance's `RequiredAdminLevel` is in the state's or transition's list.
* Any state or transition can have a list of specified `UserRoleFeature`s. What this means is that those states and transitions will be included in a workflow instance ONLY when the instance's `UserRoleFeature` is in the state's or transition's list.
*
* If a state or transition does not specify any `RequiredAdminLevel` it will be included (provided it passes other conditions not dependent on `RequiredAdminLevel`).
* If a state or transition does not specify any `UserRoleFeature` it will be included (provided it passes other conditions not dependent on `UserRoleFeature`).
*/
export enum RequiredAdminLevel {
/** NoAdmin/OwnerAdmin */
export enum UserRoleFeature {
None = 0,
/** LowAdmin */
Low,
/** Approval required */
High
RequireAdminConfiguration,
RequireApprovalProcess
}

export enum ProductType {
Expand Down Expand Up @@ -83,7 +80,7 @@ export type WorkflowContext = {
includeReviewers: boolean;
includeArtifacts: 'apk' | 'aab' | boolean;
start?: StateName;
adminLevel: RequiredAdminLevel;
URFeatures: UserRoleFeature[];
environment: BuildEnv;
productType: ProductType;
};
Expand All @@ -97,7 +94,7 @@ export type BuildEnv = {
};

export type WorkflowInput = {
adminLevel: RequiredAdminLevel;
URFeatures: UserRoleFeature[];
productType: ProductType;
};

Expand All @@ -106,53 +103,61 @@ export function workflowInputFromDBProductType(workflowDefinitionId: number): Wo
switch (workflowDefinitionId) {
case 1: // sil_android_google_play
return {
adminLevel: RequiredAdminLevel.High,
URFeatures: [
UserRoleFeature.RequireApprovalProcess,
UserRoleFeature.RequireAdminConfiguration
],
productType: ProductType.Android_GooglePlay
};
case 4: // sil_android_s3
return {
adminLevel: RequiredAdminLevel.High,
URFeatures: [UserRoleFeature.RequireApprovalProcess],
productType: ProductType.Android_S3
};
};
case 6: // la_android_google_play
return {
adminLevel: RequiredAdminLevel.Low,
URFeatures: [UserRoleFeature.RequireAdminConfiguration],
productType: ProductType.Android_GooglePlay
};
case 7: // na_android_google_play
return {
adminLevel: RequiredAdminLevel.None,
URFeatures: [UserRoleFeature.None],
productType: ProductType.Android_GooglePlay
};
case 8: // na_android_s3
return {
adminLevel: RequiredAdminLevel.None,
URFeatures: [UserRoleFeature.None],
productType: ProductType.Android_S3
};
case 9: // pwa_cloud
case 11: // html_cloud
return {
adminLevel: RequiredAdminLevel.None,
URFeatures: [UserRoleFeature.None],
productType: ProductType.Web
};
case 13: // asset_package
return {
adminLevel: RequiredAdminLevel.None,
URFeatures: [UserRoleFeature.None],
productType: ProductType.AssetPackage
};
default: // would be some other workflow type presumably
console.log(`Unrecognized workflow definition: ${workflowDefinitionId}! Returning configuration for sil_android_google_play.`);
console.log(
`Unrecognized workflow definition: ${workflowDefinitionId}! Returning configuration for sil_android_google_play.`
);
return {
adminLevel: RequiredAdminLevel.High,
URFeatures: [
UserRoleFeature.RequireApprovalProcess,
UserRoleFeature.RequireAdminConfiguration
],
productType: ProductType.Android_GooglePlay
};
}
}

/** Used for filtering based on AdminLevel and/or ProductType */
export type MetaFilter = {
level?: RequiredAdminLevel[];
product?: ProductType[];
URFeatures?: UserRoleFeature[];
productTypes?: ProductType[];
};

export type WorkflowStateMeta = MetaFilter;
Expand Down
Loading

0 comments on commit c043733

Please sign in to comment.