-
Notifications
You must be signed in to change notification settings - Fork 1
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 #473 from dolittle/edit-microservice-fix
Edit microservice fix
- Loading branch information
Showing
8 changed files
with
92 additions
and
94 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
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
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
52 changes: 52 additions & 0 deletions
52
Source/SelfService/Web/applications/microservice/utils/getMicroserviceInfo.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,52 @@ | ||
// Copyright (c) Dolittle. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
import { canEditMicroservice, MicroserviceStore } from '../../stores/microservice'; | ||
|
||
import { MicroserviceSimple } from '../../../apis/solutions/index'; | ||
import { HttpResponseApplication } from '../../../apis/solutions/application'; | ||
|
||
// Check if there is microservice.edit data. If not, use microservice.live data. | ||
export const getMicroserviceInfo = (application: HttpResponseApplication, microservice: MicroserviceStore): MicroserviceSimple => { | ||
const canEdit = canEditMicroservice(application.environments, microservice.environment, microservice.id); | ||
|
||
if (canEdit) { | ||
return microservice.edit; | ||
} else { | ||
// Can I not move this to the store? | ||
const headImage = microservice.live.images.find(img => img.name === 'head')?.image || 'N/A'; | ||
const runtimeImage = microservice.live.images.find(img => img.name === 'runtime')?.image || 'N/A'; | ||
|
||
const headCommand = { | ||
command: [], | ||
args: [], | ||
}; | ||
|
||
const environmentInfo = application.environments.find(environment => environment.name === microservice.environment)!; | ||
|
||
// TODO currently we don't use the ms.extra.ingress in the view | ||
// Look to "liveIngressView" for how we "set" the data to uniq paths | ||
return { | ||
dolittle: { | ||
applicationId: application.id, | ||
customerId: application.customerId, | ||
microserviceId: microservice.id, | ||
}, | ||
name: microservice.name, | ||
kind: 'unknown', | ||
environment: microservice.environment, | ||
extra: { | ||
ingress: { | ||
path: '', | ||
pathType: '', | ||
}, | ||
headPort: 80, | ||
isPublic: true, | ||
headImage, | ||
runtimeImage, | ||
headCommand, | ||
connections: environmentInfo.connections, | ||
}, | ||
}; | ||
} | ||
}; |
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