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

Group the services list by categories #88

Closed
alexmartinfr opened this issue Aug 31, 2020 · 12 comments
Closed

Group the services list by categories #88

alexmartinfr opened this issue Aug 31, 2020 · 12 comments

Comments

@alexmartinfr
Copy link
Contributor

Issue:

Takeout currently sorts the services list by alphabetical order.
As more and more services will be added to the list, it might become a bit confusing to browse.

Suggestion:

Each service could have a category property, which could be used to at least group similar services.

Examples of categories:

  • database
  • storage
  • search
  • cache
  • mail

Improvement:

Thetakeout enable command could now have two steps instead of one:

  • Select a category of services
  • Choose the relevant service in the curated list
@mattstauffer
Copy link
Member

I don't know if I want extra steps, but I do like the idea of grouping.

I wonder if there's a way we could build a faster UI or a UI with more information available without adding an extra step?

@alexmartinfr
Copy link
Contributor Author

alexmartinfr commented Aug 31, 2020

I think the cli-menu separators could be a good start:

image

Extra steps would only be necessary when the service list begins to be too long. The same way multi-steps forms are only relevant in some cases.

@mattstauffer
Copy link
Member

Yah, I like that!

@alexmartinfr
Copy link
Contributor Author

alexmartinfr commented Aug 31, 2020

Bear with me here, as this would need serious refactoring and is for now only generating the menu, but here is the raw idea:

public function handle(): void
{
    […]

    $databaseServices = [
        'mariadb' => 'MariaDB',
        'mysql' => 'MySQL',
        'mssql' => 'MS SQL'
    ];

    $searchServices = [
        'meilisearch' => 'MeiliSearch',
        'elasticsearch' => 'ElasticSearch'
    ];

    $option = $this->menu('Services to enable')->setTitleSeparator('=');

    /* displayCategory() private method */
    $option->addStaticItem('Database:')->addStaticItem('---------');

    foreach ($databaseServices as $service => $name) {
        $option->addOption($service, $name);
    }

    $option->addLineBreak('', 1);
    /* End of the displayCategory() private method */

    /* Start of the displayCategory() private method */
    $option->addStaticItem('Search:')->addStaticItem('-------');

    foreach ($searchServices as $service => $name) {
        $option->addOption($service, $name);
    }

    $option->addLineBreak('', 1);
    /* End of the displayCategory() private method */

    $option->setPadding(2, 5)->open();

    if (!$option) {
        return;
    }

    $this->enable($option);
}

Terminal preview:

image

I think it's safe to assume that people using Takeout will do so on a laptop or desktop, which means a minimum screen height of 768px. When taking various menu bars into account, we still have around 700px height to work with!

@jonsugar
Copy link

jonsugar commented Sep 19, 2020

Yes, please!

The concept of categories would help me with the current project to port Lambo to PHP. I'm currently experimenting with calling takeout so that I can find enabled databases and prompt the user to start them if required (for example, when configuring a project with a Jetstream UI).

At the moment I am calling takeout list --json then collecting and filtering the output. I had mentioned to Matt in a DM:

Would be nice if something like the following was possible:

takeout list --json --stopped --type=database

@mattstauffer
Copy link
Member

I still think this is a great idea, and I love Jon's note about using these in the CLI

@alexmartinfr
Copy link
Contributor Author

alexmartinfr commented Sep 23, 2020

As soon as Takeout integrate a categories concept for its services, I'll gladly leverage it to submit that feature in a proper PR 🙂

I've tried to add the concept of categories to the core of Takeout, but I am not comfortable enough with the codebase.
I hope someone else will be able to contribute that!

@danielebarbaro
Copy link
Contributor

takeout use nunomaduro/laravel-console-menu package, a simple wrapper of php-school/cli-menu but there aren't subItem (https://github.com/php-school/cli-menu#sub-menu-item) or Split Item (https://github.com/php-school/cli-menu#split-item-1) implementations. In this case also Jon can use it

One way could be make a PR to nunomaduro/laravel-console-menu and add some new feature that we can use in takeout.

Alternative way is grouping services and iterate in some way

foreach($groups as $group => $values ) {
    $option = $this->menu("Group {$group}", $this->enableableServices($values))
            ->addLineBreak('', 1)
            ->setPadding(2, 5);
}

In all cases to a better classification/grouping of Service we can add a property on BaseService. This property is easy to group with something like $collection->groupBy()

what do you think about it?
I know quite well 😎 the codebase and if you want i can handle this task.

@alexmartinfr
Copy link
Contributor Author

alexmartinfr commented Sep 23, 2020

Grouping and iterating is the way to go IMHO 👍

In what I envision, each service should have a category property.
Then, we'll only have to iterate through every category to get the UI we want.
(I'm basically describing your code snippet here.)

If you can bring the category concept to services, that would be very welcome indeed.
Thanks!

PS: That terminal preview is not just a mockup, it's actually a screenshot of a running hacked version of Takeout. I didn't need to tweak the nunomaduro/laravel-console-menu package to do so 🙂

image

@danielebarbaro
Copy link
Contributor

danielebarbaro commented Sep 24, 2020

Services grouped by category in #135 .
If you have questions, feel free to ask. 🤓

Screenshot 2020-09-24 at 12 31 02

I never used Minio maybe storage isn't the right place 🙈

@mattstauffer i can implement also Jon's note 😇

@alexmartinfr
Copy link
Contributor Author

You rock, Daniele!

I've added a custom visual improvement I wanted to add, feel free to implement or reject it :)

https://github.com/tighten/takeout/pull/135/files#r494363191

@mattstauffer
Copy link
Member

Closed via #135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants