Skip to content

Prod release #627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/common/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,15 @@ axiosRetry(axios, {
* @param {String} token The token
* @returns
*/
async function createSelfServiceProject(name, description, type) {
async function createSelfServiceProject(name, description, type, token) {
const projectObj = {
name,
description,
type,
};

const token = await m2mHelper.getM2MToken();
if (!token) {
token = await m2mHelper.getM2MToken();
}
const url = `${config.PROJECTS_API_URL}`;
const res = await axios.post(url, projectObj, {
headers: { Authorization: `Bearer ${token}` },
Expand Down
9 changes: 5 additions & 4 deletions src/services/ChallengeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,8 @@ async function createChallenge(currentUser, challenge, userToken) {
challenge.projectId = await helper.createSelfServiceProject(
selfServiceProjectName,
"N/A",
config.NEW_SELF_SERVICE_PROJECT_TYPE
config.NEW_SELF_SERVICE_PROJECT_TYPE,
userToken
);
}

Expand Down Expand Up @@ -1613,8 +1614,8 @@ async function updateChallenge(currentUser, challengeId, data) {
// TODO: Fix this Tech Debt once legacy is turned off
const finalStatus = data.status || challenge.status;
const finalTimelineTemplateId = data.timelineTemplateId || challenge.timelineTemplateId;
const timelineTemplateChanged = false;
if (!_.get(data, "legacy.pureV5") && !_.get(challenge, "legacy.pureV5")) {
let timelineTemplateChanged = false;
if (!currentUser.isMachine && !hasAdminRole(currentUser) && !_.get(data, "legacy.pureV5") && !_.get(challenge, "legacy.pureV5")) {
if (
finalStatus !== constants.challengeStatuses.New &&
finalTimelineTemplateId !== challenge.timelineTemplateId
Expand Down Expand Up @@ -1747,7 +1748,7 @@ async function updateChallenge(currentUser, challengeId, data) {
const { track, type } = await challengeHelper.validateAndGetChallengeTypeAndTrack({
typeId: challenge.typeId,
trackId: challenge.trackId,
timelineTemplateId: challenge.timelineTemplateId,
timelineTemplateId: timelineTemplateChanged ? finalTimelineTemplateId : challenge.timelineTemplateId,
});

if (_.get(type, "isTask")) {
Expand Down