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

Add button to deprecate a workflow version

#53
parent 9837f9a1
No related branches found
No related tags found
2 merge requests!84Remove development branch,!46Resolve "Deprecate a workflow version"
Pipeline #28015 passed
...@@ -260,4 +260,35 @@ export class WorkflowService { ...@@ -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 { ...@@ -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(() => { ...@@ -187,7 +187,7 @@ onMounted(() => {
</div> </div>
</form> </form>
<div class="col-5"> <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 /> to copy.<br />
You can specify folder by using '/' at destination object field. For You can specify folder by using '/' at destination object field. For
example, if you want to copy object under the folder named example, if you want to copy object under the folder named
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, reactive, watch } from "vue"; import { computed, onMounted, reactive, watch } from "vue";
import type { WorkflowOut, WorkflowVersionReduced } from "@/client/workflow"; 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 { useRoute, useRouter } from "vue-router";
import FontAwesomeIcon from "@/components/FontAwesomeIcon.vue"; import FontAwesomeIcon from "@/components/FontAwesomeIcon.vue";
import { import {
...@@ -9,6 +13,9 @@ import { ...@@ -9,6 +13,9 @@ import {
sortedVersions, sortedVersions,
} from "@/utils/Workflow"; } from "@/utils/Workflow";
import { determineGitIcon } from "@/utils/GitRepository"; import { determineGitIcon } from "@/utils/GitRepository";
import { useAuthStore } from "@/stores/auth";
const userRepository = useAuthStore();
// Props // Props
// ============================================================================= // =============================================================================
...@@ -98,6 +105,20 @@ const gitIcon = computed<string>(() => ...@@ -98,6 +105,20 @@ const gitIcon = computed<string>(() =>
determineGitIcon(workflowState.workflow?.repository_url) 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 // Functions
// ============================================================================= // =============================================================================
function updateWorkflow(workflowId: string) { function updateWorkflow(workflowId: string) {
...@@ -121,6 +142,24 @@ 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 // Lifecycle Events
// ============================================================================= // =============================================================================
onMounted(() => { onMounted(() => {
...@@ -183,6 +222,16 @@ onMounted(() => { ...@@ -183,6 +222,16 @@ onMounted(() => {
> >
</div> </div>
<div class="row align-items-center"> <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 <router-link
role="button" role="button"
class="btn btn-success btn-lg w-fit mx-auto" 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