mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-19 09:09:46 +01:00
add translations
This commit is contained in:
parent
3d081b300f
commit
635649d3bd
@ -16,19 +16,21 @@ import (
|
||||
type WorkflowEvent string
|
||||
|
||||
const (
|
||||
WorkflowEventItemOpened WorkflowEvent = "item_opened"
|
||||
WorkflowEventItemAddedToProject WorkflowEvent = "item_added_to_project"
|
||||
WorkflowEventItemReopened WorkflowEvent = "item_reopened"
|
||||
WorkflowEventItemClosed WorkflowEvent = "item_closed"
|
||||
WorkflowEventItemColumnChanged WorkflowEvent = "item_column_changed"
|
||||
WorkflowEventCodeChangesRequested WorkflowEvent = "code_changes_requested"
|
||||
WorkflowEventCodeReviewApproved WorkflowEvent = "code_review_approved"
|
||||
WorkflowEventPullRequestMerged WorkflowEvent = "pull_request_merged"
|
||||
WorkflowEventItemOpened WorkflowEvent = "item_opened"
|
||||
WorkflowEventItemAddedToProject WorkflowEvent = "item_added_to_project"
|
||||
WorkflowEventItemRemovedFromProject WorkflowEvent = "item_removed_from_project"
|
||||
WorkflowEventItemReopened WorkflowEvent = "item_reopened"
|
||||
WorkflowEventItemClosed WorkflowEvent = "item_closed"
|
||||
WorkflowEventItemColumnChanged WorkflowEvent = "item_column_changed"
|
||||
WorkflowEventCodeChangesRequested WorkflowEvent = "code_changes_requested"
|
||||
WorkflowEventCodeReviewApproved WorkflowEvent = "code_review_approved"
|
||||
WorkflowEventPullRequestMerged WorkflowEvent = "pull_request_merged"
|
||||
)
|
||||
|
||||
var workflowEvents = []WorkflowEvent{
|
||||
WorkflowEventItemOpened,
|
||||
WorkflowEventItemAddedToProject,
|
||||
WorkflowEventItemRemovedFromProject,
|
||||
WorkflowEventItemReopened,
|
||||
WorkflowEventItemClosed,
|
||||
WorkflowEventItemColumnChanged,
|
||||
@ -56,6 +58,8 @@ func (we WorkflowEvent) LangKey() string {
|
||||
return "projects.workflows.event.item_opened"
|
||||
case WorkflowEventItemAddedToProject:
|
||||
return "projects.workflows.event.item_added_to_project"
|
||||
case WorkflowEventItemRemovedFromProject:
|
||||
return "projects.workflows.event.item_removed_from_project"
|
||||
case WorkflowEventItemReopened:
|
||||
return "projects.workflows.event.item_reopened"
|
||||
case WorkflowEventItemClosed:
|
||||
@ -122,6 +126,10 @@ func GetWorkflowEventCapabilities() map[WorkflowEvent]WorkflowEventCapabilities
|
||||
AvailableFilters: []WorkflowFilterType{WorkflowFilterTypeIssueType, WorkflowFilterTypeLabels},
|
||||
AvailableActions: []WorkflowActionType{WorkflowActionTypeColumn, WorkflowActionTypeAddLabels, WorkflowActionTypeRemoveLabels, WorkflowActionTypeIssueState},
|
||||
},
|
||||
WorkflowEventItemRemovedFromProject: {
|
||||
AvailableFilters: []WorkflowFilterType{WorkflowFilterTypeIssueType, WorkflowFilterTypeLabels},
|
||||
AvailableActions: []WorkflowActionType{WorkflowActionTypeAddLabels, WorkflowActionTypeRemoveLabels, WorkflowActionTypeIssueState},
|
||||
},
|
||||
WorkflowEventItemReopened: {
|
||||
AvailableFilters: []WorkflowFilterType{WorkflowFilterTypeIssueType, WorkflowFilterTypeLabels},
|
||||
AvailableActions: []WorkflowActionType{WorkflowActionTypeColumn, WorkflowActionTypeAddLabels, WorkflowActionTypeRemoveLabels},
|
||||
|
||||
@ -3924,12 +3924,45 @@ workflows = Workflows
|
||||
exit_fullscreen = Exit Fullscreen
|
||||
workflows.event.item_opened = Item opened
|
||||
workflows.event.item_added_to_project = Item added to project
|
||||
workflows.event.item_removed_from_project = Item removed from project
|
||||
workflows.event.item_reopened = Item reopened
|
||||
workflows.event.item_closed = Item closed
|
||||
workflows.event.item_column_changed = Item column changed
|
||||
workflows.event.code_changes_requested = Code changes requested
|
||||
workflows.event.code_review_approved = Code review approved
|
||||
workflows.event.pull_request_merged = Pull request merged
|
||||
workflows.view_workflow_configuration = View workflow configuration
|
||||
workflows.configure_workflow = Configure automated actions for this workflow
|
||||
workflows.when = When
|
||||
workflows.run_when = This workflow will run when:
|
||||
workflows.filters = Filters
|
||||
workflows.apply_to = Apply to
|
||||
workflows.when_moved_from_column = When moved from column
|
||||
workflows.when_moved_to_column = When moved to column
|
||||
workflows.only_if_has_labels = Only if has labels
|
||||
workflows.default_workflows = Default Workflows
|
||||
workflows.actions = Actions
|
||||
workflows.move_to_column = Move to column
|
||||
workflows.add_labels = Add labels
|
||||
workflows.remove_labels = Remove labels
|
||||
workflows.any_label = Any label
|
||||
workflows.any_column = Any column
|
||||
workflows.issue_state = Issue state
|
||||
workflows.none = None
|
||||
workflows.no_change = No change
|
||||
workflows.edit = Edit
|
||||
workflows.delete = Delete
|
||||
workflows.save = Save
|
||||
workflows.clone = Clone
|
||||
workflows.cancel = Cancel
|
||||
workflows.disable = Disable
|
||||
workflows.disabled = Disabled
|
||||
workflows.enable = Enable
|
||||
workflows.enabled = Enabled
|
||||
workflows.issuesAndPullRequests = Issues and Pull Requests
|
||||
workflows.issues_only = Issues only
|
||||
workflows.pull_requests_only = Pull Requests only
|
||||
workflows.select_column = Select column ...
|
||||
|
||||
[git.filemode]
|
||||
changed_filemode = %[1]s → %[2]s
|
||||
|
||||
@ -2,6 +2,40 @@
|
||||
<div id="project-workflows"
|
||||
data-project-link="{{.ProjectLink}}"
|
||||
data-event-id="{{.workflowIDStr}}"
|
||||
data-locale-default-workflows="{{ctx.Locale.Tr "projects.workflows.default_workflows"}}"
|
||||
data-locale-view-workflow-configuration="{{ctx.Locale.Tr "projects.workflows.view_workflow_configuration"}}"
|
||||
data-locale-configure-workflow="{{ctx.Locale.Tr "projects.workflows.configure_workflow"}}"
|
||||
data-locale-when="{{ctx.Locale.Tr "projects.workflows.when"}}"
|
||||
data-locale-run-when="{{ctx.Locale.Tr "projects.workflows.run_when"}}"
|
||||
data-locale-filters="{{ctx.Locale.Tr "projects.workflows.filters"}}"
|
||||
data-locale-apply-to="{{ctx.Locale.Tr "projects.workflows.apply_to"}}"
|
||||
data-locale-when-moved-from-column="{{ctx.Locale.Tr "projects.workflows.when_moved_from_column"}}"
|
||||
data-locale-when-moved-to-column="{{ctx.Locale.Tr "projects.workflows.when_moved_to_column"}}"
|
||||
data-locale-only-if-has-labels="{{ctx.Locale.Tr "projects.workflows.only_if_has_labels"}}"
|
||||
data-locale-actions="{{ctx.Locale.Tr "projects.workflows.actions"}}"
|
||||
data-locale-move-to-column="{{ctx.Locale.Tr "projects.workflows.move_to_column"}}"
|
||||
data-locale-add-labels="{{ctx.Locale.Tr "projects.workflows.add_labels"}}"
|
||||
data-locale-remove-labels="{{ctx.Locale.Tr "projects.workflows.remove_labels"}}"
|
||||
data-locale-any-label="{{ctx.Locale.Tr "projects.workflows.any_label"}}"
|
||||
data-locale-any-column="{{ctx.Locale.Tr "projects.workflows.any_column"}}"
|
||||
data-locale-issue-state="{{ctx.Locale.Tr "projects.workflows.issue_state"}}"
|
||||
data-locale-none="{{ctx.Locale.Tr "projects.workflows.none"}}"
|
||||
data-locale-no-change="{{ctx.Locale.Tr "projects.workflows.no_change"}}"
|
||||
data-locale-edit="{{ctx.Locale.Tr "projects.workflows.edit"}}"
|
||||
data-locale-delete="{{ctx.Locale.Tr "projects.workflows.delete"}}"
|
||||
data-locale-save="{{ctx.Locale.Tr "projects.workflows.save"}}"
|
||||
data-locale-clone="{{ctx.Locale.Tr "projects.workflows.clone"}}"
|
||||
data-locale-cancel="{{ctx.Locale.Tr "projects.workflows.cancel"}}"
|
||||
data-locale-disable="{{ctx.Locale.Tr "projects.workflows.disable"}}"
|
||||
data-locale-disabled="{{ctx.Locale.Tr "projects.workflows.disabled"}}"
|
||||
data-locale-enable="{{ctx.Locale.Tr "projects.workflows.enable"}}"
|
||||
data-locale-enabled="{{ctx.Locale.Tr "projects.workflows.enabled"}}"
|
||||
data-locale-issues-and-pull-requests="{{ctx.Locale.Tr "projects.workflows.issues_and_pull_requests"}}"
|
||||
data-locale-issues-only="{{ctx.Locale.Tr "projects.workflows.issues_only"}}"
|
||||
data-locale-pull-requests-only="{{ctx.Locale.Tr "projects.workflows.pull_requests_only"}}"
|
||||
data-locale-select-column="{{ctx.Locale.Tr "projects.workflows.select_column"}}"
|
||||
data-locale-close-issue="{{ctx.Locale.Tr "projects.workflows.close_issue"}}"
|
||||
data-locale-reopen-issue="{{ctx.Locale.Tr "projects.workflows.reopen_issue"}}"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -4,15 +4,52 @@ import {createWorkflowStore} from './WorkflowStore.ts';
|
||||
import {svg} from '../../svg.ts';
|
||||
import {confirmModal} from '../../features/comp/ConfirmModal.ts';
|
||||
import {fomanticQuery} from '../../modules/fomantic/base.ts';
|
||||
import { locale } from 'dayjs';
|
||||
|
||||
const elRoot = useTemplateRef('elRoot');
|
||||
|
||||
const props = defineProps({
|
||||
projectLink: {type: String, required: true},
|
||||
eventID: {type: String, required: true},
|
||||
});
|
||||
const props = defineProps<{
|
||||
projectLink: string;
|
||||
eventID: string;
|
||||
locale: {
|
||||
defaultWorkflows: string;
|
||||
moveToColumn: string;
|
||||
viewWorkflowConfiguration: string;
|
||||
configureWorkflow: string;
|
||||
when: string;
|
||||
runWhen: string;
|
||||
filters: string;
|
||||
applyTo: string;
|
||||
whenMovedFromColumn: string;
|
||||
whenMovedToColumn: string;
|
||||
onlyIfHasLabels: string;
|
||||
actions: string;
|
||||
addLabels: string;
|
||||
removeLabels: string;
|
||||
anyLabel: string;
|
||||
anyColumn: string;
|
||||
issueState: string;
|
||||
none: string;
|
||||
noChange: string;
|
||||
edit: string;
|
||||
delete: string;
|
||||
save: string;
|
||||
clone: string;
|
||||
cancel: string;
|
||||
disable: string;
|
||||
disabled: string;
|
||||
enabled: string;
|
||||
enable: string;
|
||||
issuesAndPullRequests: string;
|
||||
issuesOnly: string;
|
||||
pullRequestsOnly: string;
|
||||
selectColumn: string;
|
||||
closeIssue: string;
|
||||
reopenIssue: string;
|
||||
},
|
||||
}>();
|
||||
|
||||
const store = createWorkflowStore(props);
|
||||
const store = createWorkflowStore(props.projectLink, props.eventID);
|
||||
|
||||
// Track edit state directly on workflow objects
|
||||
const previousSelection = ref(null);
|
||||
@ -648,7 +685,7 @@ onUnmounted(() => {
|
||||
<!-- Left Sidebar - Workflow List -->
|
||||
<div class="workflow-sidebar">
|
||||
<div class="sidebar-header">
|
||||
<h3>Default Workflows</h3>
|
||||
<h3>{{ locale.defaultWorkflows }}</h3>
|
||||
</div>
|
||||
|
||||
<div class="sidebar-content">
|
||||
@ -692,8 +729,6 @@ onUnmounted(() => {
|
||||
<div class="placeholder-icon">
|
||||
<i class="huge settings icon"/>
|
||||
</div>
|
||||
<h3>Select a workflow to configure</h3>
|
||||
<p>Choose an event from the left sidebar to create or configure workflows.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -709,12 +744,12 @@ onUnmounted(() => {
|
||||
class="workflow-status"
|
||||
:class="store.selectedWorkflow.enabled ? 'status-enabled' : 'status-disabled'"
|
||||
>
|
||||
{{ store.selectedWorkflow.enabled ? 'Enabled' : 'Disabled' }}
|
||||
{{ store.selectedWorkflow.enabled ? locale.enabled : locale.disabled }}
|
||||
</span>
|
||||
</h2>
|
||||
<p v-if="store.selectedWorkflow.id === 0">Configure automated actions for this workflow</p>
|
||||
<p v-else-if="isInEditMode">Configure automated actions for this workflow</p>
|
||||
<p v-else>View workflow configuration</p>
|
||||
<p v-if="store.selectedWorkflow.id === 0">{{ locale.configureWorkflow }}</p>
|
||||
<p v-else-if="isInEditMode">{{ locale.configureWorkflow }}</p>
|
||||
<p v-else>{{ locale.viewWorkflowConfiguration }}</p>
|
||||
</div>
|
||||
<div class="editor-actions-header">
|
||||
<!-- Edit Mode Buttons -->
|
||||
@ -726,7 +761,7 @@ onUnmounted(() => {
|
||||
@click="toggleEditMode"
|
||||
>
|
||||
<i class="times icon"/>
|
||||
Cancel
|
||||
{{ locale.cancel }}
|
||||
</button>
|
||||
|
||||
<!-- Save Button -->
|
||||
@ -736,7 +771,7 @@ onUnmounted(() => {
|
||||
:disabled="store.saving"
|
||||
>
|
||||
<i class="save icon"/>
|
||||
Save
|
||||
{{ locale.save }}
|
||||
</button>
|
||||
|
||||
<!-- Delete Button (only for configured workflows) -->
|
||||
@ -746,7 +781,7 @@ onUnmounted(() => {
|
||||
@click="deleteWorkflow"
|
||||
>
|
||||
<i class="trash icon"/>
|
||||
Delete
|
||||
{{ locale.delete }}
|
||||
</button>
|
||||
</template>
|
||||
|
||||
@ -758,7 +793,7 @@ onUnmounted(() => {
|
||||
@click="toggleEditMode"
|
||||
>
|
||||
<i class="edit icon"/>
|
||||
Edit
|
||||
{{ locale.edit }}
|
||||
</button>
|
||||
|
||||
<!-- Enable/Disable Button -->
|
||||
@ -766,10 +801,9 @@ onUnmounted(() => {
|
||||
class="btn"
|
||||
:class="store.selectedWorkflow.enabled ? 'btn-outline-danger' : 'btn-success'"
|
||||
@click="toggleWorkflowStatus"
|
||||
:title="store.selectedWorkflow.enabled ? 'Disable workflow' : 'Enable workflow'"
|
||||
>
|
||||
<i :class="store.selectedWorkflow.enabled ? 'pause icon' : 'play icon'"/>
|
||||
{{ store.selectedWorkflow.enabled ? 'Disable' : 'Enable' }}
|
||||
{{ store.selectedWorkflow.enabled ? locale.disable : locale.enable }}
|
||||
</button>
|
||||
|
||||
<!-- Clone Button -->
|
||||
@ -779,7 +813,7 @@ onUnmounted(() => {
|
||||
title="Clone this workflow"
|
||||
>
|
||||
<i class="copy icon"/>
|
||||
Clone
|
||||
{{ locale.clone }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
@ -788,77 +822,77 @@ onUnmounted(() => {
|
||||
<div class="editor-content">
|
||||
<div class="form" :class="{ 'readonly': !isInEditMode }">
|
||||
<div class="field">
|
||||
<label>When</label>
|
||||
<label>{{ locale.when }}</label>
|
||||
<div class="segment">
|
||||
<div class="description">
|
||||
This workflow will run when: <strong>{{ store.selectedWorkflow.display_name }}</strong>
|
||||
{{ locale.runWhen }}<strong>{{ store.selectedWorkflow.display_name }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filters Section -->
|
||||
<div class="field" v-if="hasAvailableFilters">
|
||||
<label>Filters</label>
|
||||
<label>{{ locale.filters }}</label>
|
||||
<div class="segment">
|
||||
<div class="field" v-if="hasFilter('issue_type')">
|
||||
<label>Apply to</label>
|
||||
<label>{{ locale.applyTo }}</label>
|
||||
<select
|
||||
v-if="isInEditMode"
|
||||
class="column-select"
|
||||
v-model="store.workflowFilters.issue_type"
|
||||
>
|
||||
<option value="">Issues And Pull Requests</option>
|
||||
<option value="issue">Issues</option>
|
||||
<option value="pull_request">Pull requests</option>
|
||||
<option value="">{{ locale.issuesAndPullRequests }}</option>
|
||||
<option value="issue">{{ locale.issuesOnly }}</option>
|
||||
<option value="pull_request">{{ locale.pullRequestsOnly }}</option>
|
||||
</select>
|
||||
<div v-else class="readonly-value">
|
||||
{{ store.workflowFilters.issue_type === 'issue' ? 'Issues' :
|
||||
store.workflowFilters.issue_type === 'pull_request' ? 'Pull requests' :
|
||||
'Issues And Pull Requests' }}
|
||||
{{ store.workflowFilters.issue_type === 'issue' ? locale.issuesOnly :
|
||||
store.workflowFilters.issue_type === 'pull_request' ? locale.pullRequestsOnly :
|
||||
locale.issuesAndPullRequests }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field" v-if="hasFilter('source_column')">
|
||||
<label>When moved from column</label>
|
||||
<label>{{ locale.whenMovedFromColumn }}</label>
|
||||
<select
|
||||
v-if="isInEditMode"
|
||||
v-model="store.workflowFilters.source_column"
|
||||
class="column-select"
|
||||
>
|
||||
<option value="">Any column</option>
|
||||
<option value="">{{ locale.anyColumn }}</option>
|
||||
<option v-for="column in store.projectColumns" :key="column.id" :value="String(column.id)">
|
||||
{{ column.title }}
|
||||
</option>
|
||||
</select>
|
||||
<div v-else class="readonly-value">
|
||||
{{ store.projectColumns.find(c => String(c.id) === store.workflowFilters.source_column)?.title || 'Any column' }}
|
||||
{{ store.projectColumns.find(c => String(c.id) === store.workflowFilters.source_column)?.title || locale.anyColumn }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field" v-if="hasFilter('target_column')">
|
||||
<label>When moved to column</label>
|
||||
<label>{{ locale.whenMovedToColumn }}</label>
|
||||
<select
|
||||
v-if="isInEditMode"
|
||||
v-model="store.workflowFilters.target_column"
|
||||
class="column-select"
|
||||
>
|
||||
<option value="">Any column</option>
|
||||
<option value="">{{ locale.anyColumn }}</option>
|
||||
<option v-for="column in store.projectColumns" :key="column.id" :value="String(column.id)">
|
||||
{{ column.title }}
|
||||
</option>
|
||||
</select>
|
||||
<div v-else class="readonly-value">
|
||||
{{ store.projectColumns.find(c => String(c.id) === store.workflowFilters.target_column)?.title || 'Any column' }}
|
||||
{{ store.projectColumns.find(c => String(c.id) === store.workflowFilters.target_column)?.title || locale.anyColumn }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field" v-if="hasFilter('labels')">
|
||||
<label>Only if has labels</label>
|
||||
<label>{{ locale.onlyIfHasLabels }}</label>
|
||||
<div v-if="isInEditMode" class="ui fluid multiple search selection dropdown label-dropdown">
|
||||
<input type="hidden" :value="store.workflowFilters.labels.join(',')">
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="text" :class="{ default: !store.workflowFilters.labels?.length }">
|
||||
<span v-if="!store.workflowFilters.labels?.length">Any labels</span>
|
||||
<span v-if="!store.workflowFilters.labels?.length">{{ locale.anyLabel }}</span>
|
||||
<template v-else>
|
||||
<span v-for="labelId in store.workflowFilters.labels" :key="labelId"
|
||||
class="ui label"
|
||||
@ -892,27 +926,27 @@ onUnmounted(() => {
|
||||
|
||||
<!-- Actions Section -->
|
||||
<div class="field">
|
||||
<label>Actions</label>
|
||||
<label>{{ locale.actions }}</label>
|
||||
<div class="segment">
|
||||
<div class="field" v-if="hasAction('column')">
|
||||
<label>Move to column</label>
|
||||
<label>{{ locale.moveToColumn }}</label>
|
||||
<select
|
||||
v-if="isInEditMode"
|
||||
v-model="store.workflowActions.column"
|
||||
class="column-select"
|
||||
>
|
||||
<option value="">Select column...</option>
|
||||
<option value="">{{ locale.selectColumn }}</option>
|
||||
<option v-for="column in store.projectColumns" :key="column.id" :value="String(column.id)">
|
||||
{{ column.title }}
|
||||
</option>
|
||||
</select>
|
||||
<div v-else class="readonly-value">
|
||||
{{ store.projectColumns.find(c => String(c.id) === store.workflowActions.column)?.title || 'None' }}
|
||||
{{ store.projectColumns.find(c => String(c.id) === store.workflowActions.column)?.title || locale.none }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field" v-if="hasAction('add_labels')">
|
||||
<label>Add labels</label>
|
||||
<label>{{ locale.addLabels }}</label>
|
||||
<div v-if="isInEditMode" class="ui fluid multiple search selection dropdown label-dropdown">
|
||||
<input type="hidden" :value="store.workflowActions.add_labels.join(',')">
|
||||
<i class="dropdown icon"></i>
|
||||
@ -948,7 +982,7 @@ onUnmounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="field" v-if="hasAction('remove_labels')">
|
||||
<label>Remove labels</label>
|
||||
<label>{{ locale.removeLabels }}</label>
|
||||
<div v-if="isInEditMode" class="ui fluid multiple search selection dropdown label-dropdown">
|
||||
<input type="hidden" :value="store.workflowActions.remove_labels.join(',')">
|
||||
<i class="dropdown icon"></i>
|
||||
@ -984,20 +1018,20 @@ onUnmounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="field" v-if="hasAction('issue_state')">
|
||||
<label for="issue-state-action">Issue state</label>
|
||||
<label for="issue-state-action">{{ locale.issueState }}</label>
|
||||
<select
|
||||
v-if="isInEditMode"
|
||||
id="issue-state-action"
|
||||
class="column-select"
|
||||
v-model="store.workflowActions.issue_state"
|
||||
>
|
||||
<option value="">No change</option>
|
||||
<option value="close">Close issue</option>
|
||||
<option value="reopen">Reopen issue</option>
|
||||
<option value="">{{ locale.noChange }}</option>
|
||||
<option value="close">{{ locale.closeIssue }}</option>
|
||||
<option value="reopen">{{ locale.reopenIssue }}</option>
|
||||
</select>
|
||||
<div v-else class="readonly-value">
|
||||
{{ store.workflowActions.issue_state === 'close' ? 'Close issue' :
|
||||
store.workflowActions.issue_state === 'reopen' ? 'Reopen issue' : 'No change' }}
|
||||
{{ store.workflowActions.issue_state === 'close' ? locale.closeIssue :
|
||||
store.workflowActions.issue_state === 'reopen' ? locale.reopenIssue : locale.noChange }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -80,10 +80,10 @@ const cloneActions = (actions: WorkflowActionsState): WorkflowActionsState => ({
|
||||
issue_state: actions.issue_state,
|
||||
});
|
||||
|
||||
export function createWorkflowStore(props: {projectLink: string, eventID: string}) {
|
||||
export function createWorkflowStore(projectLink: string, eventID: string) {
|
||||
const store = reactive({
|
||||
workflowEvents: [],
|
||||
selectedItem: props.eventID,
|
||||
selectedItem: eventID,
|
||||
selectedWorkflow: null,
|
||||
projectColumns: [],
|
||||
projectLabels: [], // Add labels data
|
||||
@ -113,14 +113,14 @@ export function createWorkflowStore(props: {projectLink: string, eventID: string
|
||||
},
|
||||
|
||||
async loadEvents() {
|
||||
const response = await GET(`${props.projectLink}/workflows/events`);
|
||||
const response = await GET(`${projectLink}/workflows/events`);
|
||||
store.workflowEvents = await response.json();
|
||||
return store.workflowEvents;
|
||||
},
|
||||
|
||||
async loadProjectColumns() {
|
||||
try {
|
||||
const response = await GET(`${props.projectLink}/workflows/columns`);
|
||||
const response = await GET(`${projectLink}/workflows/columns`);
|
||||
store.projectColumns = await response.json();
|
||||
console.log('[WorkflowStore] Loaded columns:', store.projectColumns);
|
||||
if (store.projectColumns.length > 0) {
|
||||
@ -159,7 +159,7 @@ export function createWorkflowStore(props: {projectLink: string, eventID: string
|
||||
|
||||
async loadProjectLabels() {
|
||||
try {
|
||||
const response = await GET(`${props.projectLink}/workflows/labels`);
|
||||
const response = await GET(`${projectLink}/workflows/labels`);
|
||||
store.projectLabels = await response.json();
|
||||
} catch (error) {
|
||||
console.error('Failed to load project labels:', error);
|
||||
@ -195,7 +195,7 @@ export function createWorkflowStore(props: {projectLink: string, eventID: string
|
||||
// Send workflow data
|
||||
console.info('Sending workflow data:', postData);
|
||||
|
||||
const response = await POST(`${props.projectLink}/workflows/${eventId}`, {
|
||||
const response = await POST(`${projectLink}/workflows/${eventId}`, {
|
||||
data: postData,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -247,7 +247,7 @@ export function createWorkflowStore(props: {projectLink: string, eventID: string
|
||||
|
||||
// Update URL to use the new workflow ID
|
||||
if (wasNewWorkflow) {
|
||||
const newUrl = `${props.projectLink}/workflows/${store.selectedWorkflow.event_id}`;
|
||||
const newUrl = `${projectLink}/workflows/${store.selectedWorkflow.event_id}`;
|
||||
window.history.replaceState({eventId: store.selectedWorkflow.event_id}, '', newUrl);
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ export function createWorkflowStore(props: {projectLink: string, eventID: string
|
||||
|
||||
// Use workflow ID for status update
|
||||
const workflowId = store.selectedWorkflow.id;
|
||||
const response = await POST(`${props.projectLink}/workflows/${workflowId}/status`, {
|
||||
const response = await POST(`${projectLink}/workflows/${workflowId}/status`, {
|
||||
data: formData,
|
||||
});
|
||||
|
||||
@ -312,7 +312,7 @@ export function createWorkflowStore(props: {projectLink: string, eventID: string
|
||||
try {
|
||||
// Use workflow ID for deletion
|
||||
const workflowId = store.selectedWorkflow.id;
|
||||
const response = await POST(`${props.projectLink}/workflows/${workflowId}/delete`, {
|
||||
const response = await POST(`${projectLink}/workflows/${workflowId}/delete`, {
|
||||
data: new FormData(),
|
||||
});
|
||||
|
||||
|
||||
@ -5,8 +5,54 @@ export async function initProjectWorkflow() {
|
||||
const workflowDiv = document.querySelector('#project-workflows');
|
||||
if (!workflowDiv) return;
|
||||
|
||||
createApp(ProjectWorkflow, {
|
||||
projectLink: workflowDiv.getAttribute('data-project-link'),
|
||||
eventID: workflowDiv.getAttribute('data-event-id'),
|
||||
}).mount(workflowDiv);
|
||||
try {
|
||||
const locale = {
|
||||
defaultWorkflows: workflowDiv.getAttribute('data-locale-default-workflows'),
|
||||
moveToColumn: workflowDiv.getAttribute('data-locale-move-to-column'),
|
||||
viewWorkflowConfiguration: workflowDiv.getAttribute('data-locale-view-workflow-configuration'),
|
||||
configureWorkflow: workflowDiv.getAttribute('data-locale-configure-workflow'),
|
||||
when: workflowDiv.getAttribute('data-locale-when'),
|
||||
runWhen: workflowDiv.getAttribute('data-locale-run-when'),
|
||||
filters: workflowDiv.getAttribute('data-locale-filters'),
|
||||
applyTo: workflowDiv.getAttribute('data-locale-apply-to'),
|
||||
whenMovedFromColumn: workflowDiv.getAttribute('data-locale-when-moved-from-column'),
|
||||
whenMovedToColumn: workflowDiv.getAttribute('data-locale-when-moved-to-column'),
|
||||
onlyIfHasLabels: workflowDiv.getAttribute('data-locale-only-if-has-labels'),
|
||||
actions: workflowDiv.getAttribute('data-locale-actions'),
|
||||
addLabels: workflowDiv.getAttribute('data-locale-add-labels'),
|
||||
removeLabels: workflowDiv.getAttribute('data-locale-remove-labels'),
|
||||
anyLabel: workflowDiv.getAttribute('data-locale-any-label'),
|
||||
anyColumn: workflowDiv.getAttribute('data-locale-any-column'),
|
||||
issueState: workflowDiv.getAttribute('data-locale-issue-state'),
|
||||
none: workflowDiv.getAttribute('data-locale-none'),
|
||||
noChange: workflowDiv.getAttribute('data-locale-no-change'),
|
||||
edit: workflowDiv.getAttribute('data-locale-edit'),
|
||||
delete: workflowDiv.getAttribute('data-locale-delete'),
|
||||
save: workflowDiv.getAttribute('data-locale-save'),
|
||||
clone: workflowDiv.getAttribute('data-locale-clone'),
|
||||
cancel: workflowDiv.getAttribute('data-locale-cancel'),
|
||||
disable: workflowDiv.getAttribute('data-locale-disable'),
|
||||
disabled: workflowDiv.getAttribute('data-locale-disabled'),
|
||||
enabled: workflowDiv.getAttribute('data-locale-enabled'),
|
||||
enable: workflowDiv.getAttribute('data-locale-enable'),
|
||||
issuesAndPullRequests: workflowDiv.getAttribute('data-locale-issues-and-pull-requests'),
|
||||
issuesOnly: workflowDiv.getAttribute('data-locale-issues-only'),
|
||||
pullRequestsOnly: workflowDiv.getAttribute('data-locale-pull-requests-only'),
|
||||
selectColumn: workflowDiv.getAttribute('data-locale-select-column'),
|
||||
closeIssue: workflowDiv.getAttribute('data-locale-close-issue'),
|
||||
reopenIssue: workflowDiv.getAttribute('data-locale-reopen-issue'),
|
||||
};
|
||||
|
||||
console.info('locale:', locale);
|
||||
|
||||
const View = createApp(ProjectWorkflow, {
|
||||
projectLink: workflowDiv.getAttribute('data-project-link'),
|
||||
eventID: workflowDiv.getAttribute('data-event-id'),
|
||||
locale,
|
||||
});
|
||||
View.mount(workflowDiv);
|
||||
} catch (err) {
|
||||
console.error('Project Workflow failed to load', err);
|
||||
workflowDiv.textContent = 'Project Workflow failed to load';
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user