-
Notifications
You must be signed in to change notification settings - Fork 26
Display saga messages body using CodeEditor #2402
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
971dc6a
Maximizable code editor
cquirosj 1b813e2
do not affect other cm instances
cquirosj 50540db
v1 of using code editor for message data
cquirosj 5d98cdb
improved styles
cquirosj 89cb1fb
Passing message type to maximized title
cquirosj 4955477
improved loading of the body - and formatted xml
cquirosj 35a3c22
changing the size of the maximized pop-up
cquirosj 3145dbf
rebase
cquirosj afdb9a0
Handle the display of empty bodies
cquirosj fc00a8d
taking custom css outside of maximizableCodeEditor
cquirosj 1616afa
Update src/Frontend/src/components/MaximizableCodeEditor.vue
cquirosj 475f3f5
Update src/Frontend/src/components/messages2/SagaDiagram/SagaUpdateNo…
cquirosj 7dda80d
adding tippy
cquirosj 1482183
using rem
cquirosj 0d9af2e
updated paddings to rem
cquirosj 240289c
adding a stub for tippy in the tests
cquirosj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
<script setup lang="ts"> | ||
import { ref, onMounted, onBeforeUnmount } from "vue"; | ||
import CodeEditor from "@/components/CodeEditor.vue"; | ||
import DiffMaximizeIcon from "@/assets/diff-maximize.svg"; | ||
import DiffCloseIcon from "@/assets/diff-close.svg"; | ||
import { Extension } from "@codemirror/state"; | ||
import { CodeLanguage } from "@/components/codeEditorTypes"; | ||
|
||
const modelValue = defineModel<string>({ required: true }); | ||
|
||
withDefaults( | ||
defineProps<{ | ||
language?: CodeLanguage; | ||
readOnly?: boolean; | ||
showGutter?: boolean; | ||
ariaLabel?: string; | ||
extensions?: Extension[]; | ||
modalTitle?: string; | ||
}>(), | ||
{ | ||
readOnly: false, | ||
showGutter: false, | ||
extensions: () => [], | ||
modalTitle: "Code View", | ||
} | ||
); | ||
|
||
// Component state for maximize functionality | ||
const showMaximizeModal = ref(false); | ||
const showMaximizeButton = ref(false); | ||
|
||
// Handle maximize functionality | ||
const toggleMaximizeModal = () => { | ||
showMaximizeModal.value = !showMaximizeModal.value; | ||
}; | ||
|
||
// Handle mouse enter/leave for showing maximize button | ||
const onEditorMouseEnter = () => { | ||
showMaximizeButton.value = true; | ||
}; | ||
|
||
const onEditorMouseLeave = () => { | ||
showMaximizeButton.value = false; | ||
}; | ||
|
||
// Handle ESC key to close modal | ||
const handleKeyDown = (event: KeyboardEvent) => { | ||
if (event.key === "Escape" && showMaximizeModal.value) { | ||
showMaximizeModal.value = false; | ||
} | ||
}; | ||
|
||
// Setup keyboard events for maximize modal | ||
onMounted(() => { | ||
window.addEventListener("keydown", handleKeyDown); | ||
}); | ||
|
||
// Clean up event listeners when component is destroyed | ||
onBeforeUnmount(() => { | ||
window.removeEventListener("keydown", handleKeyDown); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div class="code-editor-wrapper" @mouseenter="onEditorMouseEnter" @mouseleave="onEditorMouseLeave"> | ||
<!-- Regular CodeEditor --> | ||
<div class="editor-container"> | ||
<CodeEditor class="maximazable-code-editor--inline-instance" v-model="modelValue" :language="language" :read-only="readOnly" :show-gutter="showGutter" :show-copy-to-clipboard="false" :aria-label="ariaLabel" :extensions="extensions"> | ||
<template #toolbarLeft> | ||
<slot name="toolbarLeft"></slot> | ||
</template> | ||
<template #toolbarRight> | ||
<slot name="toolbarRight"> | ||
<!-- Maximize Button (shown on hover) --> | ||
<button v-if="showMaximizeButton" @click="toggleMaximizeModal" class="maximize-button" v-tippy="`Maximize view`"> | ||
<img :src="DiffMaximizeIcon" alt="Maximize" width="14" height="14" /> | ||
</button> | ||
</slot> | ||
</template> | ||
</CodeEditor> | ||
</div> | ||
|
||
<!-- Maximize modal for CodeEditor --> | ||
<div v-if="showMaximizeModal" class="maximize-modal"> | ||
<div class="maximize-modal-content"> | ||
<div class="maximize-modal-toolbar"> | ||
<span class="maximize-modal-title">{{ modalTitle }}</span> | ||
<button @click="toggleMaximizeModal" class="maximize-modal-close" v-tippy="`Close`"> | ||
<img :src="DiffCloseIcon" alt="Close" width="16" height="16" /> | ||
</button> | ||
</div> | ||
<div class="maximize-modal-body"> | ||
<CodeEditor class="maximazable-code-editor--pop-up-instance" v-model="modelValue" :language="language" :read-only="readOnly" :show-copy-to-clipboard="true" :show-gutter="true" :aria-label="ariaLabel" :extensions="[]" /> | ||
cquirosj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.code-editor-wrapper { | ||
position: relative; | ||
width: 100%; | ||
} | ||
|
||
.maximize-button { | ||
position: absolute; | ||
right: 0.375rem; | ||
top: 0.375rem; | ||
z-index: 10; | ||
background-color: rgba(255, 255, 255, 0.7); | ||
border: 1px solid #ddd; | ||
border-radius: 3px; | ||
padding: 0.25rem; | ||
cursor: pointer; | ||
opacity: 0.6; | ||
transition: opacity 0.2s ease; | ||
} | ||
|
||
.maximize-button:hover { | ||
opacity: 1; | ||
} | ||
|
||
.maximize-modal { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
z-index: 1000; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.maximize-modal-content { | ||
background-color: white; | ||
width: 95vw; | ||
height: 90vh; | ||
border-radius: 4px; | ||
overflow: hidden; | ||
display: flex; | ||
flex-direction: column; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.maximize-modal-toolbar { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 0.625rem 0.9375rem; | ||
background-color: #f8f8f8; | ||
border-bottom: 1px solid #ddd; | ||
} | ||
|
||
.maximize-modal-title { | ||
font-weight: bold; | ||
font-size: 1rem; | ||
} | ||
|
||
.maximize-modal-close { | ||
background: none; | ||
border: none; | ||
cursor: pointer; | ||
padding: 0.3125rem; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.maximize-modal-body { | ||
flex: 1; | ||
overflow: auto; | ||
padding: 0; | ||
} | ||
|
||
/* Ensure the CodeEditor wrapper fills the modal body */ | ||
.maximize-modal-body :deep(.wrapper) { | ||
height: 100%; | ||
border-radius: 0; | ||
} | ||
|
||
.maximize-modal-body :deep(.cm-editor), | ||
.maximize-modal-body :deep(.cm-scroller) { | ||
height: 100%; | ||
} | ||
</style> | ||
cquirosj marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 should try to use fontawesome icons if available