Skip to content
This repository has been archived by the owner on Mar 4, 2022. It is now read-only.

Customizable layouts #59

Merged
merged 7 commits into from
Feb 16, 2017
Merged

Conversation

alexkuz
Copy link
Contributor

@alexkuz alexkuz commented Feb 14, 2017

Phew!
So, I refactored layouts a little bit. Now user can provide JSON with layout configurations, which is then converted to internal layout object. Layout configuration describes panels (or columns), each contains views. Each panel and view has position object, that have a size or grow property. size defines exact width for panels and height for views, and grow works like CSS flex-grow. So panel with { grow: 2 } will be twice as wide as panel with { grow: 1 }.

There are also some fixes to prevent crashes, view.layoutConfig is now optional (view is hidden if there is no config).

@jasonwilson
Copy link
Contributor

@alexkuz it looks like CI is failing with these changes. Would you mind adding/fixing tests for this functionality?

@@ -8,7 +8,7 @@ var EventLoopView = require("./views/eventloop-view");
var MemoryView = require("./views/memory-view");
var CpuView = require("./views/cpu-view");
var HelpView = require("./views/help");
var layouts = require("./layouts");
var generateLayouts = require("./generate-layouts");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file doesn't seem to exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Missed it.

@alexkuz
Copy link
Contributor Author

alexkuz commented Feb 14, 2017

I'll fix tests, you can try it out meanwhile (with -l ./test/app/layouts.json, for example)

Forgot to mention - I also removed --interleave parameter, since it can be configured now via layouts.

@alexkuz
Copy link
Contributor Author

alexkuz commented Feb 15, 2017

@jasonwilson tests are ready

With a bit more of refactoring, it would be easy to implement status view with this, like:

{
  name: "stdout",
  type: "log",
  streams: ["stdout"],
  exclude: "^\[STATUS\]"
},
{
  name: "stderr",
  type: "log",
  streams: ["stderr"],
  exclude: "^\[STATUS\]"
},
{
  position: {
    size: 3
  },
  name: "status",
  type: "log",
  streams: ["stdout", "stderr"],
  include: "^\[STATUS\](.*)"
}

Copy link
Contributor

@jasonwilson jasonwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good- just want to convert layouts to js and pull default into its own file.

// View or panel with 'grow' fills <grow> part of the residuary space (it works like flex-grow).
// By default, position = { grow: 1 }

var DEFAULT_LAYOUT_CONFIG = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default config should live in a separate file, say ./layouts/default.js. Do you see any problem with using js instead of json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, js is better here. I replaced fs with require - not completely sure if I require there in a right way, but it seems to work.

@alexkuz
Copy link
Contributor Author

alexkuz commented Feb 15, 2017

Added layout config validation with jsonschema (it seems to be the most compact JSON-Schema lib)

Copy link
Member

@aisapatino aisapatino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@jasonwilson jasonwilson merged commit b80f270 into FormidableLabs:master Feb 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants