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

React Triggers page [BIVS-2800] [BIVS-2808] #1174

Merged
merged 62 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b7a5378
BIVS-2888
moczolaszlo Sep 18, 2024
0ed50d9
Merge branch 'master' into BIVS-2808
moczolaszlo Sep 18, 2024
5f9c1c0
BIVS-2808
moczolaszlo Sep 18, 2024
ea491d0
BIVS-2808
moczolaszlo Sep 18, 2024
a8c2975
BIVS-2808
moczolaszlo Sep 18, 2024
f910177
Added Selective triggering table to Triggers
Sep 18, 2024
7bcb7bb
Selective triggers
Sep 19, 2024
638ea7e
Merge branch 'master' into BIVS-2808
moczolaszlo Sep 19, 2024
ef64f8a
Implemented filtering to Selective triggers table
Sep 19, 2024
1a4ca0f
Implemented sorting
Sep 19, 2024
0e608bf
Refactor
Sep 19, 2024
ed0815d
Merge branch 'master' into BIVS-2808
moczolaszlo Sep 19, 2024
05f40a9
Added TriggerConditions
Sep 20, 2024
c3a9708
Refactor
Sep 20, 2024
25fd874
Conditions
Sep 20, 2024
0d88046
Merge branch 'master' into BIVS-2808
Sep 23, 2024
0ee7639
Added TriggersTabPanel
Sep 23, 2024
c9a5daf
Merge branch 'master' into BIVS-2808
moczolaszlo Sep 23, 2024
814418e
BIVS-2808
moczolaszlo Sep 23, 2024
46e3ca3
BIVS-2808
moczolaszlo Sep 23, 2024
df19282
Merge branch 'master' into BIVS-2808
moczolaszlo Sep 24, 2024
0a4793f
Refactor
Sep 24, 2024
259d53b
BIVS-2808
Sep 24, 2024
bd44ae1
Added ConditionCard
Sep 24, 2024
a0c86fc
BIVS-2808
Sep 24, 2024
01fd397
Submit form
Sep 24, 2024
2719a68
Merge branch 'master' into BIVS-2808
moczolaszlo Sep 24, 2024
64b0771
BIVS-2808
moczolaszlo Sep 24, 2024
694f87a
BIVS-2808
moczolaszlo Sep 24, 2024
acb3461
Merge branch 'master' into BIVS-2808
moczolaszlo Sep 25, 2024
b96b9ca
Active checkbox
Sep 25, 2024
a01a016
Edit
Sep 25, 2024
bff359b
Edit
Sep 25, 2024
c62cde7
Edit
Sep 26, 2024
5b601d9
Style active checkbox
Sep 26, 2024
daddbab
Edit triggers
Sep 26, 2024
edfcb34
Rename SelectiveTriggers to TargetBasedTriggers
Sep 26, 2024
fbf7988
Added feature flag
Sep 26, 2024
d94094e
Merge branch 'master' into BIVS-2808
Sep 26, 2024
465a3b8
Remove unused tests
moczolaszlo Sep 27, 2024
ebd73b9
Merge branch 'master' into BIVS-2808
moczolaszlo Oct 1, 2024
deef05e
BIVS-2808
moczolaszlo Oct 1, 2024
17fedce
BIVS-2808
moczolaszlo Oct 1, 2024
9be7a9e
fix
moczolaszlo Oct 2, 2024
e9ddc8d
fix
moczolaszlo Oct 2, 2024
3c17494
Merge branch 'master' into BIVS-2808
Oct 3, 2024
23a4bec
Changed notification
Oct 3, 2024
8ff37be
Fixes
Oct 3, 2024
0f68a43
Merge branch 'master' into BIVS-2808
Oct 4, 2024
5942432
Update Bitkit version
Oct 4, 2024
df4298c
Enable a triggerItem
Oct 4, 2024
9aad46f
Refactor
Oct 4, 2024
915e53c
Disabled triggerItems
Oct 4, 2024
ace779a
Design tweaks
Oct 5, 2024
660b48b
Global enable
Oct 5, 2024
50d1e10
BIVS-2808
moczolaszlo Oct 13, 2024
7296ba8
BIVS-2808
moczolaszlo Oct 13, 2024
e0bb294
BIVS-2808
moczolaszlo Oct 13, 2024
2f509da
fix
moczolaszlo Oct 14, 2024
221fb03
Merge branch 'master' into BIVS-2808
moczolaszlo Oct 14, 2024
6864647
fix
moczolaszlo Oct 14, 2024
a763c1f
BIVS-2808
moczolaszlo Oct 14, 2024
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/bitrise-io/bitrise-workflow-editor

