Skip to content

Commit ad9ffd8

Browse files
committed
fix(uat): changes
1 parent 864bef7 commit ad9ffd8

File tree

5 files changed

+75
-32
lines changed

5 files changed

+75
-32
lines changed

src/components/bulkEdits/BulkEdits.tsx

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import {
4848

4949
import { importComponentFromFELibrary } from '@Components/common'
5050

51-
import { ReactComponent as Close } from '../../assets/icons/ic-close.svg'
5251
import { SERVER_MODE, ViewType } from '../../config'
5352
import {
5453
OutputTabs,
@@ -59,26 +58,19 @@ import {
5958
} from './bulkedit.utils'
6059
import { getSeeExample, updateBulkList, updateImpactedObjectsList } from './bulkedits.service'
6160
import { BulkEditsProps, BulkEditsState, BulkEditVersion } from './bulkEdits.type'
62-
import { OutputDivider, OutputObjectTabs, STATUS } from './constants'
61+
import {
62+
BULK_EDIT_RESIZE_HANDLE_CLASS,
63+
INITIAL_OUTPUT_PANEL_HEIGHT_PERCENTAGE,
64+
OutputDivider,
65+
OutputObjectTabs,
66+
ReadmeVersionOptions,
67+
STATUS,
68+
} from './constants'
69+
import basicValidatorSchema from './schema.json'
6370

6471
import './bulkEdit.scss'
6572

66-
const getBulkEditConfig = importComponentFromFELibrary('getBulkEditConfig', null, 'function')
67-
68-
const ReadmeVersionOptions = [
69-
...(getBulkEditConfig
70-
? [
71-
{
72-
label: 'v1beta2/application',
73-
value: BulkEditVersion.v2,
74-
},
75-
]
76-
: []),
77-
{
78-
label: 'v1beta1/application',
79-
value: BulkEditVersion.v1,
80-
},
81-
]
73+
export const getBulkEditConfig = importComponentFromFELibrary('getBulkEditConfig', null, 'function')
8274

8375
class BulkEdits extends Component<BulkEditsProps, BulkEditsState> {
8476
private editorAndOutputContainerRef = createRef<HTMLDivElement>()
@@ -227,7 +219,7 @@ class BulkEdits extends Component<BulkEditsProps, BulkEditsState> {
227219
const { showExamples } = this.state
228220

229221
return (
230-
<div className="flex bg__primary px-20 py-8 dc__border-bottom dc__content-space">
222+
<div className="flex bg__primary px-16 py-8 border__secondary--bottom dc__content-space">
231223
<div className="flexbox dc__gap-12">
232224
<h1 className="m-0 fs-13 cn-9 fw-6 lh-20 dc__open-sans">Script</h1>
233225
{!showExamples && (
@@ -296,22 +288,25 @@ class BulkEdits extends Component<BulkEditsProps, BulkEditsState> {
296288
const { codeEditorPayload, schema, activeOutputTab } = this.state
297289
const { gridTemplateRows } = this.props
298290

291+
const isV2Schema = (codeEditorPayload ?? '').match('apiVersion:\\s*batch/v1beta2')?.length
292+
293+
const validatorSchema = isV2Schema ? schema : basicValidatorSchema
294+
299295
if (activeOutputTab === 'none') {
300296
return (
301297
<div className="dc__overflow-hidden flex-grow-1">
302298
<CodeEditor
299+
key={isV2Schema}
303300
mode={MODES.YAML}
304301
height="100%"
305302
value={codeEditorPayload}
306303
onChange={this.handleConfigChange}
307-
validatorSchema={schema}
304+
validatorSchema={validatorSchema}
308305
/>
309306
</div>
310307
)
311308
}
312309

313-
// TODO: make sure to disable cursor selection while dragging
314-
315310
return (
316311
<motion.div
317312
className="dc__grid flex-grow-1 dc__overflow-hidden"
@@ -320,28 +315,30 @@ class BulkEdits extends Component<BulkEditsProps, BulkEditsState> {
320315
>
321316
<motion.div className="dc__overflow-hidden flex-grow-1">
322317
<CodeEditor
318+
key={isV2Schema}
323319
mode={MODES.YAML}
324320
height="100%"
325321
value={codeEditorPayload}
326322
onChange={this.handleConfigChange}
327-
validatorSchema={schema}
323+
validatorSchema={validatorSchema}
328324
/>
329325
</motion.div>
330326

331327
<Draggable
332-
handle=".bulk-edit"
328+
handle={`.${BULK_EDIT_RESIZE_HANDLE_CLASS}`}
329+
defaultClassNameDragging={`${BULK_EDIT_RESIZE_HANDLE_CLASS}--dragging`}
333330
axis="none"
334331
position={{ x: 0, y: 0 }}
335332
bounds={{ left: 0, right: 0 }}
336333
onDrag={this.handleDrag}
337334
>
338-
<div className="bulk-edit border__secondary flex dc__zi-10">
335+
<div className={`${BULK_EDIT_RESIZE_HANDLE_CLASS} border__primary--bottom flex dc__zi-10`}>
339336
<Icon name="ic-resize-handle" size={16} color={null} />
340337
</div>
341338
</Draggable>
342339

343340
<motion.div className="bulk-output-drawer bg__primary flexbox-col dc__overflow-auto">
344-
<div className="bulk-output-header flex left pl-20 pr-20 pt-6 dc__border-top dc__border-bottom bg__primary">
341+
<div className="bulk-output-header flex left px-16 pt-6 border__secondary--bottom bg__primary">
345342
<OutputTabs
346343
handleOutputTabs={() => this.handleOutputTab('output')}
347344
outputName={activeOutputTab}
@@ -486,7 +483,7 @@ class BulkEdits extends Component<BulkEditsProps, BulkEditsState> {
486483
const { selectedReadmeVersionOption, readmeVersionOptions } = this.state
487484

488485
return (
489-
<div className="dc__border-bottom bg__primary py-8 px-20 flex dc__content-space">
486+
<div className="border__secondary--bottom bg__primary py-10 px-16 flex dc__content-space">
490487
<div className="flex left dc__gap-16">
491488
<div className="fw-6 cn-9" data-testid="sample-application">
492489
Sample:
@@ -505,13 +502,14 @@ class BulkEdits extends Component<BulkEditsProps, BulkEditsState> {
505502
/>
506503
</div>
507504
<Button
508-
icon={<Close />}
505+
icon={<Icon name="ic-close-large" color={null} />}
509506
onClick={this.onClickHideExamples}
510507
dataTestId="hide-examples-button"
511508
variant={ButtonVariantType.borderLess}
512509
style={ButtonStyleType.negativeGrey}
513510
ariaLabel="Hide Sample"
514-
size={ComponentSizeType.small}
511+
showAriaLabelInTippy={false}
512+
size={ComponentSizeType.xs}
515513
/>
516514
</div>
517515
)
@@ -589,7 +587,7 @@ class BulkEdits extends Component<BulkEditsProps, BulkEditsState> {
589587
}
590588

591589
const BulkEditsWithUseResizable = (props: Pick<BulkEditsProps, 'serverMode'>) => {
592-
const outputHeightMV = useMotionValue(50)
590+
const outputHeightMV = useMotionValue(INITIAL_OUTPUT_PANEL_HEIGHT_PERCENTAGE)
593591
const gridTemplateRows = useMotionTemplate`1fr 1px ${outputHeightMV}%`
594592

595593
return <BulkEdits {...{ ...props, outputHeightMV, gridTemplateRows }} />

src/components/bulkEdits/bulkEdit.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
}
3131
}
3232

33+
.bulk-edit__resize-handle--dragging {
34+
user-select: none;
35+
-webkit-user-select: none;
36+
-moz-user-select: none;
37+
-ms-user-select: none;
38+
}
39+
3340
// Readme Section
3441
.deploy-chart__readme-column {
3542
.markdown {

src/components/bulkEdits/bulkedits.service.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const dryRunBulkEditScript = importComponentFromFELibrary('dryRunBulkEditScript'
2727
export function updateBulkList(request): Promise<any> {
2828
const { apiVersion } = request ?? {}
2929

30-
if (apiVersion === BulkEditVersion.v2 && postBulkEditScript) {
30+
if (postBulkEditScript && apiVersion === BulkEditVersion.v2) {
3131
return postBulkEditScript(request)
3232
}
3333

@@ -37,7 +37,7 @@ export function updateBulkList(request): Promise<any> {
3737
export function updateImpactedObjectsList(request): Promise<any> {
3838
const { apiVersion } = request
3939

40-
if (apiVersion === BulkEditVersion.v2 && dryRunBulkEditScript) {
40+
if (dryRunBulkEditScript && apiVersion === BulkEditVersion.v2) {
4141
return dryRunBulkEditScript(request)
4242
}
4343

src/components/bulkEdits/constants.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { importComponentFromFELibrary } from '@Components/common'
18+
19+
import { BulkEditVersion } from './bulkEdits.type'
20+
21+
const getBulkEditConfig = importComponentFromFELibrary('getBulkEditConfig', null, 'function')
22+
1723
export enum OutputObjectTabs {
1824
OUTPUT = 'Output',
1925
IMPACTED_OBJECTS = 'Impacted objects',
@@ -25,3 +31,22 @@ export const STATUS = {
2531
}
2632

2733
export const OutputDivider = '-----------------------------------------------------------------'
34+
35+
export const BULK_EDIT_RESIZE_HANDLE_CLASS = 'bulk-edit__resize-handle'
36+
37+
export const ReadmeVersionOptions = [
38+
...(getBulkEditConfig
39+
? [
40+
{
41+
label: 'v1beta2/application',
42+
value: BulkEditVersion.v2,
43+
},
44+
]
45+
: []),
46+
{
47+
label: 'v1beta1/application',
48+
value: BulkEditVersion.v1,
49+
},
50+
]
51+
52+
export const INITIAL_OUTPUT_PANEL_HEIGHT_PERCENTAGE = 50

src/components/bulkEdits/schema.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Bulk Edit Application batch/v1beta2 Schema",
4+
"type": "object",
5+
"description": "Input Script for bulk edit",
6+
"properties": {
7+
"apiVersion": {
8+
"type": "string",
9+
"enum": ["batch/v1beta1", "batch/v1beta2"],
10+
"description": "API version of the bulk edit schema"
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)