Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0e2535e0
Commit
0e2535e0
authored
Aug 03, 2021
by
Enrique Alcantara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ContentEditorError component
Add a component to display errors notified by the ContentEditor
parent
f74b0c27
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
app/assets/javascripts/content_editor/components/content_editor_error.vue
...cripts/content_editor/components/content_editor_error.vue
+31
-0
app/assets/javascripts/content_editor/components/editor_state_observer.vue
...ripts/content_editor/components/editor_state_observer.vue
+3
-0
spec/frontend/content_editor/components/content_editor_error_spec.js
...nd/content_editor/components/content_editor_error_spec.js
+54
-0
No files found.
app/assets/javascripts/content_editor/components/content_editor_error.vue
0 → 100644
View file @
0e2535e0
<
script
>
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
EditorStateObserver
from
'
./editor_state_observer.vue
'
;
export
default
{
components
:
{
GlAlert
,
EditorStateObserver
,
},
data
()
{
return
{
error
:
null
,
};
},
methods
:
{
displayError
({
error
})
{
this
.
error
=
error
;
},
dismissError
()
{
this
.
error
=
null
;
},
},
};
</
script
>
<
template
>
<editor-state-observer
@
error=
"displayError"
>
<gl-alert
v-if=
"error"
class=
"gl-mb-6"
variant=
"danger"
@
dismiss=
"dismissError"
>
{{
error
}}
</gl-alert>
</editor-state-observer>
</
template
>
app/assets/javascripts/content_editor/components/editor_state_observer.vue
View file @
0e2535e0
...
...
@@ -5,6 +5,9 @@ export const tiptapToComponentMap = {
update
:
'
docUpdate
'
,
selectionUpdate
:
'
selectionUpdate
'
,
transaction
:
'
transaction
'
,
focus
:
'
focus
'
,
blur
:
'
blur
'
,
error
:
'
error
'
,
};
const
getComponentEventName
=
(
tiptapEventName
)
=>
tiptapToComponentMap
[
tiptapEventName
];
...
...
spec/frontend/content_editor/components/content_editor_error_spec.js
0 → 100644
View file @
0e2535e0
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
ContentEditorError
from
'
~/content_editor/components/content_editor_error.vue
'
;
import
EditorStateObserver
from
'
~/content_editor/components/editor_state_observer.vue
'
;
import
{
createTestEditor
,
emitEditorEvent
}
from
'
../test_utils
'
;
describe
(
'
content_editor/components/content_editor_error
'
,
()
=>
{
let
wrapper
;
let
tiptapEditor
;
const
findErrorAlert
=
()
=>
wrapper
.
findComponent
(
GlAlert
);
const
createWrapper
=
async
()
=>
{
tiptapEditor
=
createTestEditor
();
wrapper
=
shallowMountExtended
(
ContentEditorError
,
{
provide
:
{
tiptapEditor
,
},
stubs
:
{
EditorStateObserver
,
},
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
'
renders error when content editor emits an error event
'
,
async
()
=>
{
const
error
=
'
error message
'
;
createWrapper
();
await
emitEditorEvent
({
tiptapEditor
,
event
:
'
error
'
,
params
:
{
error
}
});
expect
(
findErrorAlert
().
text
()).
toBe
(
error
);
});
it
(
'
allows dismissing the error
'
,
async
()
=>
{
const
error
=
'
error message
'
;
createWrapper
();
await
emitEditorEvent
({
tiptapEditor
,
event
:
'
error
'
,
params
:
{
error
}
});
findErrorAlert
().
vm
.
$emit
(
'
dismiss
'
);
await
nextTick
();
expect
(
findErrorAlert
().
exists
()).
toBe
(
false
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment