Skip to content
Draft
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
35 changes: 0 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,18 @@
"description": "Custom prefixes for branch names on start work screen",
"scope": "window"
},
"atlascode.jira.startWorkBranchTemplate.enableIssueTransition": {
"type": "boolean",
"default": true,
"description": "Enables the issue transition toggle on start work screen",
"scope": "window"
},
"atlascode.jira.startWorkBranchTemplate.defaultTransitionName": {
"type": "string",
"default": "",
"description": "The default transition name to use when starting work on an issue",
"scope": "window"
},
"atlascode.jira.showCreateIssueProblems": {
"type": "boolean",
"default": false,
Expand Down
4 changes: 4 additions & 0 deletions src/config/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export interface JiraExplorer {
export interface StartWorkBranchTemplate {
customPrefixes: string[];
customTemplate: string;
enableIssueTransition: boolean;
defaultTransitionName: string;
}

export interface JiraHover {
Expand Down Expand Up @@ -202,6 +204,8 @@ const emptyTodoIssues: TodoIssues = {
const emptyStartWorkBranchTemplate: StartWorkBranchTemplate = {
customPrefixes: [],
customTemplate: '{{prefix}}/{{issueKey}}-{{summary}}',
enableIssueTransition: true,
defaultTransitionName: '',
};

const emptyJiraConfig: JiraConfig = {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/ipc/toUI/startWork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface StartWorkInitMessage {
customTemplate: string;
customPrefixes: string[];
isRovoDevEnabled: boolean;
enableIssueTransition: boolean;
defaultTransitionName: string;
}

export interface StartWorkResponseMessage {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ describe('StartWorkWebviewController', () => {
customTemplate: '{issueKey}',
customPrefixes: ['feature/', 'bugfix/'],
isRovoDevEnabled: true,
enableIssueTransition: true,
defaultTransitionName: '',
};

beforeEach(() => {
Expand Down Expand Up @@ -501,6 +503,8 @@ describe('StartWorkWebviewController', () => {
mockApi.getStartWorkConfig.mockReturnValue({
customTemplate: '{issueKey}',
customPrefixes: ['feature/', 'bugfix/'],
enableIssueTransition: true,
defaultTransitionName: '',
});
});

Expand Down Expand Up @@ -534,6 +538,8 @@ describe('StartWorkWebviewController', () => {
]),
customTemplate: '{issueKey}',
customPrefixes: ['feature/', 'bugfix/'],
enableIssueTransition: true,
defaultTransitionName: '',
});
});

Expand Down Expand Up @@ -566,6 +572,8 @@ describe('StartWorkWebviewController', () => {
]),
customTemplate: '{issueKey}',
customPrefixes: ['feature/', 'bugfix/'],
enableIssueTransition: true,
defaultTransitionName: '',
});
});

Expand All @@ -582,6 +590,8 @@ describe('StartWorkWebviewController', () => {
repoData: [],
customTemplate: '{issueKey}',
customPrefixes: ['feature/', 'bugfix/'],
enableIssueTransition: true,
defaultTransitionName: '',
});
});

Expand Down Expand Up @@ -679,6 +689,8 @@ describe('StartWorkWebviewController', () => {
mockApi.getStartWorkConfig.mockReturnValue({
customTemplate: '{issueKey}',
customPrefixes: [],
enableIssueTransition: true,
defaultTransitionName: '',
});

await controller.onMessageReceived({ type: CommonActionType.Refresh });
Expand All @@ -693,6 +705,8 @@ describe('StartWorkWebviewController', () => {
]),
customTemplate: '{issueKey}',
customPrefixes: [],
enableIssueTransition: true,
defaultTransitionName: '',
});
});

