-
Notifications
You must be signed in to change notification settings - Fork 2k
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 #4616 from hashicorp/f-ui-promote-canary
UI: Promote canary
- Loading branch information
Showing
9 changed files
with
145 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Watchable from './watchable'; | ||
|
||
export default Watchable.extend({ | ||
promote(deployment) { | ||
const id = deployment.get('id'); | ||
const url = urlForAction(this.urlForFindRecord(id, 'deployment'), '/promote'); | ||
return this.ajax(url, 'POST', { | ||
data: { | ||
DeploymentId: id, | ||
All: true, | ||
}, | ||
}); | ||
}, | ||
}); | ||
|
||
// The deployment action API endpoints all end with the ID | ||
// /deployment/:action/:deployment_id instead of /deployment/:deployment_id/:action | ||
function urlForAction(url, extension = '') { | ||
const [path, params] = url.split('?'); | ||
const pathParts = path.split('/'); | ||
const idPart = pathParts.pop(); | ||
let newUrl = `${pathParts.join('/')}${extension}/${idPart}`; | ||
|
||
if (params) { | ||
newUrl += `?${params}`; | ||
} | ||
|
||
return newUrl; | ||
} |
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 |
---|---|---|
@@ -1,8 +1,27 @@ | ||
import Component from '@ember/component'; | ||
import { task } from 'ember-concurrency'; | ||
import messageFromAdapterError from 'nomad-ui/utils/message-from-adapter-error'; | ||
|
||
export default Component.extend({ | ||
job: null, | ||
tagName: '', | ||
|
||
handleError() {}, | ||
|
||
isShowingDeploymentDetails: false, | ||
|
||
promote: task(function*() { | ||
try { | ||
yield this.get('job.latestDeployment.content').promote(); | ||
} catch (err) { | ||
let message = messageFromAdapterError(err); | ||
if (!message || message === 'Forbidden') { | ||
message = 'Your ACL token does not grant permission to promote deployments.'; | ||
} | ||
this.get('handleError')({ | ||
title: 'Could Not Promote Deployment', | ||
description: message, | ||
}); | ||
} | ||
}), | ||
}); |
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
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