Skip to content
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

Feature: Enhancements to run page run-config inputs with new dict, json, yaml inputs #1095

Merged
merged 89 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
5b72ed1
broke out dynamic form items into separate run config forms
stackoverfloweth Oct 11, 2021
1aeaa8e
styling form
stackoverfloweth Oct 12, 2021
3d03db9
removed runConfig util; pulled out run config selection into new comp…
stackoverfloweth Oct 12, 2021
ce0979e
created argument component; additional styling
stackoverfloweth Oct 12, 2021
3911ae9
added support for additional actions in menu-tooltip
stackoverfloweth Oct 12, 2021
a0637c8
supporting reset run-config values from run.vue
stackoverfloweth Oct 12, 2021
4d24eb1
fixed list-input reactivity
stackoverfloweth Oct 12, 2021
5881f72
basic json and yaml inputs started
stackoverfloweth Oct 15, 2021
578e503
created utility classes for json and yaml
stackoverfloweth Oct 15, 2021
508be6c
created code-input component with multiple-language support
stackoverfloweth Oct 15, 2021
00797c8
started dict2 component
stackoverfloweth Oct 15, 2021
80fe3c6
renamed utility files to match others
stackoverfloweth Oct 15, 2021
ba367da
allowing for variety of value types
stackoverfloweth Oct 15, 2021
dc20741
accepting variety of value types at code-input component as well
stackoverfloweth Oct 15, 2021
628ac81
discovered issue with supporting multiple input types - reverting to …
stackoverfloweth Oct 15, 2021
a076c95
textarea input styling side-by-side
stackoverfloweth Oct 18, 2021
e476196
building out dict-input including key-value-input
stackoverfloweth Oct 18, 2021
713c13b
styling decisions
stackoverfloweth Oct 19, 2021
5261fb5
add and remove buttons in dict; validation in dict; dynamic keys and …
stackoverfloweth Oct 19, 2021
03330db
moved away from dynamic key
stackoverfloweth Oct 19, 2021
621f6e4
basic readonly functionality
stackoverfloweth Oct 19, 2021
b626564
basic readonly functionality for json and yaml
stackoverfloweth Oct 19, 2021
231fece
auto-grow json and yaml
stackoverfloweth Oct 19, 2021
043a1a2
created base component for json and yaml
stackoverfloweth Oct 19, 2021
34fd7d5
fixed some styles issues with base-code-textarea
stackoverfloweth Oct 19, 2021
9507f30
more specific with types; can choose type from dropdown
stackoverfloweth Oct 19, 2021
e9415eb
support for single-type-mode
stackoverfloweth Oct 19, 2021
01842ae
setting defaults on props
stackoverfloweth Oct 19, 2021
a368fb2
validation changed; now supports validating existing rows without cha…
stackoverfloweth Oct 19, 2021
1eaf1eb
named components
stackoverfloweth Oct 20, 2021
9c5c047
arrange dict entries alphabetically
stackoverfloweth Oct 20, 2021
f3cd783
split out base dict input for future checkbox dict input
stackoverfloweth Oct 20, 2021
83833e3
implemented checkbox-dict-input
stackoverfloweth Oct 20, 2021
867056f
quick review changes
stackoverfloweth Oct 20, 2021
1b786d1
simplifying base-dict; using focusout to trigger add
stackoverfloweth Oct 21, 2021
aae93d7
broke out input, parsing, validation into separate sub components
stackoverfloweth Oct 21, 2021
8415551
changed checkbox-dict-input to work like a multiselect
stackoverfloweth Oct 21, 2021
6330154
if show-types is false always use string input
stackoverfloweth Oct 21, 2021
84f8e07
added text option to code-input
stackoverfloweth Oct 21, 2021
db3b74d
made some ux review changes
stackoverfloweth Oct 21, 2021
b981224
additional ux review suggestions implemented
stackoverfloweth Oct 22, 2021
71cc2c1
kvp input starts with jsonParsingInput and tries to infer type
stackoverfloweth Oct 22, 2021
715acc9
fixed wrong syntax and missing errors from base-code-textarea
stackoverfloweth Oct 22, 2021
c265745
created resettable-wrapper
stackoverfloweth Oct 22, 2021
c8d427e
using new inputs on run
stackoverfloweth Oct 22, 2021
deadcb8
inverted the string and object versions on run page code-inputs
stackoverfloweth Oct 22, 2021
d83170b
extending code-input to accept value as object
stackoverfloweth Oct 25, 2021
f80b044
simplified run form now that code-input can accept value as object
stackoverfloweth Oct 25, 2021
185d9cb
updated kubernetes-run-form to use new code-input
stackoverfloweth Oct 25, 2021
eda4e83
fixed catching of common vue errors, needs investigation
stackoverfloweth Oct 25, 2021
719f657
run-config now just wraps specific run-config form components
stackoverfloweth Oct 25, 2021
fba225f
implemented code-input replacement in all other run-config form compo…
stackoverfloweth Oct 25, 2021
079ca19
reset app.js to original value
stackoverfloweth Oct 25, 2021
e2008ca
continue emiting value from code textarea even if there are errors
stackoverfloweth Oct 25, 2021
db26e3f
reverted support for Object at code-input level
stackoverfloweth Oct 25, 2021
f898417
added resettable-wrapper to all run-config form component inputs
stackoverfloweth Oct 25, 2021
1406b25
few last minute conerns addressed
stackoverfloweth Oct 25, 2021
3358c41
fixed adding of logging level when logging level is not default
stackoverfloweth Oct 26, 2021
52c2d97
reverted changes to orginal DictInput
stackoverfloweth Oct 26, 2021
ccfb4f2
moved location of resettable-wrapper css class
stackoverfloweth Oct 26, 2021
d4e1773
changed catchall for both singular property and multiple properties o…
stackoverfloweth Oct 26, 2021
00530f0
adding support for checkbox-dict that will be used in schedule parame…
stackoverfloweth Oct 26, 2021
30676bb
created input for null type that sets value to null; allowing for res…
stackoverfloweth Oct 26, 2021
d4f4780
using beautify-js for formatting json
stackoverfloweth Oct 26, 2021
4300131
languages renamed to editors
stackoverfloweth Oct 26, 2021
a78b25f
added support for placeholder in textarea components
stackoverfloweth Oct 27, 2021
02604d4
fixed defaulting null type in kvp
stackoverfloweth Oct 27, 2021
3652f55
styling of code-input text; allow passing mode into code-input
stackoverfloweth Oct 28, 2021
26e0b5d
only overwrite value on type change if value can be parsed to object
stackoverfloweth Oct 28, 2021
3971df3
validate textarea inputs on created to retain errors when switching m…
stackoverfloweth Oct 28, 2021
42263a1
ux review suggestions with nbrown
stackoverfloweth Oct 28, 2021
8740860
changed readonly prop to several more specific controls
stackoverfloweth Oct 28, 2021
723f30f
implemented new readonly props in run-config params
stackoverfloweth Oct 28, 2021
c5ea1f7
fixed disabling of value for kvp
stackoverfloweth Oct 28, 2021
789b692
code review suggestions
stackoverfloweth Oct 29, 2021
811778f
Merge branch 'master' into run-config-forms
stackoverfloweth Nov 1, 2021
1817de1
replaced dependency that was not allowing us to upgrade highlightjs
stackoverfloweth Nov 3, 2021
73ee67f
setting of value from outside component should force type change to m…
stackoverfloweth Nov 4, 2021
e99f01e
Merge branch 'master' into run-config-forms
stackoverfloweth Nov 4, 2021
63b35f1
changelog
stackoverfloweth Nov 4, 2021
d974b70
preventing passing of invalid values to datetime component
stackoverfloweth Nov 4, 2021
c157599
change in functionality for checkbox dictionary input
stackoverfloweth Nov 5, 2021
f4a8a75
Merge branch 'master' into run-config-forms
stackoverfloweth Nov 5, 2021
c4d3755
emits on error; dict fails validation when given list, type is consid…
stackoverfloweth Nov 6, 2021
7aa31b9
alternative validation approach working
stackoverfloweth Nov 8, 2021
a771b00
cleanup
stackoverfloweth Nov 8, 2021
52adf1d
fixed validation error when ecs or kubernetes have code-inputs are no…
stackoverfloweth Nov 9, 2021
88c5e50
reverting changelog
stackoverfloweth Nov 11, 2021
a58f2ca
Merge branch 'master' into run-config-forms
zhen0 Nov 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