Expand Down Expand Up @@ -729,6 +743,8 @@ describe('StartWorkWebviewController', () => {
mockApi.getStartWorkConfig.mockReturnValue({
customTemplate: '{issueKey}',
customPrefixes: [],
enableIssueTransition: true,
defaultTransitionName: '',
});

await controller.onMessageReceived({ type: CommonActionType.Refresh });
Expand All @@ -743,6 +759,8 @@ describe('StartWorkWebviewController', () => {
]),
customTemplate: '{issueKey}',
customPrefixes: [],
enableIssueTransition: true,
defaultTransitionName: '',
});
});
});
Expand Down
19 changes: 17 additions & 2 deletions src/react/atlascode/common/StartWorkPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ import { PanelTitle } from './PanelTitle';
type StartWorkPanelProps = CommonSubpanelProps & {
customPrefixes: string[];
customTemplate: string;
enableIssueTransition: boolean;
defaultTransitionName: string;
};

export const StartWorkPanel: React.FunctionComponent<StartWorkPanelProps> = memo(
({ visible, expanded, customPrefixes, customTemplate, onSubsectionChange }) => {
({
visible,
expanded,
customPrefixes,
customTemplate,
defaultTransitionName,
enableIssueTransition,
onSubsectionChange,
}) => {
const [internalExpanded, setInternalExpanded] = useState<boolean>(expanded);

const expansionHandler = useCallback(
Expand Down Expand Up @@ -47,7 +57,12 @@ export const StartWorkPanel: React.FunctionComponent<StartWorkPanelProps> = memo
<PanelSubtitle>configure the start work screen</PanelSubtitle>
</AccordionSummary>
<AccordionDetails>
<StartWorkSettings customPrefixes={customPrefixes} customTemplate={customTemplate} />
<StartWorkSettings
customPrefixes={customPrefixes}
customTemplate={customTemplate}
enableIssueTransition={enableIssueTransition}
defaultTransitionName={defaultTransitionName}
/>
</AccordionDetails>
</Accordion>
);
Expand Down
72 changes: 70 additions & 2 deletions src/react/atlascode/config/StartWorkSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InlineTextEditor, InlineTextEditorList } from '@atlassianlabs/guipi-core-components';
import { Box, FormHelperText, Grid, Link, Typography } from '@mui/material';
import { Box, FormHelperText, Grid, Link, Switch, Tooltip, Typography } from '@mui/material';
import Mustache from 'mustache';
import React, { useCallback, useContext, useEffect, useState } from 'react';

Expand All @@ -9,9 +9,16 @@ import { ConfigControllerContext } from './configController';
type StartWorkSettings = {
customTemplate: string;
customPrefixes: string[];
enableIssueTransition: boolean;
defaultTransitionName: string;
};

export const StartWorkSettings: React.FunctionComponent<StartWorkSettings> = ({ customTemplate, customPrefixes }) => {
export const StartWorkSettings: React.FunctionComponent<StartWorkSettings> = ({
customTemplate,
customPrefixes,
enableIssueTransition,
defaultTransitionName,
}) => {
const controller = useContext(ConfigControllerContext);
const boxClass = useBorderBoxStyles();
const [changes, setChanges] = useState<{ [key: string]: any }>({});
Expand All @@ -21,6 +28,10 @@ export const StartWorkSettings: React.FunctionComponent<StartWorkSettings> = ({
setTemplate(customTemplate);
}, [customTemplate]);

const stopProp = useCallback((event: React.MouseEvent<HTMLElement>) => {
event.stopPropagation();
}, []);

const handlePrefixesChange = useCallback((newOptions: string[]) => {
const changes = Object.create(null);
changes['jira.startWorkBranchTemplate.customPrefixes'] = newOptions;
Expand All @@ -34,6 +45,25 @@ export const StartWorkSettings: React.FunctionComponent<StartWorkSettings> = ({
setChanges(changes);
}, []);

const handleEnableIssueTransitionChange = useCallback((enable: boolean) => {
const changes = Object.create(null);
changes['jira.startWorkBranchTemplate.enableIssueTransition'] = enable;
setChanges(changes);
}, []);

const toggleIssueTransition = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
handleEnableIssueTransitionChange(event.target.checked);
},
[handleEnableIssueTransitionChange],
);

const handleTransitionNameChange = useCallback((name: string) => {
const changes = Object.create(null);
changes['jira.startWorkBranchTemplate.defaultTransitionName'] = name;
setChanges(changes);
}, []);

useEffect(() => {
if (Object.keys(changes).length > 0) {
controller.updateConfig(changes);
Expand Down Expand Up @@ -145,6 +175,44 @@ export const StartWorkSettings: React.FunctionComponent<StartWorkSettings> = ({
</Box>
</Box>
</Grid>
<Grid item>
<Box margin={2}>
<Typography variant="h4">Enable Issue Transition</Typography>
<Typography variant="caption">
If enabled, the "Transition issue" dropdown on the Start Work page will be shown. This allows
you to choose which status the issue should move to when starting work.
</Typography>
<Box marginTop={1} paddingBottom={2}>
<Tooltip title={enableIssueTransition ? 'Disable issue transition' : 'Enable issue transition'}>
<Switch
color="primary"
size="small"
checked={enableIssueTransition}
onClick={stopProp}
onChange={toggleIssueTransition}
/>
</Tooltip>
</Box>
</Box>
</Grid>
<Grid item>
<Box margin={2}>
<Typography variant="h4">Default Issue Transition</Typography>
<Typography variant="caption">
The "Transition issue" dropdown on the Start Work page lets you choose which status the issue
should move to. By default, it is set to "In Progress". To change the default selection in the
dropdown, enter a transition name below.
</Typography>
<Box marginTop={1} paddingBottom={2}>
<InlineTextEditor
fullWidth
label="Default Transition Name"
defaultValue={defaultTransitionName}
onSave={handleTransitionNameChange}
/>
</Box>
</Box>
</Grid>
</Grid>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export const AdvancedConfigsPanel: React.FunctionComponent<AdvancedConfigsProps>
onSubsectionChange={onSubsectionChange}
customPrefixes={config[`${ConfigSection.Jira}.startWorkBranchTemplate.customPrefixes`]}
customTemplate={config[`${ConfigSection.Jira}.startWorkBranchTemplate.customTemplate`]}
defaultTransitionName={
config[`${ConfigSection.Jira}.startWorkBranchTemplate.defaultTransitionName`]
}
enableIssueTransition={
config[`${ConfigSection.Jira}.startWorkBranchTemplate.enableIssueTransition`]
}
/>
</Grid>
<Grid item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ import { StartWorkSettings } from './../../../StartWorkSettings';
type StartWorkPanelProps = CommonSubpanelV3Props & {
customPrefixes: string[];
customTemplate: string;
defaultTransitionName: string;
enableIssueTransition: boolean;
};

export const StartWorkPanel: React.FunctionComponent<StartWorkPanelProps> = memo(
({ visible, expanded, customPrefixes, customTemplate, onSubsectionChange }) => {
({
visible,
expanded,
customPrefixes,
customTemplate,
defaultTransitionName,
enableIssueTransition,
onSubsectionChange,
}) => {
const [internalExpanded, setInternalExpanded] = useState<boolean>(expanded);

const expansionHandler = useCallback(
Expand Down Expand Up @@ -47,7 +57,12 @@ export const StartWorkPanel: React.FunctionComponent<StartWorkPanelProps> = memo
<PanelSubtitle>configure the start work screen</PanelSubtitle>
</AccordionSummary>
<AccordionDetails>
<StartWorkSettings customPrefixes={customPrefixes} customTemplate={customTemplate} />
<StartWorkSettings
customPrefixes={customPrefixes}
customTemplate={customTemplate}
enableIssueTransition={enableIssueTransition}
defaultTransitionName={defaultTransitionName}
/>
</AccordionDetails>
</Accordion>
);
Expand Down
6 changes: 6 additions & 0 deletions src/react/atlascode/config/jira/JiraPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ export const JiraPanel: React.FunctionComponent<JiraPanelProps> = ({
onSubsectionChange={onSubsectionChange}
customPrefixes={config[`${ConfigSection.Jira}.startWorkBranchTemplate.customPrefixes`]}
customTemplate={config[`${ConfigSection.Jira}.startWorkBranchTemplate.customTemplate`]}
enableIssueTransition={
config[`${ConfigSection.Jira}.startWorkBranchTemplate.enableIssueTransition`]
}
defaultTransitionName={
config[`${ConfigSection.Jira}.startWorkBranchTemplate.defaultTransitionName`]
}
/>
</Grid>
<Grid item>
Expand Down
Loading