-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBP-10987-1
More file actions
841 lines (772 loc) · 39.6 KB
/
Copy pathBP-10987-1
File metadata and controls
841 lines (772 loc) · 39.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
import React, { useEffect, useState } from 'react';
import Dialog from '@mui/material/Dialog';
import Slide from '@mui/material/Slide';
import Grid from '@mui/material/Grid';
import { Input } from '../../../components/genericComponents/Input';
import { getCommonFunctions } from '../../serviceRevamp/add/ci_flow/SourceDetails';
import { Loading } from '../../utils/Loading';
import { Link } from 'react-router-dom';
import { ValidateDataSet, VALIDATION_TYPE_REQUIRED } from '../../../util/Validator';
import GenerateURL from '../../../util/APIUrlProvider';
import properties from '../../../properties/properties';
import InvokeApi, { PostData } from '../../../util/apiInvoker';
import { showErrorHandlerUpdated } from '../../../util/util';
import PageHeader from '../../../components/PageHeader';
import InputSkeleton from '../../../components/genericComponents/Skeletons/InputSkeleton';
import AlertStrip from '../../../components/AlertStrips';
import JiraTicketSkeleton from './JiraTicketSkeleton';
import { makeStyles } from '@mui/styles';
import useSystemSettings from '../../../hooks/useSystemSettings';
import { useDebounce } from '../../../hooks/useDebounce';
import { useCustomSnackbar } from '../../../contexts/SnackbarContext';
import Button from '../../../components/genericComponents/Button';
const INTEGRATION_TYPE_MAP = {
'jira': 'Jira',
'azure_devops': 'Azure DevOps',
'service_now': 'ServiceNow'
};
const Transition = React.forwardRef(function Transition(props, ref) {
return <Slide direction="left" ref={ref} {...props} />;
});
const useStyles = makeStyles(theme => ({
root_half_dialog: {
'& .MuiPaper-root': {
position: 'absolute',
right: 'var(--space-0)',
margin: 'var(--space-0)',
top: 'var(--space-0)',
height: '100vh',
maxHeight: '100%',
borderRadius: 'var(--radius-0)',
width: 'var(--space-704)',
maxWidth: 'var(--space-704)',
boxShadow: 'none',
backgroundColor: 'transparent',
'& .main_dialog_div': {
display: 'grid',
gridTemplateColumns: '323px 623px',
backgroundColor: 'transparent',
justifyContent: 'flex-end'
},
'& .main_dialog_hidded': {
display: 'grid',
justifyContent: 'flex-end',
gridTemplateColumns: 'var(--space-650)'
}
},
'& .three-forth-dialog__part_2': {
backgroundColor: 'var(--color-white)',
height: '100vh'
},
'& .three-forth-dialog__part_1': {
padding: 'var(--space-20)',
backgroundColor: 'var(--color-white)',
height: '100vh',
position: 'relative',
overflowY: 'scroll'
}
},
root: {
'& .MuiPaper-root': {
position: 'absolute',
right: 'var(--space-0)',
margin: 'var(--space-0)',
boxShadow: 'none',
top: 'var(--space-0)',
height: '100vh',
maxHeight: '100%',
borderRadius: 'var(--radius-0)',
width: 'var(--space-1054)',
maxWidth: 'var(--space-1054)',
backgroundColor: 'transparent',
'& .main_dialog_div': {
display: 'grid',
backgroundColor: 'transparent',
gridTemplateColumns: 'var(--space-350) var(--space-650)',
justifyContent: 'flex-end'
},
'& .main_dialog_hidded': {
display: 'grid',
gridTemplateColumns: '623px'
}
},
'& .three-forth-dialog__part_2': {
backgroundColor: 'var(--color-white)',
height: '100vh',
'& .checkbox-only-divi': {
bottom: 'var(--space-10)',
position: 'absolute',
}
},
'& .three-forth-dialog__part_1': {
padding: 'var(--space-20)',
backgroundColor: 'var(--color-white)',
height: '100vh',
position: 'relative',
overflowY: 'scroll'
}
}
}))
const AddTicketingSystemDialog = ({ open, handleOnClickClose, type, edit_id = null, refreshListingPage }) => {
const { showSnackbar } = useCustomSnackbar();
const classes = useStyles();
const ticketing_system_type = type ? type.toLowerCase() : null;
const [state, setState] = useState({
data: {},
error: {},
hide_left_div: false
})
const [data, setData] = useState({ data: {}, error: {} })
const commonFunctions = getCommonFunctions(state, setState, {});
const showInfoSection = JSON.parse(localStorage.getItem('ticketing_system_dialog_display_flag'));
const { settings, settingsLoading = true, error, specificSetting, refetch } = useSystemSettings({
settingKey: "URL_CONTROL_WHITELIST"
});
const debouncedValue = useDebounce(state.data?.server_url, 500);
useEffect(() => {
fetAllSecrets()
}, [])
useEffect(() => {
if (debouncedValue?.length > 0) {
setState((new_state) => ({
...new_state,
validationLoading: false
}))
validateServerURL();
}
}, [debouncedValue])
useEffect(() => {
setState((new_state) => ({
...new_state,
hide_left_div: showInfoSection
}))
}, [showInfoSection])
function fetAllSecrets() {
var requestInfo = {
endPoint: GenerateURL({}, properties.api.credential_all) + "?all=true",
httpMethod: "GET",
httpHeaders: { "Content-Type": "application/json" },
};
setState((new_state) => ({
...new_state,
loading_secrets: true
}));
InvokeApi(
requestInfo,
handleSecretsDataSuccessApiHit,
handleSecretsDataFailedApiHit
);
}
const handleSecretsDataSuccessApiHit = data => {
fetchAllUserGroups();
if (data && data.results && data.results.length > 0) {
let secretList = data && data.results.map(item => {
return { label: item.name, id: item.id }
})
setState((new_state) => ({
...new_state,
loading_secrets: false,
secret_list: secretList,
unable_to_load_secret: false,
error_in_loading_secrets: null
}));
} else {
setState((new_state) => ({
...new_state,
loading_secrets: false,
unable_to_load_secret: true
}));
}
}
const handleSecretsDataFailedApiHit = error => {
let error_msg = showErrorHandlerUpdated(error)
setState((new_state) => ({
...new_state,
loading_secrets: false,
unable_to_load_secret: true,
error_in_loading_secrets: error_msg
}));
}
function validateServerURL() {
let list = JSON.parse(specificSetting);
// Remove empty strings
list = list && list.length > 0 ? list.filter(item => item.trim() !== "") :[];
let parsedHost = "";
try {
const urlObj = new URL(debouncedValue);
parsedHost = urlObj.hostname; // e.g., "bitbucket.org"
} catch (err) {
setState(new_state => ({
...new_state,
server_url_valid: false,
server_url_valid_message: "Invalid URL format",
validationLoading: false
}));
return;
}
console.log(list, parsedHost, "Parsed host check");
const isWildcard = list.includes("*");
const isValid = isWildcard || list.some(item => parsedHost.includes(item));
setState(new_state => ({
...new_state,
server_url_valid: isValid,
server_url_valid_message: isValid ? "Valid URL" : "Invalid URL",
validationLoading: false
}));
}
const getIdsFromName = (arr) => {
const { all_user_groups } = state;
return arr.map(item => {
const foundGroup = all_user_groups.find(group => group.label === item);
return foundGroup ? foundGroup.id : null;
}).filter(id => id !== null);
};
function validateAndSave() {
console.log(state.data,"afvcdshgvcgdshvc")
var result = ValidateDataSet(state.data, state.validations);
var post_url = GenerateURL({}, properties.api.ticketing_system);
if (edit_id) {
post_url = GenerateURL({ id: edit_id }, properties.api.ticketing_system_update);
}
if (result.valid) {
let write_permission_group = state.data?.write_user_groups || [];
let read_permission_group = state.data?.read_user_groups || [];
var post_data = {
...state.data,
"write_user_groups": write_permission_group,
"read_user_groups": read_permission_group,
"integration_type": ticketing_system_type && ticketing_system_type.toLowerCase(),
"credential": Number(state.data.credential_id),
"organisation_name": ticketing_system_type === "azure_devops" ? state.data.organization_name : null,
"integration_name": state.data.integration_name,
"status": "CONNECTED"
}
showSnackbar('info', "Ticketing configurations are being saved. Please wait...");
PostData(post_url, post_data, postSuccess, postFail);
setState(new_state => ({
...new_state,
post_data_loading: true
}))
} else {
let error_msg = showErrorHandlerUpdated({ ...result.error })
showSnackbar('error', "Unable to save ticketing configurations.", error_msg);
setState(new_state => ({
...new_state,
error: {
...new_state.error,
...result.error
}
}))
}
}
function postSuccess(response) {
showSnackbar('success', "Ticketing configurations are saved successfully.");
handleRefersh()
setState(new_state => ({
...new_state,
post_data_loading: false
}))
}
const handleRefersh = () => {
handleOnClickClose();
refreshListingPage();
}
function postFail(response) {
let error_msg = showErrorHandlerUpdated(response)
showSnackbar('error', "Unable to save ticketing configurations.", error_msg);
setState(new_state => ({
...new_state,
post_data_loading: false,
error_msg: error_msg,
error: {
...response
}
}))
}
const testJiraConnection = (is_edit) => {
let result;
if (is_edit) {
result = ValidateDataSet({
credential_id: state.data.credential_id,
server_url: state.data.server_url,
},
{
credential_id: [VALIDATION_TYPE_REQUIRED],
server_url: [VALIDATION_TYPE_REQUIRED],
}
);
} else {
result = ValidateDataSet({
server_url: state.data.server_url,
credential_id: state.data.credential_id,
},
{
server_url: [VALIDATION_TYPE_REQUIRED],
credential_id: [VALIDATION_TYPE_REQUIRED],
}
);
}
if (result.valid) {
const post_data = {
server_url: state.data.server_url,
credential_id: Number(state.data.credential_id),
organization_name: ticketing_system_type === "azure_devops" ? state.data.organization_name : null,
integration_type: ticketing_system_type && ticketing_system_type.toLowerCase()
};
const integrationLabel = INTEGRATION_TYPE_MAP[ticketing_system_type] || "integration";
showSnackbar('info', `Testing connection with ${integrationLabel}...`);
PostData(GenerateURL({}, properties.api.integration_test), post_data, onFetchSuccess, onFetchFail);
setState(new_state => ({
...new_state,
connection_test: true,
load_jira_users: "",
connection_test_failed: false,
}));
} else {
let error_msg = showErrorHandlerUpdated({ ...result.error })
showSnackbar('error', "Unable to test integration...", error_msg);
setState(new_state => ({
...new_state,
error: {
...new_state.error,
...result.error,
}
}));
}
}
function onFetchSuccess(response) {
console.log(response, "fkdjfjasj")
const integrationLabel = INTEGRATION_TYPE_MAP[ticketing_system_type] || "integration";
showSnackbar('success', `Connection established with ${integrationLabel}.`);
setState(new_state => ({
...new_state,
connection_test: false,
load_jira_users: 'success',
jira_users: [
...response.users
],
data: {
...new_state.data,
is_last_connected: true
}
}));
}
function onFetchFail(error) {
const integrationLabel = INTEGRATION_TYPE_MAP[ticketing_system_type] || "integration";
var error_msg = showErrorHandlerUpdated(error);
console.log("sdjsdjhdsj", error_msg);
showSnackbar('error', `Unable to test connection with ${integrationLabel}.`, error_msg);
setState(new_state => ({
...new_state,
connection_test: false,
load_jira_users: 'failed',
jira_users: [],
show_error_msg: error_msg,
connection_test_failed: true,
error: {
...new_state.error,
...error,
}
}));
}
const toggleError = () => {
setState(new_state => ({
...new_state,
detailed_error: !new_state.detailed_error,
}));
}
const fetchCurrentTicketingSystemData = (id) => {
let requestInfo = {
endPoint: GenerateURL({ id: id }, properties.api.ticketing_system_update),
httpMethod: "GET",
httpHeaders: { "Content-Type": "application/json" }
}
InvokeApi(requestInfo, fetchCurrentTicketingSystemDataSuccessApiHit, fetchCurrentTicketingSystemDataFailedApiHit);
setState(new_state => ({
...new_state,
post_data_loading: true,
}));
}
const fetchCurrentTicketingSystemDataSuccessApiHit = (response) => {
let read_user_groups = response.read_user_groups && response.read_user_groups.length > 0 ?
response.read_user_groups.map(item => {
return item.role_master.id
}) : [];
let write_user_groups = response.write_user_groups && response.write_user_groups.length > 0 ?
response.write_user_groups.map(item => {
return item.role_master.id
}) : []
setState(new_state => ({
...new_state,
post_data_loading: false,
data: {
...new_state.data,
integration_name: response.integration_name,
server_url: response.server_url,
credential_id: response.credential_id && response.credential_id.id ? response.credential_id.id : null,
read_user_groups: read_user_groups,
write_user_groups: write_user_groups,
}
}));
}
const fetchCurrentTicketingSystemDataFailedApiHit = (error) => {
setState(new_state => ({
...new_state,
post_data_loading: false,
}));
}
const fetchAllUserGroups = (data, url) => {
var requestInfo = {
endPoint: GenerateURL({}, properties.api.save_user_group) + "?all=true&no_mapping=true",
httpMethod: "GET",
httpHeaders: { "Content-Type": "application/json" }
}
InvokeApi(requestInfo, handleSuccessApiHit, handleFailedApiHit);
setState(new_state => ({
...new_state,
loading: true,
}));
}
function handleSuccessApiHit(data) {
if (edit_id) {
fetchCurrentTicketingSystemData(edit_id);
}
let list = data.results.map(item => { return { label: item.name, id: item.id } })
setState(new_state => ({
...new_state,
all_user_groups: list,
loading: false,
}));
}
function handleFailedApiHit(error) {
setState(new_state => ({
...new_state,
error: error,
loading: false
}))
}
const onKeyValueHandler = (e) => {
const k = e.target.name;
let v = e.target.value;
console.log("onKeyValueHandler Debugging:", { key: k, value: v });
if (Array.isArray(v) && v.length > 0 && typeof v[0] === "string") {
v[0] = v[0].replace(" (New Label)", "");
}
setState((new_state) => ({
...new_state,
data: {
...new_state.data,
[k]: v,
},
error: { ...new_state.error, [k]: "" },
}));
};
function onChangeDoNotshow(e) {
let key = e.target.name;
let value = e.target.value;
if (key == "dont_show_again") {
value = !data.data.dont_show_again;
}
setData((prevState) => ({
...prevState,
data: {
...prevState.data,
[key]: value,
},
error: {
...prevState.error,
[key]: ''
},
}));
}
const hideInfoPanel = () => {
console.log(data, data.data, data.data.dont_show_again, "dont_show_again")
if (data?.data?.dont_show_again) {
setDataToLocalStorage()
}
setState(new_state => ({
...new_state,
hide_left_div: true
}));
}
function setDataToLocalStorage() {
localStorage.setItem('ticketing_system_dialog_display_flag', data.data.dont_show_again);
}
const onChangeHandler = (e) => {
commonFunctions.onChangeHandler(e)
}
console.log(state.all_user_groups, "all_user_groups")
console.log("skdklslklslkldsk", state);
return (
<Dialog
open={open}
onClose={handleOnClickClose}
TransitionComponent={Transition}
className={state.hide_left_div ? classes.root_half_dialog : classes.root}
>
<div className={state.hide_left_div ? 'main_dialog_hidded' : 'main_dialog_div'}>
<button
className='btn float-cancel-button'
style={{ left: 'var(--space-0)', zIndex: 99 }}
onClick={handleOnClickClose}
>
<span className='ri-close-line'></span>
</button>
{
!state.hide_left_div && <>
<div className={"three-forth-dialog__part_2 position-relative"} style={{ boxShadow: 'calc(var(--space-20) * -1) var(--space-0) var(--space-35) var(--space-0) #0000000D inset' }}>
<div className='d-flex align-center space-between left-panel-header ' style={{ borderBottom: 'var(--space-1) solid #f1f1f1', padding: 'var(--space-10) var(--space-20)' }}>
<p>Information</p>
<button
className='btn btn-icon-only'
onClick={hideInfoPanel}
>
<span className='ri-close-line color-icon-secondary'></span>
</button>
</div>
<div className='pd-10' style={{ padding: 'var(--space-10) var(--space-20)' }}>
<div className='mb-10'>
<p className='font-16 font-weight-600 color-primary mb-10'>What is Ticketing System?</p>
<p className='font-12 color-icon-secondary' style={{ color: 'var(--color-grey-900)' }}>
BuildPiper supports integration with multiple ticketing systems, including Jira, Bitbucket, and Azure DevOps. These integrations enhance BuildPiper's capabilities in several ways:
</p>
</div>
<div className='mb-10'>
<span className='font-12 font-weight-600 color-primary mb-10'>Pipelines : </span>
<p className='font-12 color-icon-secondary ' style={{ color: 'var(--color-grey-900)', display: "inline" }}>
Comprehensive CI/CD pipelines can be constructed by incorporating detailed information directly from ticketing systems like Jira or ServiceNow.
</p>
</div>
<div className='mb-10'>
<span className='font-12 font-weight-600 color-primary mb-10'>Release Packages: </span>
<p className='font-12 color-icon-secondary ' style={{ color: 'var(--color-grey-900)', display: "inline" }}>
BuildPiper efficiently gathers and consolidates feature, bug, and story details from ticketing systems, creating a unified release package for deployment across various environments, etc.
</p>
</div>
</div>
<div className='checkbox-only-divi' style={{ padding: 'var(--space-10) var(--space-20)' }}>
<Input
type="simple-checkbox"
name="dont_show_again"
label="Dont show this again"
mandatorySign
data={data.data}
error={data.error}
onChangeHandler={onChangeDoNotshow}
/>
</div>
</div>
</>
}
<div className={"three-forth-dialog__part_1"} style={state.hide_left_div ? {} : { boxShadow: 'var(--space-0) var(--space-8) var(--space-24) var(--space-0) var(--color-overlay-black-07)' }}>
<PageHeader
heading={`${ticketing_system_type === "jira" ? "Jira" : ticketing_system_type === "azure_devops" ? "Azure Devops" : ticketing_system_type === "service_now" ? "Service Now" : null} Ticketing System Integration`}
icon={null}
imgIcon={ticketing_system_type === "jira" ? '/images/logos/jira_icon.svg' : ticketing_system_type === "azure_devops" ? '/images/logos/azure_devops.svg' : ticketing_system_type === "service_now" ? '/images/logos/sevice_now.svg' : null}
primaryButton={null}
commonDivMargin={true}
/>
{
state.post_data_loading ?
<JiraTicketSkeleton />
:
<>
<div style={{}}>
<Grid container spacing={2} >
<>
<Grid item xs={12}>
<Input
type="text"
name="integration_name"
label="Name"
placeholder="Enter Name"
mandatorySign
info={"Name"}
error={state.error}
data={state.data}
onChangeHandler={commonFunctions.onChangeHandler}
/>
</Grid>
{/* <Grid item xs={12}>
<Input
type="text"
name="server_url"
label="Server URL"
placeholder="email address"
mandatorySign
info={"Offical JIRA URL"}
error={state.error}
data={state.data}
onChangeHandler={onChangeHandler}
/>
</Grid> */}
<Grid item lg={12}>
<Input
type="text"
label="Server URL"
name="server_url"
data={state.data}
error={state.error}
placeholder={"Enter URL"}
mandatorySign
onChangeHandler={onChangeHandler}
// paramsHeading={
// <div className='d-flex align-center color-key-78 font-12'>
// <span className='ri-information-line font-16' style={{ lineHeight: 'var(--line-height-1-2)' }}></span>
// Enter a unique version number for this release with at least two parts
// </div>
// }
info={"Offical JIRA URL"}
extraDiv={
state.data?.server_url && !state?.validationLoading ?
!state.server_url_valid ?
<div className='d-flex align-center' style={{ gap: 'var(--space-4)' }}>
<span className="ri-close-circle-fill font-16 line-height-normal" style={{ color: 'var(--color-error-500)' }}></span>
<span style={{ color: 'var(--color-error-500)' }} className='font-12 font-weight-500'>{state.server_url_valid_message}</span>
</div>
:
<div className='d-flex align-center' style={{ gap: 'var(--space-4)' }}>
<span className="ri-checkbox-circle-fill font-16 line-height-normal" style={{ color: 'var(--color-success-500)' }}></span>
<span style={{ color: 'var(--color-success-500)' }} className='font-12 font-weight-500'>{state.server_url_valid_message}</span>
</div>
: null
}
/>
</Grid>
{
ticketing_system_type == "azure_devops" &&
<Grid item xs={12}>
<Input
type="text"
name="organization_name"
label="Organization Name"
placeholder="Organization Name"
mandatorySign
error={state.error}
data={state.data}
onChangeHandler={commonFunctions.onChangeHandler}
/>
</Grid>
}
<Grid item xs={9}>
{
state.loading_secrets ?
<InputSkeleton />
:
state.unable_to_load_secret ?
<AlertStrip
message={state.error_in_loading_secrets} />
:
<Input
type="select"
name="credential_id"
label="Select Credential"
list={state.secret_list}
mandatorySign
error={state.error}
data={state.data}
onChangeHandler={commonFunctions.onChangeHandler}
/>
}
</Grid>
<Grid item xs={3} style={{ alignContent: 'center' }}>
{
// state.connection_test ?
// <div style={{}}>
// <InputSkeleton />
// </div>
// :
state.server_url_valid ?
<Button className="btn btn-primary mr-0" style={{ width: '100%', padding: 'var(--space-12) var(--space-8)' }} onClick={testJiraConnection} isLoading={state.connection_test}>Test Connection</Button>
:
state.server_url_valid ?
<button className="btn btn-primary mr-0" style={{ width: '100%', padding: 'var(--space-12) var(--space-8)' }} onClick={testJiraConnection}>Test Connection</button>
:
<button className="btn btn-grey mr-0" style={{ width: '100%', padding: 'var(--space-12) var(--space-8)' }} onClick={() => {}}>Test Connection</button>
}
</Grid>
{
state.data.server_url && (state.jira_users &&
state.jira_users.length > 0) ?
<Grid item xs={12}>
<AlertStrip message={"Connection Established"} variant={"success"} />
</Grid>
: state.connection_test_failed || state.load_jira_users === "failed" ?
<Grid item xs={12}>
<AlertStrip
message={
<>
<div className='d-flex align-center'><div>Unable to establish connection please validate server url or choose correct credentials </div>
<div>
<button className='btn btn-link mr-0' onClick={toggleError} style={{ color: 'var(--color-tertiary-500)', padding: 'var(--space-12) var(--space-8)' }}>View Detailed Error</button>
</div>
</div>
{state.detailed_error && state.show_error_msg}
</>
}
variant={"error"} />
</Grid>
: null
}
{state.loading ?
<Loading varient="light" />
:
<>
<Grid item xs={12}>
<div className="auto-complete-dropdown auto-complete-dropdown-42 auto-complete-dropdown-ticketing">
<Input
type="auto-complete-freesolo-v2"
label="Share with user groups"
id={"read_user_groups1"}
name="read_user_groups"
list={state.all_user_groups}
freeSolo={true}
count={10}
mandatorySign
allowNewItems={false}
placeholder="Enter user group name and press enter"
getOptionLabel={(option) => option.label}
error={state.error}
data={state.data}
onChangeHandler={onKeyValueHandler}
/>
</div>
</Grid>
<Grid item xs={12}>
<div className="auto-complete-dropdown auto-complete-dropdown-42 auto-complete-dropdown-ticketing">
<Input
type="auto-complete-freesolo-v2"
label="Allow edit for user groups"
id={"write_user_groups1"}
name="write_user_groups"
list={state.all_user_groups}
freeSolo={true}
mandatorySign
count={10}
allowNewItems={false}
placeholder="Enter user group name and press enter"
getOptionLabel={(option) => option.label}
error={state.error}
data={state.data}
onChangeHandler={onKeyValueHandler}
/>
</div>
</Grid>
</>
}
</>
</Grid>
</div>
{/* style={{ width: '100%', position: 'absolute', bottom: 'var(--space-20)', right: 'var(--space-20)' }} */}
<div className='d-flex align-center justify-end'>
<button className='btn btn-transparent mr-5' onClick={() => handleOnClickClose()}>Cancel</button>
<Button onClick={state.load_jira_users == "success" && state.server_url_valid ? validateAndSave : () => { }} isLoading={state.post_data_loading} className={state.load_jira_users == "success" && state.server_url_valid ? 'btn btn-primary mr-0 d-flex align-center' : 'btn btn-disable mr-0 d-flex align-center cursor-not-allowed'}>Save</Button>
</div>
</>
}
</div>
</div>
</Dialog>
)
}
export default AddTicketingSystemDialog;