-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ui: Toggle for read-only
view
#16279
Conversation
Ember Asset Size actionAs of 0cefe88 Files that got Bigger 🚨:
Files that stayed the same size 🤷:
|
Ember Test Audit comparison
|
<div class="pull-right" style="display: flex"> | ||
<div class="select-mode" data-test-toggle={{@data.view}}> | ||
<button | ||
class="button is-small is-borderless {{if (eq @data.view "job-spec") "is-active"}}" | ||
type="button" | ||
{{on "click" @fns.onToggle}} | ||
> | ||
Job Spec | ||
</button> | ||
<button | ||
class="button is-small is-borderless {{if (eq @data.view "full-definition") "is-active"}}" | ||
type="button" | ||
{{on "click" @fns.onToggle}} | ||
data-test-toggle-full | ||
> | ||
Full Definition | ||
</button> | ||
</div> |
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 should be conditionally rendered because old jobs will not have this functionality. This wasn't addressed in the mocks so I will tackle this issue separately.
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.
FYI it allows users to toggle between full specification and JSON definition
is a test that is made to fail until the next PR.
Small note: if you use the GitHub web ui's "Create a branch for...." from an issue, it'll auto-track it. Makes it a little easier to traverse from issue to pr and back. |
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.
A few changes and requests for clarification.
Some of the terminology could be changed to be clearer IMO. For example, I'm able to grok that definition
means JSON and specification
means HCL in this context, but that wasn't immediately clear.
ui/app/routes/jobs/job/definition.js
Outdated
const definitionWithoutSpecification = { ...definition }; | ||
delete definitionWithoutSpecification.Specification; | ||
|
||
const specification = await new Blob([ | ||
definition?.Specification?.Definition, | ||
]).text(); |
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.
Can you help me understand what this is accomplishing? delete prop
outside of a serializer has me wondering if this is the optimal place for this.
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.
fetchRawDefinition
specifically is made to skip the Ember Data and thus should not be serialized because we serialize payloads to format them before they enter the Ember Data store.
That leaves me with 2 places to handle this concerns: the Route who makes the fetch
request outside of Ember Data
or creating a Service
and extract our logic there. I opted for minimally changing the API surface and handling the concern where we are loading the data.
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.
Okay, so why are we deleting .Specification
here?
What's the format of definition
? Why does Specification
need to be removed from it? I'm struggling to understand what this model is trying to accomplish.
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're doing what we would do in our Serializer
here. We don't require this field. We could keep it, as we're not concerned with it and it won't break anything.
}, | ||
}, | ||
}; | ||
|
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.
Q: why not use a factory to accomplish this? They're extensible and most things you have listed here are either already job defaults or else unrelated to the acceptance test below.
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.
I'm not in the camp of factory or writing test logic. It becomes painful to maintain and that's personally the part of the test suite I hate the most. If you want it, I'm happy to create it. But it's just more code to maintain.
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.
There's a few things here:
- This data isn't going to be modeled because this is a raw request. We're explicitly using the API response to visualize the response itself in code mirror.
- We could overcome this using the
afterCreate
hook. But we already have 200 lines of logic in that hook and I simply don't want to touch it.
The best solution would be to just move this into a utility file if you wish to separate this fixture from the test code. And I can address that in a follow up PR.
Co-authored-by: Phil Renaud <[email protected]>
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.
I noticed there were test failures associated with the job definition
acceptance test module. However, those test failures don't occur for me locally. I will ignore the test failures for now for that reason.
* ui: model update for specification * style: add styling for select * style: add styling for select * refact: add spec to view * refact: update component API * test: refactor for new UI state * refact: clean conditional * refact: update component API for prop * chore: correct naming * chore: remove `fn` helper Co-authored-by: Phil Renaud <[email protected]> * update `default` Mirage scenario (#16496) * chore: update mirage scenario: * ui: conditionally render toggle button (#16497) * chore: update css variable name (#16498) --------- Co-authored-by: Phil Renaud <[email protected]>
* ui: model update for specification * style: add styling for select * style: add styling for select * refact: add spec to view * refact: update component API * test: refactor for new UI state * refact: clean conditional * refact: update component API for prop * chore: correct naming * chore: remove `fn` helper Co-authored-by: Phil Renaud <[email protected]> * update `default` Mirage scenario (#16496) * chore: update mirage scenario: * ui: conditionally render toggle button (#16497) * chore: update css variable name (#16498) --------- Co-authored-by: Phil Renaud <[email protected]>
* ui: model update for specification * style: add styling for select * style: add styling for select * refact: add spec to view * refact: update component API * test: refactor for new UI state * refact: clean conditional * refact: update component API for prop * chore: correct naming * chore: remove `fn` helper Co-authored-by: Phil Renaud <[email protected]> * update `default` Mirage scenario (#16496) * chore: update mirage scenario: * ui: conditionally render toggle button (#16497) * chore: update css variable name (#16498) --------- Co-authored-by: Phil Renaud <[email protected]>
* ui: model update for specification * style: add styling for select * style: add styling for select * refact: add spec to view * refact: update component API * test: refactor for new UI state * refact: clean conditional * refact: update component API for prop * chore: correct naming * chore: remove `fn` helper Co-authored-by: Phil Renaud <[email protected]> * update `default` Mirage scenario (#16496) * chore: update mirage scenario: * ui: conditionally render toggle button (#16497) * chore: update css variable name (#16498) --------- Co-authored-by: Phil Renaud <[email protected]>
* ui: model update for specification * style: add styling for select * style: add styling for select * refact: add spec to view * refact: update component API * test: refactor for new UI state * refact: clean conditional * refact: update component API for prop * chore: correct naming * chore: remove `fn` helper Co-authored-by: Phil Renaud <[email protected]> * update `default` Mirage scenario (#16496) * chore: update mirage scenario: * ui: conditionally render toggle button (#16497) * chore: update css variable name (#16498) --------- Co-authored-by: Phil Renaud <[email protected]>
* ui: model update for specification * style: add styling for select * style: add styling for select * refact: add spec to view * refact: update component API * test: refactor for new UI state * refact: clean conditional * refact: update component API for prop * chore: correct naming * chore: remove `fn` helper Co-authored-by: Phil Renaud <[email protected]> * update `default` Mirage scenario (#16496) * chore: update mirage scenario: * ui: conditionally render toggle button (#16497) * chore: update css variable name (#16498) --------- Co-authored-by: Phil Renaud <[email protected]>
* ui: Toggle for `read-only` view (#16279) * ui: model update for specification * style: add styling for select * style: add styling for select * refact: add spec to view * refact: update component API * test: refactor for new UI state * refact: clean conditional * refact: update component API for prop * chore: correct naming * chore: remove `fn` helper Co-authored-by: Phil Renaud <[email protected]> * update `default` Mirage scenario (#16496) * chore: update mirage scenario: * ui: conditionally render toggle button (#16497) * chore: update css variable name (#16498) --------- Co-authored-by: Phil Renaud <[email protected]> * refact: `JobEditor` reactive query parameters (#16710) * refact: add query parameter * refact: move toggle action to controller * ui: remove toggle behavior in `JobEditor` (#16711) * refact: rename logic for select * chore: instantiate qp in route * refact: uniform alerts (#16715) * style: buffer between alert and header * refact: extract alerts into a component * chore: update tests for qp * chore: defensive logic for app controller * refact: move `edit` state to controller (#16725) * refact: move edit state to controller * refact: handle edit state (#16731) * refact: handle edit state * ui: warning message (#16732) * ui: warning message * ui: enable editing of HCL vars in the UI (#16734) * enable editing of HCL vars * refact: default qp logic * refact: alert condition * refact: variables as string * style: revert styling change --------- Co-authored-by: Phil Renaud <[email protected]>
…ition` view (#16669) * ui: Toggle for `read-only` view (#16279) * ui: model update for specification * style: add styling for select * style: add styling for select * refact: add spec to view * refact: update component API * test: refactor for new UI state * refact: clean conditional * refact: update component API for prop * chore: correct naming * chore: remove `fn` helper Co-authored-by: Phil Renaud <[email protected]> * update `default` Mirage scenario (#16496) * chore: update mirage scenario: * ui: conditionally render toggle button (#16497) * chore: update css variable name (#16498) --------- Co-authored-by: Phil Renaud <[email protected]> * ui: Display JSON view of variables associated to job specification (#16570) * chore: move fixture to util * chore: update tests: * ui: display variables table * chore: add mirage fixture (#16572) * ui: regex for job spec parse (#16668) * ui: remove variable table (#16670) * ui: notify user if specification has variables (#16671) * ui: regex for job spec parse * chore: deprecate variable references * chore: update mirage * ui: add notification * test: add test coverage for parse method (#16590) * refact: `JobEditor` reactive query parameters (#16710) * refact: add query parameter * refact: move toggle action to controller * ui: remove toggle behavior in `JobEditor` (#16711) * refact: rename logic for select * chore: instantiate qp in route * refact: uniform alerts (#16715) * style: buffer between alert and header * refact: extract alerts into a component * chore: update tests for qp * chore: defensive logic for app controller * refact: move `edit` state to controller (#16725) * refact: move edit state to controller * refact: handle edit state (#16731) * refact: handle edit state * ui: warning message (#16732) * ui: warning message * ui: enable editing of HCL vars in the UI (#16734) * enable editing of HCL vars * refact: default qp logic * refact: alert condition * refact: Pass `variables` as string (#16849) * ui: Toggle for `read-only` view (#16279) * ui: model update for specification * style: add styling for select * style: add styling for select * refact: add spec to view * refact: update component API * test: refactor for new UI state * refact: clean conditional * refact: update component API for prop * chore: correct naming * chore: remove `fn` helper Co-authored-by: Phil Renaud <[email protected]> * update `default` Mirage scenario (#16496) * chore: update mirage scenario: * ui: conditionally render toggle button (#16497) * chore: update css variable name (#16498) --------- Co-authored-by: Phil Renaud <[email protected]> * refact: `JobEditor` reactive query parameters (#16710) * refact: add query parameter * refact: move toggle action to controller * ui: remove toggle behavior in `JobEditor` (#16711) * refact: rename logic for select * chore: instantiate qp in route * refact: uniform alerts (#16715) * style: buffer between alert and header * refact: extract alerts into a component * chore: update tests for qp * chore: defensive logic for app controller * refact: move `edit` state to controller (#16725) * refact: move edit state to controller * refact: handle edit state (#16731) * refact: handle edit state * ui: warning message (#16732) * ui: warning message * ui: enable editing of HCL vars in the UI (#16734) * enable editing of HCL vars * refact: default qp logic * refact: alert condition * refact: variables as string * style: revert styling change --------- Co-authored-by: Phil Renaud <[email protected]> * bug: correctly edit variables (#16989) * ui: visualize variables (#16987) * ui: fetchRawSpecification * refact: integrate new model method * test: fetchRaw unit * styling: enable height on cm * chore: update copy * feat: visual variables * chore: conditional render info txt * refact: add mirage endpoint * refact: update test for new schema * refact: job submit flow (#17015) * refact: job update logic * chore: remove dead code * bug: update `job.run` and `job.update` adapter methods (#17055) * refact: update adapter * chore: update api usage * styling: UX requests (#17064) * refact: update adapter * chore: update api usage * styling: disable toggle w text * styling: stick button * style: space out alerts * chore: autofocus on first editor * bug: dismiss alert * chore: add jsdoc and assertion check * chore: update mirage for Vercel (#17054) * chore: mirage logic for vercel deploy * chore: update test for mirage change * refact: API refactoring (#17083) * refact: udpate for req schema * refact: update for variable flags and literal * bug: visualize job model not derived state * chore: update copy * chore: fix incorrect copy * chore: deprecate variables derived state * chore: update copy * feat: enable toggle on edit * chore: prettify * refact: move conditional --------- Co-authored-by: Phil Renaud <[email protected]>
Closes #16269 for creating a Toggle Button to display both the Job Specification and Full Definition.
Functional Changes
This PR adds a toggle button when the
JobEditor
component is in a read-only state.Refactoring
This PR refactors the JobEditor component to improve its flexibility and maintainability. The original code tightly coupled the component's state with its rendering logic, which made it difficult to modify and extend. This PR introduces several improvements to make the code more modular and easier to understand.
Changes
component helper
to dynamically render the appropriate child component based on the value of the stage property.