go 1.22.0

toolchain go1.22.5
toolchain go1.23.1

require (
github.com/GeertJohan/go.rice v1.0.3
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"stepDefinitions": "spec/integration"
},
"dependencies": {
"@bitrise/bitkit": "^13.159.0",
"@bitrise/bitkit": "^13.160.0",
"@bitrise/react2angular": "^5.0.0",
"@bitrise/steplib-search": "^2.3.0",
"@chakra-ui/react": "^2.8.2",
Expand Down
7 changes: 0 additions & 7 deletions rails/strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,6 @@ def strings
notification: "You can specify Env Vars which will only be available for the steps in your <workflow_id> Workflow."
}
},
triggers: {
update_deprecated_popup: {
title: "Triggers are changing for the better",
details_1: "We're converting your current trigger maps to the new format, to enable specifying Pushes and Pull Requests separately, as well as setting the source and target branch for PRs. You don't have to worry, though, everything you've set so far will work the same!",
details_2: "For more information, please check the <a href='<url>' target='_blank'>blogpost</a>!"
}
},
stack: {
load_stacks_progress: {
in_progress: "Loading, wait a sec..."
Expand Down
9 changes: 2 additions & 7 deletions source/javascripts/_componentRegister.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ angular
.component(
'rTriggersPage',
register(TriggersPage, [
'onTriggerMapChange',
'pipelines',
'triggerMap',
'setDiscard',
'workflows',
'isWebsiteMode',
'integrationsUrl',
"onChange",
"yml",
]),
)
.component(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { EnvVar } from '@/core/models/EnvVar';
export enum WorkflowConfigTab {
CONFIGURATION = 'configuration',
PROPERTIES = 'properties',
TRIGGERS = 'triggers',
}

export type FormValues = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import omit from 'lodash/omit';
import useSearchParams from '@/hooks/useSearchParams';
import useBitriseYmlStore from '@/hooks/useBitriseYmlStore';
import { EnvVar } from '@/core/models/EnvVar';
import TriggersTabPanel from '@/pages/WorkflowsPage/components/WorkflowConfigPanel/components/TriggersTabPanel';
import useFeatureFlag from '@/hooks/useFeatureFlag';
import WorkflowConfigHeader from './components/WorkflowConfigHeader';
import ConfigurationTab from './tabs/ConfigurationTab';
import PropertiesTab from './tabs/PropertiesTab';
Expand Down Expand Up @@ -66,6 +68,8 @@ const WorkflowConfigPanelContent = () => {
updateWorkflowEnvVars,
]);

const isTargetBasedTriggersEnabled = useFeatureFlag('enable-target-based-triggers');

return (
<Tabs display="flex" flexDir="column" borderLeft="1px solid" borderColor="border/regular">
<WorkflowConfigHeader variant="panel" />
Expand All @@ -76,6 +80,11 @@ const WorkflowConfigPanelContent = () => {
<TabPanel id={WorkflowConfigTab.PROPERTIES} p="24" overflowY="auto" h="100%">
<PropertiesTab />
</TabPanel>
{isTargetBasedTriggersEnabled && (
<TabPanel id={WorkflowConfigTab.TRIGGERS} overflowY="auto" h="100%">
<TriggersTabPanel />
</TabPanel>
)}
</TabPanels>
</Tabs>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box, IconButton, Tab, TabList, Text } from '@bitrise/bitkit';
import WorkflowService from '@/core/models/WorkflowService';
import useDependantWorkflows from '@/hooks/useDependantWorkflows';
import { useWorkflowsPageStore } from '@/pages/WorkflowsPage/WorkflowsPage.store';
import useFeatureFlag from '@/hooks/useFeatureFlag';
import { useWorkflowConfigContext } from '../WorkflowConfig.context';
import { WorkflowConfigTab } from '../WorkflowConfig.types';

Expand All @@ -13,8 +14,10 @@ const WorkflowConfigHeader = ({ variant }: Props) => {
const { id, userValues } = useWorkflowConfigContext() ?? { id: '' };
const dependants = useDependantWorkflows(id);
const { openDeleteWorkflowDialog } = useWorkflowsPageStore();
const isTargetBasedTriggersEnabled = useFeatureFlag('enable-target-based-triggers');

const shouldShowDeleteButton = variant === 'panel';
const shouldShowTriggersTab = variant === 'panel' && isTargetBasedTriggersEnabled;

return (
<>
Expand All @@ -39,12 +42,11 @@ const WorkflowConfigHeader = ({ variant }: Props) => {
/>
)}
</Box>
<Box position="relative" mt="8">
<TabList paddingX="8">
<Tab id={WorkflowConfigTab.CONFIGURATION}>Configuration</Tab>
<Tab id={WorkflowConfigTab.PROPERTIES}>Properties</Tab>
</TabList>
</Box>
<TabList paddingX="8" position="relative" mt="8">
<Tab id={WorkflowConfigTab.CONFIGURATION}>Configuration</Tab>
<Tab id={WorkflowConfigTab.PROPERTIES}>Properties</Tab>
{shouldShowTriggersTab && <Tab id={WorkflowConfigTab.TRIGGERS}>Triggers</Tab>}
</TabList>
</>
);
};
Expand Down
55 changes: 25 additions & 30 deletions source/javascripts/controllers/_MainController.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {segmentTrack} from "@/utils/segmentTracking";
id: "workflows",
title: "<%= data[:strings][:main][:menus][:workflows] %>",
path: "<%= data[:routes][:endpoints][:workflows] %>",
possibleURLParameterKeys: ["workflow_id"],
possibleURLParameterKeys: ["workflow_id", "tab"],
cssClass: "workflows"
},
{
Expand Down Expand Up @@ -207,7 +207,6 @@ import {segmentTrack} from "@/utils/segmentTracking";
break;
}
case "env-vars":
case "triggers":
var loadPromises = [appService.getAppConfig()];
if (requestService.isWebsiteMode()) {
loadPromises.push(Stack.getAll());
Expand All @@ -225,37 +224,28 @@ import {segmentTrack} from "@/utils/segmentTracking";

loadPromise.then(
function () {
$q(function (deprecatedTriggerCheckResolve, deprecatedTriggerCheckReject) {
if (appService.appConfigHasDeprecatedTriggerMap()) {
appService.updateDeprecatedTriggerMap();

Popup.showNoticePopup("<%= data[:strings][:triggers][:update_deprecated_popup][:title] %>", [
"<%= data[:strings][:triggers][:update_deprecated_popup][:details_1] %>",
"<%= replaced_string(data[:strings][:triggers][:update_deprecated_popup][:details_2], [data[:routes][:blog][:new_triggers]])%>"
])
.then(function () {
return requestService.isWebsiteMode() && appService.pipelineConfig.usesRepositoryYml
? $q.when()
: viewModel.save({source: "deprecated_trigger_map_update"});
})
.then(deprecatedTriggerCheckResolve, deprecatedTriggerCheckReject);
} else {
deprecatedTriggerCheckResolve();
}
}).then(
function () {
resolve();
},
function (error) {
reject(error);
}
);
resolve();
},
function (error) {
reject(error);
}
);
break;
case "triggers":
var loadPromises = [appService.getAppConfig()];
if (requestService.isWebsiteMode()) {
loadPromises.push(appService.getPipelineConfig());
}
var loadPromise = $q.all(loadPromises);

loadPromise.then(
function () {
resolve();
},
function (error) {
reject(error);
}
);
break;
case "licenses":
var loadPromises = [appService.getAppConfig(), appService.getPipelineConfig(), appService.getPublicApiToken()];
Expand Down Expand Up @@ -318,7 +308,7 @@ import {segmentTrack} from "@/utils/segmentTracking";
);
}

