-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Euified Management Saved Objects view component. #47652
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
1 similar comment
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
// This handles the validation of the Ace Editor. Since we don't have any | ||
// other hooks into the editors to tell us if the content is valid or not | ||
// we need to use the annotations to see if they have any errors. If they | ||
// do then we push the field.name to aceInvalidEditor variable. | ||
// Otherwise we remove it. | ||
const loadedEditors = []; | ||
$scope.aceInvalidEditors = []; | ||
|
||
$scope.aceLoaded = function (editor) { | ||
if (_.contains(loadedEditors, editor)) return; | ||
loadedEditors.push(editor); | ||
|
||
editor.$blockScrolling = Infinity; | ||
|
||
const session = editor.getSession(); | ||
const fieldName = editor.container.id; | ||
|
||
session.setTabSize(2); | ||
session.setUseSoftTabs(true); | ||
session.on('changeAnnotation', function () { | ||
const annotations = session.getAnnotations(); | ||
if (_.some(annotations, { type: 'error' })) { | ||
if (!_.contains($scope.aceInvalidEditors, fieldName)) { | ||
$scope.aceInvalidEditors.push(fieldName); | ||
} | ||
} else { | ||
$scope.aceInvalidEditors = _.without($scope.aceInvalidEditors, fieldName); | ||
} | ||
|
||
if (!$rootScope.$$phase) $scope.$apply(); | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this any more because we can validate the values directly inside the <Form>
component.
disabled={fields | ||
.filter(f => f.type === 'json' || f.type === 'array') | ||
.map(f => { | ||
try { | ||
JSON.parse(f.value || '[]'); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
}) | ||
.includes(false)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the validation part.
|| '[]'
in f.value || '[]'
is there because JSON.parse(undefined)
or JSON.parse('')
is error.
link: string; | ||
canViewInApp: boolean; | ||
canDelete: boolean; | ||
removeObject: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any
will be removed when View
is de-angularized.
} from '@elastic/eui'; | ||
|
||
interface Props { | ||
initialFields: any[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Field
will be defined when View
is de-angularized.
When you (Kibana team) are ready to handle this, please leave me a comment. I'll come back to handle the conflicts and bugs. |
Pinging @elastic/kibana-app-arch (Team:AppArch) |
It was 5 months ago I wrote this and I forgot most of the code. So, I guess I should skip the review. |
Summary
Partially solves #47022. Euified management/sections/objects/view.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.This was checked for cross-browser compatibility, including a check against IE11Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportDocumentation was added for features that require explanation or tutorialsUnit or functional tests were updated or added to match the most common scenariosThis was checked for keyboard-only and screenreader accessibilityFor maintainers