fix(ui/code-editor): stretch code editor content full height [EE-5202] (#8672)

pull/8710/head
Chaim Lev-Ari 2023-03-30 12:26:35 +03:00 committed by GitHub
parent 23e6a982b9
commit e063cba81b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 60 additions and 57 deletions

View File

@ -73,6 +73,7 @@
<box-selector options="options" slim="true" value="state.BuildType" on-change="(onChangeBuildType)"></box-selector> <box-selector options="options" slim="true" value="state.BuildType" on-change="(onChangeBuildType)"></box-selector>
<!-- web-editor --> <!-- web-editor -->
<!-- TODO use web-editor-form component -->
<div ng-show="state.BuildType === 'editor'"> <div ng-show="state.BuildType === 'editor'">
<div class="col-sm-12 form-section-title"> Web editor </div> <div class="col-sm-12 form-section-title"> Web editor </div>
<div class="form-group"> <div class="form-group">

View File

@ -135,13 +135,14 @@
<!-- !execution-method --> <!-- !execution-method -->
<!-- web-editor --> <!-- web-editor -->
<!-- TODO use web-editor-form component -->
<div ng-show="$ctrl.formValues.method === 'editor'"> <div ng-show="$ctrl.formValues.method === 'editor'">
<div class="col-sm-12 form-section-title"> Web editor </div> <div class="col-sm-12 form-section-title"> Web editor </div>
<div class="form-group"> <div class="form-group">
<div class="col-sm-12"> <div class="col-sm-12">
<code-editor <code-editor
identifier="execute-edge-job-editor" identifier="execute-edge-job-editor"
placeholder="# Define or paste the content of your script file here" placeholder="Define or paste the content of your script file here"
on-change="($ctrl.editorUpdate)" on-change="($ctrl.editorUpdate)"
value="$ctrl.model.FileContent" value="$ctrl.model.FileContent"
></code-editor> ></code-editor>

View File

@ -34,7 +34,7 @@
value="$ctrl.model.StackFileContent" value="$ctrl.model.StackFileContent"
yml="true" yml="true"
identifier="compose-editor" identifier="compose-editor"
placeholder="# Define or paste the content of your docker compose file here" placeholder="Define or paste the content of your docker compose file here"
on-change="($ctrl.onChangeComposeConfig)" on-change="($ctrl.onChangeComposeConfig)"
read-only="$ctrl.hasKubeEndpoint()" read-only="$ctrl.hasKubeEndpoint()"
> >
@ -63,7 +63,7 @@
value="$ctrl.model.StackFileContent" value="$ctrl.model.StackFileContent"
yml="true" yml="true"
identifier="kube-manifest-editor" identifier="kube-manifest-editor"
placeholder="# Define or paste the content of your manifest here" placeholder="Define or paste the content of your manifest here"
on-change="($ctrl.onChangeKubeManifest)" on-change="($ctrl.onChangeKubeManifest)"
> >
<editor-description> <editor-description>

View File

@ -8,7 +8,7 @@
on-change="($ctrl.onChangeFileContent)" on-change="($ctrl.onChangeFileContent)"
ng-required="true" ng-required="true"
yml="true" yml="true"
placeholder="# Define or paste the content of your docker compose file here" placeholder="Define or paste the content of your docker compose file here"
> >
<editor-description> <editor-description>
You can get more information about Compose file format in the You can get more information about Compose file format in the
@ -55,7 +55,7 @@
value="$ctrl.formValues.StackFileContent" value="$ctrl.formValues.StackFileContent"
on-change="($ctrl.onChangeFileContent)" on-change="($ctrl.onChangeFileContent)"
yml="true" yml="true"
placeholder="# Define or paste the content of your docker compose file here" placeholder="Define or paste the content of your docker compose file here"
ng-required="true" ng-required="true"
> >
</web-editor-form> </web-editor-form>

View File

@ -18,7 +18,7 @@
value="$ctrl.formValues.StackFileContent" value="$ctrl.formValues.StackFileContent"
on-change="($ctrl.onChangeFileContent)" on-change="($ctrl.onChangeFileContent)"
yml="true" yml="true"
placeholder="# Define or paste the content of your manifest here" placeholder="Define or paste the content of your manifest here"
ng-required="true" ng-required="true"
> >
<editor-description> <editor-description>

View File

@ -124,7 +124,7 @@
value="$ctrl.state.values" value="$ctrl.state.values"
on-change="($ctrl.editorUpdate)" on-change="($ctrl.editorUpdate)"
yml="true" yml="true"
placeholder="# Define or paste the content of your values yaml file here" placeholder="Define or paste the content of your values yaml file here"
> >
<editor-description class="vertical-center"> <editor-description class="vertical-center">
<pr-icon icon="'info'" mode="'primary'"></pr-icon> <pr-icon icon="'info'" mode="'primary'"></pr-icon>

View File

@ -159,7 +159,7 @@
value="$ctrl.formValues.DataYaml" value="$ctrl.formValues.DataYaml"
on-change="($ctrl.editorUpdate)" on-change="($ctrl.editorUpdate)"
yml="true" yml="true"
placeholder="# Define or paste key-value pairs, one pair per line" placeholder="Define or paste key-value pairs, one pair per line"
> >
</web-editor-form> </web-editor-form>
</div> </div>

View File

@ -3,7 +3,7 @@
identifier="application-details-yaml" identifier="application-details-yaml"
value="$ctrl.data" value="$ctrl.data"
yml="true" yml="true"
placeholder="# Define or paste the content of your manifest here" placeholder="Define or paste the content of your manifest here"
read-only="true" read-only="true"
hide-title="true" hide-title="true"
height="{{ $ctrl.expanded ? '800px' : '500px' }}" height="{{ $ctrl.expanded ? '800px' : '500px' }}"

View File

@ -19,7 +19,7 @@
on-change="($ctrl.onChangeFileContent)" on-change="($ctrl.onChangeFileContent)"
ng-required="true" ng-required="true"
yml="true" yml="true"
placeholder="# Define or paste the content of your manifest file here" placeholder="Define or paste the content of your manifest file here"
> >
<editor-description> <editor-description>
<p>Templates allow deploying any kind of Kubernetes resource (Deployment, Secret, ConfigMap...)</p> <p>Templates allow deploying any kind of Kubernetes resource (Deployment, Secret, ConfigMap...)</p>

View File

@ -13,7 +13,7 @@
on-change="($ctrl.onChangeFileContent)" on-change="($ctrl.onChangeFileContent)"
ng-required="true" ng-required="true"
yml="true" yml="true"
placeholder="# Define or paste the content of your manifest file here" placeholder="Define or paste the content of your manifest file here"
> >
<editor-description> <editor-description>
<p>Templates allow deploying any kind of Kubernetes resource (Deployment, Secret, ConfigMap...)</p> <p>Templates allow deploying any kind of Kubernetes resource (Deployment, Secret, ConfigMap...)</p>

View File

@ -114,11 +114,11 @@
value="ctrl.stackFileContent" value="ctrl.stackFileContent"
yml="true" yml="true"
identifier="kubernetes-deploy-editor" identifier="kubernetes-deploy-editor"
placeholder="# Define or paste the content of your manifest file here" placeholder="Define or paste the content of your manifest file here"
on-change="(ctrl.onChangeFileContent)" on-change="(ctrl.onChangeFileContent)"
> >
<editor-description> <editor-description>
<div class="text-muted small flex gap-1" ng-show="ctrl.stack.IsComposeFormat"> <div class="flex gap-1" ng-show="ctrl.stack.IsComposeFormat">
<pr-icon icon="'alert-circle'" mode="'warning'" class-name="'!mt-1'"></pr-icon> <pr-icon icon="'alert-circle'" mode="'warning'" class-name="'!mt-1'"></pr-icon>
<div> <div>
<p> <p>
@ -127,17 +127,17 @@
conversion tool which enables this. The reason for this is because Kompose now poses a security risk, since it has a number of Common Vulnerabilities and conversion tool which enables this. The reason for this is because Kompose now poses a security risk, since it has a number of Common Vulnerabilities and
Exposures (CVEs). Exposures (CVEs).
</p> </p>
<p <p>
>Unfortunately, while the Kompose project has a maintainer and is part of the CNCF, it is not being actively maintained. Releases are very infrequent and Unfortunately, while the Kompose project has a maintainer and is part of the CNCF, it is not being actively maintained. Releases are very infrequent and new
new pull requests to the project (including ones we've submitted) are taking months to be merged, with new CVEs arising in the meantime.</p pull requests to the project (including ones we've submitted) are taking months to be merged, with new CVEs arising in the meantime.
> </p>
<p> <p>
We advise installing your own instance of Kompose in a sandbox environment, performing conversions of your Docker Compose files to Kubernetes manifests and We advise installing your own instance of Kompose in a sandbox environment, performing conversions of your Docker Compose files to Kubernetes manifests and
using those manifests to set up applications. using those manifests to set up applications.
</p> </p>
</div> </div>
</div> </div>
<span class="text-muted small" ng-show="!ctrl.stack.IsComposeFormat"> <span ng-show="!ctrl.stack.IsComposeFormat">
<p class="vertical-center"> <p class="vertical-center">
<pr-icon icon="'info'" mode="'primary'"></pr-icon> <pr-icon icon="'info'" mode="'primary'"></pr-icon>
This feature allows you to deploy any kind of Kubernetes resource in this environment (Deployment, Secret, ConfigMap...). This feature allows you to deploy any kind of Kubernetes resource in this environment (Deployment, Secret, ConfigMap...).

View File

@ -114,19 +114,17 @@
on-change="(ctrl.onChangeFileContent)" on-change="(ctrl.onChangeFileContent)"
ng-required="true" ng-required="true"
yml="true" yml="true"
placeholder="# Define or paste the content of your manifest file here" placeholder="Define or paste the content of your manifest file here"
> >
<editor-description> <editor-description>
<span class="col-sm-12 text-muted small"> <p class="vertical-center">
<p class="vertical-center"> <pr-icon icon="'info'" mode="'primary'"></pr-icon>
<pr-icon icon="'info'" mode="'primary'"></pr-icon> This feature allows you to deploy any kind of Kubernetes resource in this environment (Deployment, Secret, ConfigMap...).
This feature allows you to deploy any kind of Kubernetes resource in this environment (Deployment, Secret, ConfigMap...). </p>
</p> <p>
<p> You can get more information about Kubernetes file format in the
You can get more information about Kubernetes file format in the <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/" target="_blank">official documentation</a>.
<a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/" target="_blank">official documentation</a>. </p>
</p>
</span>
</editor-description> </editor-description>
</web-editor-form> </web-editor-form>
</div> </div>

View File

@ -34,14 +34,14 @@
on-change="($ctrl.editorUpdate)" on-change="($ctrl.editorUpdate)"
ng-required="true" ng-required="true"
yml="true" yml="true"
placeholder="# Define or paste the content of your docker compose file here" placeholder="Define or paste the content of your docker compose file here"
> >
<editor-description> <editor-description>
<span class="col-sm-12 text-muted"> <p>
You can get more information about Compose file format in the You can get more information about Compose file format in the
<a href="https://docs.docker.com/compose/compose-file/" target="_blank"> official documentation </a> <a href="https://docs.docker.com/compose/compose-file/" target="_blank"> official documentation </a>
. .
</span> </p>
</editor-description> </editor-description>
</web-editor-form> </web-editor-form>
<!-- !web-editor --> <!-- !web-editor -->

View File

@ -36,14 +36,14 @@
on-change="($ctrl.editorUpdate)" on-change="($ctrl.editorUpdate)"
ng-required="true" ng-required="true"
yml="true" yml="true"
placeholder="# Define or paste the content of your docker compose file here" placeholder="Define or paste the content of your docker compose file here"
> >
<editor-description> <editor-description>
<span class="col-sm-12 text-muted"> <p>
You can get more information about Compose file format in the You can get more information about Compose file format in the
<a href="https://docs.docker.com/compose/compose-file/" target="_blank"> official documentation </a> <a href="https://docs.docker.com/compose/compose-file/" target="_blank"> official documentation </a>
. .
</span> </p>
</editor-description> </editor-description>
</web-editor-form> </web-editor-form>
<!-- !web-editor --> <!-- !web-editor -->

View File

@ -14,14 +14,14 @@
on-change="($ctrl.editorUpdate)" on-change="($ctrl.editorUpdate)"
ng-required="true" ng-required="true"
yml="true" yml="true"
placeholder="# Define or paste the content of your docker compose file here" placeholder="Define or paste the content of your docker compose file here"
> >
<editor-description> <editor-description>
<span class="col-sm-12 text-muted"> <p>
You can get more information about Compose file format in the You can get more information about Compose file format in the
<a href="https://docs.docker.com/compose/compose-file/" target="_blank"> official documentation </a> <a href="https://docs.docker.com/compose/compose-file/" target="_blank"> official documentation </a>
. .
</span> </p>
</editor-description> </editor-description>
</web-editor-form> </web-editor-form>
<!-- !web-editor --> <!-- !web-editor -->

View File

@ -26,7 +26,6 @@
value="formValues.profileFileContent" value="formValues.profileFileContent"
on-change="(onChangeFileContent)" on-change="(onChangeFileContent)"
ng-required="true" ng-required="true"
placeholder="#"
> >
</web-editor-form> </web-editor-form>

View File

@ -27,7 +27,6 @@
value="formValues.profileFileContent" value="formValues.profileFileContent"
on-change="(onChangeFileContent)" on-change="(onChangeFileContent)"
ng-required="true" ng-required="true"
placeholder="#"
> >
</web-editor-form> </web-editor-form>

View File

@ -113,15 +113,13 @@
on-change="(onChangeFileContent)" on-change="(onChangeFileContent)"
ng-required="true" ng-required="true"
yml="true" yml="true"
placeholder="# Define or paste the content of your docker compose file here" placeholder="Define or paste the content of your docker compose file here"
> >
<editor-description> <editor-description>
<span class="col-sm-12 text-muted small"> <p>
You can get more information about Compose file format in the <a href="https://docs.docker.com/compose/compose-file/" target="_blank">official documentation</a>. You can get more information about Compose file format in the <a href="https://docs.docker.com/compose/compose-file/" target="_blank">official documentation</a>.
</span> </p>
<div class="col-sm-12" ng-if="state.editorYamlValidationError"> <p ng-if="state.editorYamlValidationError" class="text-danger">{{ state.editorYamlValidationError }}</p>
<span class="text-danger small">{{ state.editorYamlValidationError }}</span>
</div>
</editor-description> </editor-description>
</web-editor-form> </web-editor-form>

View File

@ -70,3 +70,7 @@
background-color: var(--bg-inputbox); background-color: var(--bg-inputbox);
color: var(--text-form-control-color); color: var(--text-form-control-color);
} }
.root :global(.cm-content[contenteditable='true']) {
@apply h-full;
}

View File

@ -6,6 +6,7 @@ import { createTheme } from '@uiw/codemirror-themes';
import { tags as highlightTags } from '@lezer/highlight'; import { tags as highlightTags } from '@lezer/highlight';
import styles from './CodeEditor.module.css'; import styles from './CodeEditor.module.css';
import { TextTip } from './Tip/TextTip';
interface Props { interface Props {
id: string; id: string;
@ -53,16 +54,18 @@ export function CodeEditor({
const extensions = useMemo(() => (isYaml ? [yamlLanguage] : []), [isYaml]); const extensions = useMemo(() => (isYaml ? [yamlLanguage] : []), [isYaml]);
return ( return (
<CodeMirror <>
className={styles.root} {!!placeholder && <TextTip color="blue">{placeholder}</TextTip>}
theme={theme} <CodeMirror
value={value} className={styles.root}
onChange={onChange} theme={theme}
readOnly={readonly} value={value}
placeholder={placeholder} onChange={onChange}
id={id} readOnly={readonly}
extensions={extensions} id={id}
height={height} extensions={extensions}
/> height={height}
/>
</>
); );
} }