### Features and Improvements

- Rebuilt various inputs responsible for code input (Dict, Json, Yaml) - [#1095](https://github.com/PrefectHQ/ui/pull/1095)
- Allow users to specify type explicitly for env variables - [#1095](https://github.com/PrefectHQ/ui/pull/1095)
- When creating/editing schedule, make action button available across tabs - [#1096](https://github.com/PrefectHQ/ui/pull/1096)

### Bugfixes
- Rebuilt Run-Config editor to preserve original run_config values, allows resetting fields - [#1095](https://github.com/PrefectHQ/ui/pull/1095)
- Removed unused locale files from moment dependency - [#1109](https://github.com/PrefectHQ/ui/pull/1109)
- Moved away from discouraged per-method-packaging of lodash - [#1107](https://github.com/PrefectHQ/ui/pull/1107)
- Removed unnecessary dependency preventing us from tree shaking highlightjs - [#1108](https://github.com/PrefectHQ/ui/pull/1108)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"d3-zoom": "^2.0.0",
"graphiql": "^1.4.1",
"graphql": "^15.5.0",
"highlight.js": "^10.7.2",
"js-beautify": "^1.13.5",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
Expand All @@ -44,7 +45,6 @@
"velocity-animate": ">=1.5.2",
"vue": "^2.6.12",
"vue-apollo": "^3.0.7",
"vue-code-highlight": "^0.7.6",
"vue-codemirror": ">=4.0.6",
"vue-meta": "^2.4.0",
"vue-router": "^3.5.1",
Expand Down
8 changes: 4 additions & 4 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import TransitionHeight from '@/components/Functional/Transition-Height'
import TruncatedSpan from '@/components/Functional/TruncatedSpan'
import GetCloud from '@/components/GetCloud'

import '@/styles/atelier-sulphurpool-light.scss'

// Prefect icon font
import '@/assets/fonts/prefect-icons/style.scss'

Expand Down Expand Up @@ -72,8 +74,7 @@ Vue.prototype.$globalApolloQueries = {}

// Vue Global Error Handler
Vue.config.errorHandler = function(error, vm, trace) {
if (error?.message?.includes("Cannot read property '_observe' of null"))
return
if (error?.message?.includes("'_observe'")) return
stackoverfloweth marked this conversation as resolved.
Show resolved Hide resolved
if (process.env.NODE_ENV === 'development')
// eslint-disable-next-line no-console
console.log('Vue Global Error Handler', { error, vm, trace })
Expand All @@ -82,8 +83,7 @@ Vue.config.errorHandler = function(error, vm, trace) {
}

Vue.config.warnHandler = function(error, vm, trace) {
if (error?.message?.includes("Cannot read property '_observe' of null"))
return
if (error?.message?.includes("'_observe'")) return
if (process.env.NODE_ENV === 'development')
// eslint-disable-next-line no-console
console.log('Vue Global Warn Handler', { error, vm, trace })
Expand Down
173 changes: 173 additions & 0 deletions src/components/CustomInputs/BaseCodeTextarea.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<template>
<div class="base-code-textarea">
<v-textarea
v-model="internalValue"
class="base-code-textarea__textarea"
spellcheck="false"
stackoverfloweth marked this conversation as resolved.
Show resolved Hide resolved
:error-messages="errors"
:disabled="readonly"
:placeholder="placeholder"
auto-grow
outlined
@input="validate"
@blur="handleBlur"
>
<template #append>
<highlight
:language="language"
:code="internalValue"
class="base-code-textarea__preview"
/>
<span
class="base-code-textarea__language"
:class="`base-code-textarea__language-${language}`"
>{{ language }}</span
>
</template>
<template #message="{message}">
<p style="white-space: pre-line">
{{ message }}
</p>
</template>
</v-textarea>
</div>
</template>

<script>
import Highlight from '@/components/CustomInputs/Highlight'

export default {
name: 'BaseCodeTextarea',
components: {
Highlight
},
props: {
value: {
type: String,
required: false,
default: null
},
readonly: {
type: Boolean,
required: false,
default: false
},
language: {
type: String,
required: true,
validator: value => ['json', 'yaml'].includes(value)
},
placeholder: {
type: String,
required: false,
default: null
},
getErrors: {
type: Function,
required: true
},
parse: {
type: Function,
required: true
},
format: {
type: Function,
required: true
}
},
data() {
return {
errors: []
}
},
computed: {
internalValue: {
get() {
return this.value
},
set(value) {
this.$emit('input', value)
}
}
},
created() {
if (this.internalValue) {
this.validate(this.internalValue)
}
},
methods: {
handleBlur() {
const objectValue = this.parse(this.internalValue)
const formatted = this.format(objectValue)

if (formatted != null) {
this.internalValue = formatted
}
},
validate(value) {
this.errors = this.getErrors(value)

return this.errors.length === 0
}
}
}
</script>

<style lang="scss">
.base-code-textarea {
.v-input__append-inner {
position: absolute;
margin: 0;
padding: 0;
width: 50%;
right: 2px;
top: 2px;
bottom: 2px;
}

.v-input__control {
padding: 0;
}

.base-code-textarea__textarea .v-text-field__slot {
width: 50%;
margin-bottom: 4px;
flex-grow: 0 !important;
}

.base-code-textarea__preview {
color: #666666;
width: 100%;
word-wrap: break-word;
white-space: pre-wrap;

code {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding-top: 10px;
padding-bottom: 8px;
font-family: monospace, monospace;
font-size: 13px;
line-height: 13px;
}
}

.base-code-textarea__language {
position: absolute;
bottom: 5px;
right: 5px;
text-transform: uppercase;
}

.base-code-textarea__language-json {
color: rgba(76, 175, 80, 0.35);
}

.base-code-textarea__language-yaml {
color: rgba(255, 152, 0, 0.35);
}
}
</style>
132 changes: 132 additions & 0 deletions src/components/CustomInputs/BaseDictInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<template>
<div class="base-dict-input">
<div
v-for="(entry, index) in entries"
:key="index"
class="base-dict-input__row"
>
<slot name="before-existing" :entry="entry" />
<key-value-input
ref="existingPropertyForms"
:value="entry"
:readonly-key="readonlyKey"
:readonly-type="readonlyType"
:readonly-value="readonlyValue"
:show-types="showTypes"
:types="types"
@input="$emit('update', [$event, entry])"
/>
<slot name="after-existing" :entry="entry" />
<v-btn
v-if="!disableRemove"
class="base-dict-input__action"
icon
@click="$emit('remove', entry)"
>
<v-icon color="red">remove_circle</v-icon>
</v-btn>
</div>
<div
v-if="!disableAdd"
ref="newPropertyContainer"
class="base-dict-input__row base-dict-input__row-last"
>
<slot name="before-new" :entry="newProperty" />
<key-value-input
ref="newPropertyForm"
v-model="newProperty"
:show-types="showTypes"
:types="types"
@focusout.native="handleFocusout"
/>
<slot name="after-new" :entry="newProperty">
<v-btn class="base-dict-input__action" icon @click="tryAddNewProperty">
<v-icon color="green">add_circle</v-icon>
</v-btn>
</slot>
</div>
</div>
</template>

<script>
import KeyValueInput from '@/components/CustomInputs/KeyValueInput'
import readonlyProps from '@/components/CustomInputs/readonlyProps'
import { types, isValidType } from '@/utils/types'

export default {
name: 'BaseDictInput',
components: {
KeyValueInput
},
props: {
entries: {
type: Array,
required: false,
default: null
},
showTypes: {
type: Boolean,
required: false,
default: false
},
types: {
type: Array,
required: false,
default: () => types,
validator: value => value.every(isValidType)
},
...readonlyProps
},
data() {
return {
newProperty: { key: null, value: null }
}
},
methods: {
handleFocusout(event) {
const target = event.relatedTarget

if (
!this.$refs.newPropertyContainer.contains(target) &&
this.newProperty.key != null
) {
this.tryAddNewProperty()
}
},
tryAddNewProperty() {
if (!this.$refs.newPropertyForm.validate()) {
return false
}

this.$emit('add', this.newProperty)
this.$refs.newPropertyForm.reset()
return true
},
validate() {
if (!this.$refs.existingPropertyForms) {
return true
}

return this.$refs.existingPropertyForms.every(form => form.validate())
}
}
}
</script>

<style lang="scss">
.base-dict-input__row {
display: flex;
}

.base-dict-input__row-last:not(:focus-within) {
opacity: 0.5;
}

.key-value-input {
flex-grow: 1;
}

.base-dict-input__action {
flex-grow: 0;
}
</style>
Loading