Skip to content

Commit

Permalink
feat(transitionvis): collapse undefined param/resolves into single ro…
Browse files Browse the repository at this point in the history
…w. Hide $state$ resolve.
  • Loading branch information
christopherthielen committed Dec 1, 2017
1 parent 3b6b46a commit 1710d10
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
29 changes: 22 additions & 7 deletions src/transition/keysAndValues.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ export class KeysAndValues extends Component<IProps, IState> {
);
};

return this.isEmpty() ? null : (
<div className={this.class('outerdiv')}>
<div className={this.class('section')}>
{this.props.labels.section}
</div>
if (this.isEmpty()) return null;

{ Object.keys(this.props.data).map(key =>
const keys = Object.keys(this.props.data);

const defineds = keys.filter(key => this.props.data[key] !== undefined);
const undefineds = keys.filter(key => this.props.data[key] === undefined);

const renderKeyValues = (keys) =>
keys.map(key =>
<div key={key} className={this.class('keyvaldiv')}>
<div className={this.class('_key')}>
{key}:
Expand All @@ -80,7 +82,20 @@ export class KeysAndValues extends Component<IProps, IState> {
{renderValue(key, this.props.data[key])}
</div>
</div>
) }
)

const renderUndefineds = (keys) => renderKeyValues([keys.join(', ')]);

return (
<div className={this.class('outerdiv')}>
<div className={this.class('section')}>
{this.props.labels.section}
</div>

{renderKeyValues(defineds)}

{/* { undefineds.length <= 2 && <KeyValues keys={undefineds} /> } */}
{ undefineds.length > 2 && renderUndefineds(undefineds) }

</div>
)
Expand Down
3 changes: 2 additions & 1 deletion src/transition/nodeDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { h, render, Component } from "preact";
import {stringify, maxLength} from "../util/strings";
import {KeysAndValues} from "./keysAndValues";
import {Transition} from '@uirouter/core';

export interface IProps {
node: any;
Expand Down Expand Up @@ -32,7 +33,7 @@ export class NodeDetail extends Component<IProps, IState> {
typeof val === 'string' ? val : maxLength(30, stringify(val));

let node = this.props.node;
let ignoredTokens = ['$stateParams', '$transition$'];
let ignoredTokens = ['$stateParams', '$transition$', '$state$', Transition];

return node && node.resolvables
.filter(r => ignoredTokens.indexOf(r.token) === -1)
Expand Down

0 comments on commit 1710d10

Please sign in to comment.