Skip to content

Commit

Permalink
Merge branch 'sprint-34' of https://github.com/Avanade/approval-system
Browse files Browse the repository at this point in the history
…into 92-implement-clean-arch-on-approval-system

Signed-off-by: Ismael Ibuan <[email protected]>
  • Loading branch information
iibuan committed Sep 25, 2024
2 parents 356c50a + 494d579 commit 582f7ac
Show file tree
Hide file tree
Showing 11 changed files with 380 additions and 225 deletions.
1 change: 1 addition & 0 deletions .bicep/webapp/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"WEBSITES_ENABLE_APP_SERVICE_STORAGE": "",
"CONTENT_SECURITY_POLICY": "",
"EMAIL_SUPPORT":"",
"ENTERPRISE_OWNERS":"",
"EMAIL_ENABLED" : "",
"EMAIL_TENANT_ID" : "",
"EMAIL_CLIENT_ID" : "",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/setup-appservice-resource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
parameters.appServiceSettings.value.EMAIL_TENANT_ID : ${{ secrets.EMAIL_TENANT_ID }}
parameters.appServiceSettings.value.EMAIL_CLIENT_ID : ${{ secrets.EMAIL_CLIENT_ID }}
parameters.appServiceSettings.value.EMAIL_CLIENT_SECRET : ${{ secrets.EMAIL_CLIENT_SECRET }}
parameters.appServiceSettings.value.ENTERPRISE_OWNERS : ${{ secrets.ENTERPRISE_OWNERS }}
parameters.appServiceSettings.value.EMAIL_USER_ID : ${{ secrets.EMAIL_USER_ID }}
parameters.appServiceSettings.value.DOCKER_REGISTRY_SERVER_URL : ${{ secrets.CONTAINER_REGISTRY_SERVER_URL }}
parameters.appServiceSettings.value.DOCKER_REGISTRY_SERVER_USERNAME : ${{ secrets.CONTAINER_REGISTRY_SERVER_USERNAME }}
Expand Down
1 change: 1 addition & 0 deletions src/goapp/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type Config struct {

type ConfigManager interface {
GetDatabaseConnectionString() string
GetEnterpriseOwners() []string
GetEmailTenantID() string
GetEmailClientID() string
GetEmailClientSecret() string
Expand Down
15 changes: 11 additions & 4 deletions src/goapp/config/env-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"log"
"os"
"strings"

"github.com/joho/godotenv"
)
Expand All @@ -25,6 +26,15 @@ func (ecm *envConfigManager) GetDatabaseConnectionString() string {
return os.Getenv("APPROVALSYSTEMDB_CONNECTION_STRING")
}

func (ecm *envConfigManager) GetEnterpriseOwners() []string {
enterpriseOwners := os.Getenv("ENTERPRISE_OWNERS")
if enterpriseOwners == "" {
return nil
}
ownersArray := strings.Split(enterpriseOwners, ",")
return ownersArray
}

func (ecm *envConfigManager) GetEmailTenantID() string {
return os.Getenv("EMAIL_TENANT_ID")
}
Expand All @@ -42,8 +52,5 @@ func (ecm *envConfigManager) GetEmailUserID() string {
}

func (ecm *envConfigManager) GetIsEmailEnabled() bool {
if os.Getenv("EMAIL_ENABLED") != "true" {
return false
}
return true
return os.Getenv("EMAIL_ENABLED") == "true"
}
2 changes: 1 addition & 1 deletion src/goapp/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (

svc = s.NewService(
s.NewApplicationModuleService(repo),
s.NewItemService(repo),
s.NewItemService(repo, conf),
s.NewEmailService(conf),
)

Expand Down
36 changes: 16 additions & 20 deletions src/goapp/public/css/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -1847,10 +1847,18 @@ select {
top: 50%;
}

.top-5 {
top: 1.25rem;
}

.top-full {
top: 100%;
}

.top-8 {
top: 2rem;
}

.isolate {
isolation: isolate;
}
Expand Down Expand Up @@ -1991,12 +1999,8 @@ select {
margin-left: 0.75rem;
}

.mr-1 {
margin-right: 0.25rem;
}

.mr-1\.5 {
margin-right: 0.375rem;
.ml-auto {
margin-left: auto;
}

.mr-2 {
Expand Down Expand Up @@ -2234,10 +2238,6 @@ select {
width: 2rem;
}

.w-96 {
width: 24rem;
}

.w-auto {
width: auto;
}
Expand Down Expand Up @@ -4243,6 +4243,12 @@ select {
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}

.shadow-md {
--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}

.shadow-sm {
--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);
Expand All @@ -4255,12 +4261,6 @@ select {
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}

.shadow-md {
--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}

.outline-none {
outline: 2px solid transparent;
outline-offset: 2px;
Expand Down Expand Up @@ -6398,10 +6398,6 @@ select {
justify-content: flex-end;
}

.sm\:justify-between {
justify-content: space-between;
}

.sm\:gap-4 {
gap: 1rem;
}
Expand Down
39 changes: 36 additions & 3 deletions src/goapp/service/item/item-service.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package item

import (
"main/config"
"main/model"
"main/repository"
)

type itemService struct {
Repository *repository.Repository
Repository *repository.Repository
configManager config.ConfigManager
}

func NewItemService(repo *repository.Repository) ItemService {
func NewItemService(repo *repository.Repository, configManager config.ConfigManager) ItemService {
return &itemService{
Repository: repo,
Repository: repo,
configManager: configManager,
}
}

Expand All @@ -28,6 +31,16 @@ func (s *itemService) GetAll(itemOptions model.ItemOptions) (model.Response, err
return model.Response{}, err
}

for i := 0; i < len(data); i++ {
if data[i].Approvers == nil {
continue
}
if len(data[i].Approvers) == 0 {
continue
}
data[i].Approvers = s.removeEnterpriseOwnersInApprovers(data[i].Approvers)
}

result = model.Response{
Data: data,
Total: total,
Expand Down Expand Up @@ -59,3 +72,23 @@ func (s *itemService) UpdateItemDateSent(itemId string) error {
}
return nil
}

func (s *itemService) removeEnterpriseOwnersInApprovers(approvers []string) []string {
ownersArray := s.configManager.GetEnterpriseOwners()
if len(ownersArray) == 0 {
return approvers
}
ownersMap := make(map[string]bool)
for _, owner := range ownersArray {
ownersMap[owner] = true
}

var newApprovers []string
for _, approver := range approvers {
if !ownersMap[approver] {
newApprovers = append(newApprovers, approver)
}
}

return newApprovers
}
4 changes: 2 additions & 2 deletions src/goapp/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ func NewApplicationModuleService(repo *repository.Repository) ServiceOptionFunc
}
}

func NewItemService(repo *repository.Repository) ServiceOptionFunc {
func NewItemService(repo *repository.Repository, conf config.ConfigManager) ServiceOptionFunc {
return func(s *Service) {
s.Item = sItem.NewItemService(repo)
s.Item = sItem.NewItemService(repo, conf)
}
}

Expand Down
17 changes: 9 additions & 8 deletions src/goapp/tailwind/package-lock.json

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

Loading

0 comments on commit 582f7ac

Please sign in to comment.