viewModel.menuSelected = function (menu) {
viewModel.menuSelected = function (menu, params) {
if (menu === viewModel.currentMenu) {
return;
}
Expand Down Expand Up @@ -414,7 +404,12 @@ import {segmentTrack} from "@/utils/segmentTracking";

viewModel.currentMenu = menu;
if ($location.path() != "/" + menu.path) {
$location.path("/" + menu.path).replace();
if (params) {
$location.path("/" + menu.path).search(params).replace();
}
else {
$location.path("/" + menu.path).replace();
}
}

if (!isInitialSelection) {
Expand Down Expand Up @@ -936,7 +931,7 @@ import {segmentTrack} from "@/utils/segmentTracking";
const menu = viewModel.menus.find(m => `/${m.path}` === e.detail.path);

if (menu) {
viewModel.menuSelected(menu);
viewModel.menuSelected(menu, e.detail.params);
}
});

Expand Down
41 changes: 15 additions & 26 deletions source/javascripts/controllers/_TriggersController.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,31 @@
import {safeDigest} from "@/services/react-compat";

(function() {
"use strict";

angular
.module("BitriseWorkflowEditor")
.controller("TriggersController", function($scope, $rootScope, $location, appService, Progress, Trigger, launchDarklyService, requestService) {
.controller("TriggersController", function($rootScope, $scope, appService) {
var viewModel = this;
viewModel.pipelines = appService.appConfig.pipelines ? Object.keys(appService.appConfig.pipelines) : [];
viewModel.workflows = Object.keys(appService.appConfig.workflows).filter(function(workflowID) {
return !workflowID.startsWith('_');
});
viewModel.triggerMap = appService.appConfig.trigger_map;
viewModel.isWebsiteMode = requestService.mode === 'website';
viewModel.yml = null;

viewModel.originalTriggerMap = appService.appConfig.trigger_map;
viewModel.integrationsUrl = appService.appDetails ? '/app/' + appService.appDetails.slug + '/settings/integrations?tab=webhooks' : '';
viewModel.init = function () {
viewModel.yml = appService.appConfig;
};

$scope.$on(
"$destroy",
$rootScope.$on("MainController::changesDiscarded", function() {
appService.appConfig.trigger_map = viewModel.originalTriggerMap;
viewModel.onDiscard(viewModel.originalTriggerMap);
})
);
viewModel.onChangeYml = (yml) => {
appService.appConfig = yml;
safeDigest($rootScope);
}

$scope.$on(
"$destroy",
$rootScope.$on("MainController::savedFinishedWithSuccess", function() {
viewModel.originalTriggerMap = appService.appConfig.trigger_map;
$rootScope.$on("MainController::changesDiscarded", function() {
safeDigest($scope);
viewModel.init();
})
);

viewModel.setDiscard = function(onDiscard) {
viewModel.onDiscard = onDiscard;
}

viewModel.onTriggerMapChange = function(triggerMap) {
appService.appConfig.trigger_map = triggerMap;
$scope.$apply();
};
viewModel.init();
});
})();
72 changes: 71 additions & 1 deletion source/javascripts/core/models/BitriseYml.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,74 @@ const ChainableMockYml: BitriseYml = {
},
};

export { MockYml, ChainableMockYml };
const MockYmlWithTriggers: BitriseYml = {
...MockYml,
trigger_map: [
{
workflow: 'wf1',
push_branch: 'master',
},
{
workflow: 'wf2',
push_branch: 'release',
},
{
workflow: 'wf3',
pull_request_target_branch: '*',
},
],
workflows: {
a_release_IOS: {
triggers: {
push: [
{
branch: 'main',
enabled: false,
},
],
tag: [
{
name: {
regex: '^\\d\\.\\d\\.\\d$',
},
},
],
pull_request: [
{
comment: '[workflow: deploy]',
},
{
commit_message: {
regex: '.*\\[workflow: deploy\\].*',
},
},
],
},
},
c_staging_IOS: {
triggers: {
pull_request: [
{
target_branch: 'main',
source_branch: 'approved',
enabled: false,
},
],
},
},
},
pipelines: {
b_staging_IOS: {
triggers: {
push: [
{
branch: 'staging',
enabled: false,
},
],
},
},
},
};

export { MockYml, ChainableMockYml, MockYmlWithTriggers };
Loading