kibana/packages/serverless/project_switcher
Clint Andrew Hall 8e37b38417
[serverless] Create the Serverless Plugin (#155582)
> Derived from https://github.com/elastic/kibana/pull/153274 for
production.

## Summary

This PR creates the `serverless` plugin for Kibana Serverless projects.


![image](https://user-images.githubusercontent.com/297604/233892935-b3713575-a2f7-4e82-a9dd-e8c11823683f.png)


It uses the methodology proven out in the proof-of-concept
(https://github.com/elastic/kibana/pull/153274) and prepares it for
production:

- Adds chrome style and related API to the `chrome` services.
- Creates the `serverless` plugin.
- Invokes the new chrome style API for all serverless projects.
- Alters `yarn` scripts to support all project types, and switching
between them.
- Creates the new "Project Switcher" component for use in the new chrome
header for Serverless.
- Creates a Storybook config for this and future components.
- Adds API endpoint to trigger project switching and `Watcher` restarts.

<img width="1598" alt="Screenshot 2023-04-26 at 10 44 01 AM"
src="https://user-images.githubusercontent.com/297604/234612654-fdcf38ea-8c48-4066-bc85-507f40c984aa.png">


## Next steps

- [x] Creating a PR for enabling/disabling related plugins for
Serverless. (https://github.com/elastic/kibana/pull/155583)
- [ ] Creating product plugin PR based on
https://github.com/elastic/kibana/pull/153274.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-04-26 11:48:23 -07:00
..
mocks [serverless] Create the Serverless Plugin (#155582) 2023-04-26 11:48:23 -07:00
src [serverless] Create the Serverless Plugin (#155582) 2023-04-26 11:48:23 -07:00
index.ts [serverless] Create the Serverless Plugin (#155582) 2023-04-26 11:48:23 -07:00
jest.config.js [serverless] Create the Serverless Plugin (#155582) 2023-04-26 11:48:23 -07:00
kibana.jsonc [serverless] Create the Serverless Plugin (#155582) 2023-04-26 11:48:23 -07:00
package.json [serverless] Create the Serverless Plugin (#155582) 2023-04-26 11:48:23 -07:00
README.mdx [serverless] Create the Serverless Plugin (#155582) 2023-04-26 11:48:23 -07:00
tsconfig.json [serverless] Create the Serverless Plugin (#155582) 2023-04-26 11:48:23 -07:00

---
id: serverless/components/ProjectSwitcher
slug: /serverless/components/project-switcher
title: Project Switcher
description: A popup which allows a developer to switch between project types on their dev server.
tags: ['serverless', 'component']
date: 2023-04-23
---

When working on Serverless instances of Kibana, developers likely want to switch between different project types to test changes. This Project Switcher is intended to be placed into the header bar by the Serverless plugin when the server is in development mode to allow "quick switching" between configurations.

The connected component uses `http` to post a selection to a given API endpoint, intended to alter the YML configuration and trigger Watcher to restart the server.  To that end, it will post its message to a given API endpoint and replace the content of `document.body`.  The remainder of the process is left to the Serverless plugin.