Skip to content

Commit

Permalink
KWA: Use new Editor component (Monaco) (#2023)
Browse files Browse the repository at this point in the history
* kwa(front): Add new Editor component

Import new Editor component from Kubeflow Common Library and replace
all instances of previous Ace Editor.

Signed-off-by: Orfeas Kourkakis <orfeas@arrikto.com>

* Update COMMIT file to a more recent one in Kubeflow

Signed-off-by: Orfeas Kourkakis <orfeas@arrikto.com>

Signed-off-by: Orfeas Kourkakis <orfeas@arrikto.com>
  • Loading branch information
orfeas-k authored Nov 21, 2022
1 parent a5ef2db commit ae1655c
Show file tree
Hide file tree
Showing 24 changed files with 80 additions and 87 deletions.
2 changes: 1 addition & 1 deletion pkg/new-ui/v1beta1/frontend/COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c4ca7a9
1cca7b81
16 changes: 10 additions & 6 deletions pkg/new-ui/v1beta1/frontend/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss", "src/assets/css/d3.parcoords.css"],
"scripts": [
"node_modules/ace-builds/src-min/ace.js",
"node_modules/ace-builds/src-min/mode-yaml.js",
"node_modules/ace-builds/src-min/theme-xcode.js"
"assets": [
"src/favicon.ico",
"src/assets",
{
"glob": "**/*",
"input": "node_modules/monaco-editor",
"output": "assets/monaco-editor"
}
],
"styles": ["src/styles.scss", "src/assets/css/d3.parcoords.css"],
"scripts": [],
"vendorChunk": true,
"extractLicenses": false,
"buildOptimizer": false,
Expand Down
11 changes: 11 additions & 0 deletions pkg/new-ui/v1beta1/frontend/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ module.exports = function (config) {
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
files: [
{
pattern: 'node_modules/monaco-editor/**',
watched: false,
included: false,
served: true,
},
],
proxies: {
'/static/assets/monaco-editor/': '/base/node_modules/monaco-editor/',
},
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
Expand Down
26 changes: 6 additions & 20 deletions pkg/new-ui/v1beta1/frontend/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 pkg/new-ui/v1beta1/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"js-yaml": "^4.0.0",
"lodash-es": "4.17.21",
"material-icons": "^0.7.7",
"ng2-ace-editor": "^0.3.9",
"monaco-editor": "^0.33.0",
"ngx-echarts": "^8.0.1",
"ngx-json-viewer": "^2.4.0",
"rxjs": "~6.6.7",
Expand Down
5 changes: 5 additions & 0 deletions pkg/new-ui/v1beta1/frontend/proxy.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
"secure": false,
"logLevel": "debug",
"changeOrigin": true
},
"/static": {
"target": "http://localhost:4200",
"pathRewrite": { "^/static": "" },
"secure": false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@
</ng-container>

<ng-container *ngSwitchCase="kind.CUSTOM">
<div
ace-editor
class="ace-editor"
<lib-monaco-editor
[(text)]="customYaml"
mode="yaml"
theme="xcode"
></div>
[language]="'yaml'"
[readOnly]="false"
[width]="375"
[height]="300"
></lib-monaco-editor>
</ng-container>
</ng-container>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
.ace-editor {
width: 375px;
height: 300px;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { FormControl, FormGroup } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { FormModule } from 'kubeflow';
import { EditorModule, FormModule } from 'kubeflow';
import { ListKeyValueModule } from 'src/app/shared/list-key-value/list-key-value.module';
import { AceEditorModule } from 'ng2-ace-editor';

import { FormMetricsCollectorComponent } from './metrics-collector.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
Expand All @@ -20,7 +19,7 @@ describe('FormMetricsCollectorComponent', () => {
BrowserAnimationsModule,
FormModule,
ListKeyValueModule,
AceEditorModule,
EditorModule,
],
declarations: [FormMetricsCollectorComponent],
}).compileComponents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormMetricsCollectorComponent } from './metrics-collector.component';
import { FormModule } from 'kubeflow';
import { FormModule, EditorModule } from 'kubeflow';
import { ListKeyValueModule } from 'src/app/shared/list-key-value/list-key-value.module';
import { AceEditorModule } from 'ng2-ace-editor';

@NgModule({
declarations: [FormMetricsCollectorComponent],
imports: [CommonModule, FormModule, ListKeyValueModule, AceEditorModule],
imports: [CommonModule, FormModule, ListKeyValueModule, EditorModule],
exports: [FormMetricsCollectorComponent],
})
export class FormMetricsCollectorModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@
</div>
</ng-container>

<div
ace-editor
<lib-monaco-editor
[(text)]="yaml"
[language]="'yaml'"
[readOnly]="formGroup.get('type').value === 'configmap'"
(textChange)="recalculateTrialParameters($event)"
theme="xcode"
mode="yaml"
></div>
[width]="375"
[height]="350"
></lib-monaco-editor>

<mat-divider class="margin-bottom margin-top"></mat-divider>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@
.margin-top {
margin-top: 12px;
}

[ace-editor] {
height: 350px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { KWABackendService } from 'src/app/services/backend.service';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatDividerModule } from '@angular/material/divider';
import { FormModule, PopoverModule } from 'kubeflow';
import { EditorModule, FormModule, PopoverModule } from 'kubeflow';
import { ListKeyValueModule } from 'src/app/shared/list-key-value/list-key-value.module';
import { AceEditorModule } from 'ng2-ace-editor';

import { FormTrialTemplateComponent } from './trial-template.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
Expand All @@ -25,8 +24,8 @@ describe('FormTrialTemplateComponent', () => {
FormModule,
ListKeyValueModule,
MatDividerModule,
AceEditorModule,
PopoverModule,
EditorModule,
],
declarations: [FormTrialTemplateComponent],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { CommonModule } from '@angular/common';
import { MatDividerModule } from '@angular/material/divider';

import { FormTrialTemplateComponent } from './trial-template.component';
import { FormModule, PopoverModule } from 'kubeflow';
import { FormModule, PopoverModule, EditorModule } from 'kubeflow';
import { ListKeyValueModule } from 'src/app/shared/list-key-value/list-key-value.module';
import { AceEditorModule } from 'ng2-ace-editor';
import { TrialParameterComponent } from './trial-parameter/trial-parameter.component';

@NgModule({
Expand All @@ -15,8 +14,8 @@ import { TrialParameterComponent } from './trial-parameter/trial-parameter.compo
FormModule,
ListKeyValueModule,
MatDividerModule,
AceEditorModule,
PopoverModule,
EditorModule,
],
exports: [FormTrialTemplateComponent],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<h1 mat-dialog-title>Edit YAML</h1>

<div mat-dialog-content>
<div ace-editor [(text)]="yaml" theme="xcode" mode="yaml"></div>
<lib-monaco-editor
[(text)]="yaml"
[language]="'yaml'"
[readOnly]="false"
[width]="700"
[height]="350"
></lib-monaco-editor>
</div>

<div mat-dialog-actions>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[ace-editor] {
height: 350px;
width: 700px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { CommonModule } from '@angular/common';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatDialogModule } from '@angular/material/dialog';
import { FormModule } from 'kubeflow';
import { AceEditorModule } from 'ng2-ace-editor';
import { EditorModule, FormModule } from 'kubeflow';

import { YamlModalComponent } from './yaml-modal.component';

Expand All @@ -14,7 +13,7 @@ describe('YamlModalComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CommonModule, MatDialogModule, FormModule, AceEditorModule],
imports: [CommonModule, MatDialogModule, FormModule, EditorModule],
declarations: [YamlModalComponent],
providers: [
{ provide: MatDialogRef, useValue: {} },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { YamlModalComponent } from './yaml-modal.component';
import { MatDialogModule } from '@angular/material/dialog';
import { FormModule } from 'kubeflow';
import { AceEditorModule } from 'ng2-ace-editor';
import { FormModule, EditorModule } from 'kubeflow';

@NgModule({
declarations: [YamlModalComponent],
imports: [CommonModule, MatDialogModule, FormModule, AceEditorModule],
imports: [CommonModule, MatDialogModule, FormModule, EditorModule],
})
export class YamlModalModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@
></app-experiment-details-tab>
</mat-tab>
<mat-tab label="YAML">
<app-experiment-yaml
[experimentJson]="experimentDetails"
></app-experiment-yaml>
<ng-template matTabContent>
<app-experiment-yaml
[experimentJson]="experimentDetails"
></app-experiment-yaml>
</ng-template>
</mat-tab>
</mat-tab-group>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<div
ace-editor
<lib-monaco-editor
[(text)]="yaml"
theme="xcode"
mode="yaml"
[language]="'yaml'"
[readOnly]="true"
[options]="{ maxLines: 1000 }"
></div>
[height]="500"
></lib-monaco-editor>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@
display: block;
overflow: auto;
}

[ace-editor] {
width: 100%;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CommonModule } from '@angular/common';
import { AceEditorModule } from 'ng2-ace-editor';

import { ExperimentYamlComponent } from './experiment-yaml.component';
import { EditorModule } from 'kubeflow';

describe('ExperimentYamlComponent', () => {
let component: ExperimentYamlComponent;
Expand All @@ -12,7 +12,7 @@ describe('ExperimentYamlComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CommonModule, BrowserAnimationsModule, AceEditorModule],
imports: [CommonModule, BrowserAnimationsModule, EditorModule],
declarations: [ExperimentYamlComponent],
}).compileComponents();
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ExperimentYamlComponent } from './experiment-yaml.component';
import { AceEditorModule } from 'ng2-ace-editor';
import { EditorModule } from 'kubeflow';

@NgModule({
declarations: [ExperimentYamlComponent],
imports: [CommonModule, AceEditorModule],
imports: [CommonModule, EditorModule],
exports: [ExperimentYamlComponent],
})
export class ExperimentYamlModule {}
Loading

0 comments on commit ae1655c

Please sign in to comment.