vault/ui/app/templates/components/diff-version-selector.hbs
Angel Garbarino 720db8e299
UI/kv codemirror diff (#13000)
* staying with jsondiff

* routing setup

* send compare against data to component after using new adapater method to return the version data.

* functionality

* fix issue on route transition not calling model hook

* formatting

* update version

* changelog

* glimmerize the json-editor component

* catch up

* passing tracked property from child to parent

* pull out of jsonEditor

* fix issue with message

* icon

* fix some issues with right selection

* changes and convert to component

* integration test

* tests

* fixes

* cleanup

* cleanup 2

* fixes

* fix test by spread attributes

* remove log

* remove
2021-12-01 11:41:49 -07:00

95 lines
4.0 KiB
Handlebars

<Toolbar>
<div class="version-diff-toolbar" data-test-version-diff-toolbar>
{{!-- Left side version --}}
<BasicDropdown
@class="popup-menu"
@horizontalPosition="auto-right"
@verticalPosition="below"
as |D|
>
<D.trigger
data-test-popup-menu-trigger="left-version"
@class={{concat "toolbar-link" (if D.isOpen " is-active")}}
@tagName="button"
>
Version {{or this.leftSideVersionSelected this.args.model.currentVersion}}
<Chevron @direction="down" @isButton={{true}} />
</D.trigger>
<D.content @class="popup-menu-content">
<nav class="box menu">
<ul class="menu-list">
{{#each (reverse this.args.model.versions) as |leftSideSecretVersion|}}
<li class="action" data-test-leftSide-version={{leftSideSecretVersion.version}}>
<button
class="link"
{{on "click" (fn this.selectVersion leftSideSecretVersion.version D.actions "left")}}
>
Version {{leftSideSecretVersion.version}}
{{#if (and (eq leftSideSecretVersion.version (or this.leftSideVersionSelected this.args.model.currentVersion)) (not leftSideSecretVersion.destroyed) (not leftSideSecretVersion.deleted))}}
<Icon @glyph="check-circle-outline" class="has-text-success is-pulled-right" />
{{else if leftSideSecretVersion.destroyed}}
<Icon @glyph="cancel-square-fill" class="has-text-danger is-pulled-right" />
{{else if leftSideSecretVersion.deleted}}
<Icon @glyph="cancel-square-fill" class="has-text-grey is-pulled-right" />
{{/if}}
</button>
</li>
{{/each}}
</ul>
</nav>
</D.content>
</BasicDropdown>
{{!-- Right side version --}}
<BasicDropdown
@class="popup-menu"
@horizontalPosition="right"
@verticalPosition="below"
as |D|
>
<D.trigger
@class={{concat "toolbar-link" (if D.isOpen " is-active")}}
@tagName="button"
data-test-popup-menu-trigger="right-version"
>
Version {{or this.rightSideVersionSelected this.rightSideVersionInit}}
<Chevron @direction="down" @isButton={{true}} />
</D.trigger>
<D.content @class="popup-menu-content">
<nav class="box menu">
<ul class="menu-list">
{{#each (reverse this.args.model.versions) as |rightSideSecretVersion|}}
<li class="action">
<button
class="link"
{{on "click" (fn this.selectVersion rightSideSecretVersion.version D.actions "right")}}
data-test-rightSide-version={{rightSideSecretVersion.version}}
>
Version {{rightSideSecretVersion.version}}
{{#if (and (eq rightSideSecretVersion.version (or this.rightSideVersionSelected this.rightSideVersionInit)) (not rightSideSecretVersion.destroyed) (not rightSideSecretVersion.deleted))}}
<Icon @glyph="check-circle-outline" class="has-text-success is-pulled-right" />
{{else if rightSideSecretVersion.destroyed}}
<Icon @glyph="cancel-square-fill" class="has-text-danger is-pulled-right" />
{{else if rightSideSecretVersion.deleted}}
<Icon @glyph="cancel-square-fill" class="has-text-grey is-pulled-right" />
{{/if}}
</button>
</li>
{{/each}}
</ul>
</nav>
</D.content>
</BasicDropdown>
{{!-- Status --}}
{{#if this.statesMatch}}
<div class="diff-status">
<span>States match</span>
<Icon @glyph="check-circle-fill" class="has-text-success" />
</div>
{{/if}}
</div>
</Toolbar>
<div class="form-section visual-diff">
<pre>{{{this.visualDiff}}}</pre>
</div>