mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
refactor(app): migrate the yaml inspector to react [EE-5356] (#10058)
Co-authored-by: testa113 <testa113>
This commit is contained in:
parent
23295d2736
commit
0f6607e703
14 changed files with 98 additions and 112 deletions
|
@ -1,34 +0,0 @@
|
|||
<div>
|
||||
<web-editor-form
|
||||
identifier="application-details-yaml"
|
||||
value="$ctrl.data"
|
||||
yml="true"
|
||||
placeholder="Define or paste the content of your manifest here"
|
||||
read-only="true"
|
||||
hide-title="true"
|
||||
height="{{ $ctrl.expanded ? '800px' : '500px' }}"
|
||||
>
|
||||
</web-editor-form>
|
||||
<div class="py-5">
|
||||
<span class="btn btn-light btn-sm" ng-click="$ctrl.copyYAML()">
|
||||
<pr-icon class="vertical-center" icon="'copy'"></pr-icon>
|
||||
Copy to clipboard
|
||||
</span>
|
||||
<span class="btn btn-light btn-sm space-left !ml-0" ng-click="$ctrl.toggleYAMLInspectorExpansion()">
|
||||
<pr-icon class="vertical-center" icon="'minus'" size="'sm'" ng-if="$ctrl.expanded"></pr-icon>
|
||||
<pr-icon class="vertical-center" icon="'plus'" size="'sm'" ng-if="!$ctrl.expanded"></pr-icon>
|
||||
{{ $ctrl.expanded ? 'Collapse' : 'Expand' }}
|
||||
</span>
|
||||
<span id="copyNotificationYAML" style="display: none" class="small vertical-center ml-1">
|
||||
<pr-icon class="vertical-center" icon="'check'" size="'md'" mode="'success'"></pr-icon> copied
|
||||
</span>
|
||||
|
||||
<be-teaser-button
|
||||
class="float-right"
|
||||
feature-id="$ctrl.limitedFeature"
|
||||
message="'Applies any changes that you make in the YAML editor by calling the Kubernetes API to patch the relevant resources. Any resource removals or unexpected resource additions that you make in the YAML will be ignored. Note that editing is disabled for resources in namespaces marked as system.'"
|
||||
heading="'Apply YAML changes'"
|
||||
button-text="'Apply changes'"
|
||||
></be-teaser-button>
|
||||
</div>
|
||||
</div>
|
|
@ -1,8 +0,0 @@
|
|||
angular.module('portainer.kubernetes').component('kubernetesYamlInspector', {
|
||||
templateUrl: './yamlInspector.html',
|
||||
controller: 'KubernetesYamlInspectorController',
|
||||
bindings: {
|
||||
key: '@',
|
||||
data: '<',
|
||||
},
|
||||
});
|
|
@ -1,46 +0,0 @@
|
|||
import angular from 'angular';
|
||||
import YAML from 'yaml';
|
||||
import { FeatureId } from '@/react/portainer/feature-flags/enums';
|
||||
|
||||
class KubernetesYamlInspectorController {
|
||||
/* @ngInject */
|
||||
|
||||
constructor(clipboard) {
|
||||
this.clipboard = clipboard;
|
||||
this.expanded = false;
|
||||
}
|
||||
|
||||
cleanYamlUnwantedFields(yml) {
|
||||
try {
|
||||
const ymls = yml.split('---');
|
||||
const cleanYmls = ymls.map((yml) => {
|
||||
const y = YAML.parse(yml);
|
||||
if (y.metadata) {
|
||||
delete y.metadata.managedFields;
|
||||
delete y.metadata.resourceVersion;
|
||||
}
|
||||
return YAML.stringify(y);
|
||||
});
|
||||
return cleanYmls.join('---\n');
|
||||
} catch (e) {
|
||||
return yml;
|
||||
}
|
||||
}
|
||||
|
||||
copyYAML() {
|
||||
this.clipboard.copyText(this.data);
|
||||
$('#copyNotificationYAML').show().fadeOut(2500);
|
||||
}
|
||||
|
||||
toggleYAMLInspectorExpansion() {
|
||||
this.expanded = !this.expanded;
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
this.data = this.cleanYamlUnwantedFields(this.data);
|
||||
this.limitedFeature = FeatureId.K8S_EDIT_YAML;
|
||||
}
|
||||
}
|
||||
|
||||
export default KubernetesYamlInspectorController;
|
||||
angular.module('portainer.kubernetes').controller('KubernetesYamlInspectorController', KubernetesYamlInspectorController);
|
Loading…
Add table
Add a link
Reference in a new issue