Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async getActions(props) {
const { queue, taskGroupId } = props;
if (!taskGroupId) {
return;
}
try {
const [decision, actions] = await Promise.all([
queue.task(taskGroupId),
request(
queue.buildUrl(
queue.getLatestArtifact,
taskGroupId,
'public/actions.json'
),
{ retries: 1 }
)
]);
return { decision, actions };
} catch (err) {
if (err.response && err.response.status !== 404) {
throw err;
}
return { decision: null, actions: null };
this.setState({ actionLoading: true }, async () => {
const credentials = await this.props.userSession.getCredentials();
try {
const url = urls.api(
'ec2-manager',
'v1',
`/region/${region}/instance/${instanceId}`
);
await request(url, {
extra: this.props.queue.buildExtraData(credentials),
method: 'DELETE',
credentials
});
const toast = {
text: 'Terminate',
icon:
};
this.setState({
actionLoading: false,
toasts: this.state.toasts.concat(toast)
});
} catch (error) {
this.setState({ error, actionLoading: false });
this.setState({ actionLoading: true }, async () => {
try {
const credentials =
(this.props.userSession &&
(await this.props.userSession.getCredentials())) ||
{};
await request(url, {
extra: this.props.queue.buildExtraData(credentials),
credentials,
method: action.method
});
const toast = {
text: action.title,
icon:
};
this.setState({
actionLoading: false,
toasts: this.state.toasts.concat(toast)
});
} catch (error) {
this.setState({ error, actionLoading: false });
this.setState({ actionLoading: true }, async () => {
try {
const credentials =
(this.props.userSession &&
(await this.props.userSession.getCredentials())) ||
{};
await request(url, {
extra: this.props.queue.buildExtraData(credentials),
credentials,
method: action.method
});
const toast = {
text: action.title,
icon:
};
this.setState({
actionLoading: false,
toasts: this.state.toasts.concat(toast)
});
} catch (error) {
this.setState({ error, actionLoading: false });
this.setState({ actionLoading: true }, async () => {
try {
const credentials =
(this.props.userSession &&
(await this.props.userSession.getCredentials())) ||
{};
await request(url, {
extra: this.props.queue.buildExtraData(credentials),
credentials,
method: action.method
});
const toast = {
text: action.title,
icon:
};
this.setState({
actionLoading: false,
toasts: this.state.toasts.concat(toast)
});
} catch (error) {
this.setState({ error, actionLoading: false });