Skip to content
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

feat: issue trace to jira #8118

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 18 additions & 1 deletion backend/plugins/jira/api/blueprint_v200.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,25 @@ func makeDataSourcePipelinePlanV200(
if err != nil {
return nil, err
}

stage = append(stage, task)

// add issue_trace stage
if scopeConfig == nil || scopeConfig.EnableIssueTrace == nil || *scopeConfig.EnableIssueTrace {
j := i + 1
if j == len(plan) {
plan = append(plan, nil)
}
plan[j] = coreModels.PipelineStage{
{
Plugin: "issue_trace",
Options: map[string]interface{}{
"plugin": "issue_trace",
"connectionId": connection.ID,
"boardId": scope.BoardId,
},
},
}
}
plan[i] = stage
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package migrationscripts

import (
"github.com/apache/incubator-devlake/core/context"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/helpers/migrationhelper"
)

type jiraScopeConfig20240926 struct {
EnableIssueTrace *bool `json:"enableIssueTrace" gorm:"type:boolean"`
}

func (jiraScopeConfig20240926) TableName() string {
return "_tool_jira_scope_configs"
}

type addEnableIssueTrace20240926 struct{}

func (script *addEnableIssueTrace20240926) Up(basicRes context.BasicRes) errors.Error {
return migrationhelper.AutoMigrateTables(basicRes, &jiraScopeConfig20240926{})
}

func (*addEnableIssueTrace20240926) Version() uint64 {
return 20240926142316
}

func (*addEnableIssueTrace20240926) Name() string {
return "add enable_issue_trace to scope config"
}
1 change: 1 addition & 0 deletions backend/plugins/jira/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ func All() []plugin.MigrationScript {
new(changeIssueComponentType),
new(flushJiraIssues),
new(addJiraServerInfo),
new(addEnableIssueTrace20240926),
}
}
1 change: 1 addition & 0 deletions backend/plugins/jira/models/scope_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type JiraScopeConfig struct {
RemotelinkRepoPattern []CommitUrlPattern `mapstructure:"remotelinkRepoPattern,omitempty" json:"remotelinkRepoPattern" gorm:"type:json;serializer:json"`
TypeMappings map[string]TypeMapping `mapstructure:"typeMappings,omitempty" json:"typeMappings" gorm:"type:json;serializer:json"`
ApplicationType string `mapstructure:"applicationType,omitempty" json:"applicationType" gorm:"type:varchar(255)"`
EnableIssueTrace *bool `mapstructure:"enableIssueTrace,omitempty" json:"enableIssueTrace" gorm:"type:boolean"`
}

func (r *JiraScopeConfig) SetConnectionId(c *JiraScopeConfig, connectionId uint64) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const ScopeConfigForm = ({
title="Data Entities"
description={
<>
Select the data entities you wish to collect for the Data Scope.
Select the data entities you wish to collect for the Data Scope.
<ExternalLink link="{DOC_URL.DATA_ENTITIES}">Learn about data entities</ExternalLink>
</>
}
Expand Down
1 change: 1 addition & 0 deletions config-ui/src/plugins/register/jira/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const JiraConfig: IPluginConfig = {
transformation: {
storyPointField: '',
typeMappings: {},
enableIssueTrace: true,
remotelinkCommitShaPattern: '',
remotelinkRepoPattern: [],
},
Expand Down
18 changes: 16 additions & 2 deletions config-ui/src/plugins/register/jira/transformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
import { useState, useEffect } from 'react';
import { uniqWith } from 'lodash';
import { CaretRightOutlined } from '@ant-design/icons';
import { theme, Collapse, Tag, Form, Select } from 'antd';
import { theme, Collapse, Tag, Form, Select, Switch } from 'antd';

import API from '@/api';
import { PageLoading, HelpTooltip, ExternalLink } from '@/components';
import { PageLoading, HelpTooltip, ExternalLink, Block } from '@/components';
import { useProxyPrefix, useRefreshData } from '@/hooks';
import { DOC_URL } from '@/release';

Expand Down Expand Up @@ -265,6 +265,20 @@ const renderCollapseItems = ({
}
/>
</Form.Item>
<Block
title="Enable Issue Trace"
description="Parse the issue status and assignee history from Jira issue changelogs."
>
<Switch
checked={transformation.enableIssueTrace}
onChange={(checcked) =>
onChangeTransformation({
...transformation,
enableIssueTrace: checcked,
})
}
/>
</Block>
</Form>
),
},
Expand Down
20 changes: 0 additions & 20 deletions config-ui/src/routes/project/additional-settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ export const ProjectAdditionalSettings = () => {
enable: false,
prToIssueRegexp: '',
});
const [issueTrace, setIssueTrace] = useState({
enable: false,
});
const [operating, setOperating] = useState(false);
const [open, setOpen] = useState(false);

Expand All @@ -54,7 +51,6 @@ export const ProjectAdditionalSettings = () => {

const dora = project.metrics.find((ms) => ms.pluginName === 'dora');
const linker = project.metrics.find((ms) => ms.pluginName === 'linker');
const issueTrace = project.metrics.find((ms) => ms.pluginName === 'issue_trace');

setName(project.name);
setDora({
Expand All @@ -64,9 +60,6 @@ export const ProjectAdditionalSettings = () => {
enable: linker?.enable ?? false,
prToIssueRegexp: linker?.pluginOption?.prToIssueRegexp ?? RegexPrIssueDefaultValue,
});
setIssueTrace({
enable: issueTrace?.enable ?? false,
});
}, [project]);

const handleUpdate = async () => {
Expand All @@ -92,11 +85,6 @@ export const ProjectAdditionalSettings = () => {
},
enable: linker.enable,
},
{
pluginName: 'issue_trace',
pluginOption: {},
enable: issueTrace.enable,
},
],
}),
{
Expand Down Expand Up @@ -189,14 +177,6 @@ export const ProjectAdditionalSettings = () => {
/>
)}
</Block>
<Block
title={
<Checkbox checked={issueTrace.enable} onChange={(e) => setIssueTrace({ enable: e.target.checked })}>
Enable issue trace
</Checkbox>
}
description="Parse the issue status and assignee history from issue changelogs. Currently, only Jira issues are supported."
/>
<Block>
<Button type="primary" loading={operating} disabled={!name} onClick={handleUpdate}>
Save
Expand Down
5 changes: 0 additions & 5 deletions config-ui/src/routes/project/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ export const ProjectHomePage = () => {
pluginOption: {},
enable: true,
},
{
pluginName: 'issue_trace',
pluginOption: {},
enable: true,
},
],
}),
{
Expand Down
Loading