Skip to content
Snippets Groups Projects
Commit a57e70b4 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Merge branch 'feature/53-deprecate-a-workflow-version' into 'development'

Resolve "Deprecate a  workflow version"

Closes #53

See merge request !46
parents 9837f9a1 e13dc105
No related branches found
No related tags found
2 merge requests!84Remove development branch,!46Resolve "Deprecate a workflow version"
......@@ -260,4 +260,35 @@ export class WorkflowService {
});
}
/**
* Deprecate a workflow version
* Deprecate a workflow version.
*
* Permission "workflow:update" required if you are the developer of the workflow,
* otherwise "workflow:read_status""
* @param gitCommitHash Git commit git_commit_hash of specific version.
* @param wid ID of a workflow
* @returns WorkflowVersionFull Successful Response
* @throws ApiError
*/
public static workflowVersionDeprecateWorkflowVersion(
gitCommitHash: string,
wid: string,
): CancelablePromise<WorkflowVersionFull> {
return __request(OpenAPI, {
method: 'POST',
url: '/workflows/{wid}/versions/{git_commit_hash}/deprecate',
path: {
'git_commit_hash': gitCommitHash,
'wid': wid,
},
errors: {
400: `Error decoding JWT Token`,
403: `Not authenticated`,
404: `Entity not Found`,
422: `Validation Error`,
},
});
}
}
......@@ -108,4 +108,35 @@ export class WorkflowVersionService {
});
}
/**
* Deprecate a workflow version
* Deprecate a workflow version.
*
* Permission "workflow:update" required if you are the developer of the workflow,
* otherwise "workflow:read_status""
* @param gitCommitHash Git commit git_commit_hash of specific version.
* @param wid ID of a workflow
* @returns WorkflowVersionFull Successful Response
* @throws ApiError
*/
public static workflowVersionDeprecateWorkflowVersion(
gitCommitHash: string,
wid: string,
): CancelablePromise<WorkflowVersionFull> {
return __request(OpenAPI, {
method: 'POST',
url: '/workflows/{wid}/versions/{git_commit_hash}/deprecate',
path: {
'git_commit_hash': gitCommitHash,
'wid': wid,
},
errors: {
400: `Error decoding JWT Token`,
403: `Not authenticated`,
404: `Entity not Found`,
422: `Validation Error`,
},
});
}
}
......@@ -187,7 +187,7 @@ onMounted(() => {
</div>
</form>
<div class="col-5">
You can copy objects. You have to create destination container prior
You can copy objects. You have to create destination buckets prior
to copy.<br />
You can specify folder by using '/' at destination object field. For
example, if you want to copy object under the folder named
......
<script setup lang="ts">
import { computed, onMounted, reactive, watch } from "vue";
import type { WorkflowOut, WorkflowVersionReduced } from "@/client/workflow";
import { Status, WorkflowService } from "@/client/workflow";
import {
Status,
WorkflowService,
WorkflowVersionService,
} from "@/client/workflow";
import { useRoute, useRouter } from "vue-router";
import FontAwesomeIcon from "@/components/FontAwesomeIcon.vue";
import {
......@@ -9,6 +13,9 @@ import {
sortedVersions,
} from "@/utils/Workflow";
import { determineGitIcon } from "@/utils/GitRepository";
import { useAuthStore } from "@/stores/auth";
const userRepository = useAuthStore();
// Props
// =============================================================================
......@@ -98,6 +105,20 @@ const gitIcon = computed<string>(() =>
determineGitIcon(workflowState.workflow?.repository_url)
);
const allowVersionDeprecation = computed<boolean>(() => {
if (activeVersion.value?.status === Status.PUBLISHED) {
if (userRepository.workflowReviewer || userRepository.admin) {
return true;
} else if (
userRepository.workflowDev &&
workflowState.workflow?.developer_id === userRepository.currentUID
) {
return true;
}
}
return false;
});
// Functions
// =============================================================================
function updateWorkflow(workflowId: string) {
......@@ -121,6 +142,24 @@ function updateWorkflow(workflowId: string) {
});
}
function deprecateCurrentWorkflowVersion() {
if (props.versionId) {
WorkflowVersionService.workflowVersionDeprecateWorkflowVersion(
props.versionId,
props.workflowId
).then((version) => {
if (workflowState.workflow) {
const versionIndex = workflowState.workflow.versions.findIndex(
(v) => v.git_commit_hash === version.git_commit_hash
);
if (versionIndex > -1) {
workflowState.workflow.versions[versionIndex].status = version.status;
}
}
});
}
}
// Lifecycle Events
// =============================================================================
onMounted(() => {
......@@ -183,6 +222,16 @@ onMounted(() => {
>
</div>
<div class="row align-items-center">
<div class="w-fit position-absolute start-0">
<button
v-if="props.versionId && allowVersionDeprecation"
type="button"
class="btn btn-warning"
@click="deprecateCurrentWorkflowVersion"
>
Deprecate version
</button>
</div>
<router-link
role="button"
class="btn btn-success btn-lg w-fit mx-auto"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment