open-consul/ui/packages/consul-nspaces/app/components/consul/nspace/selector
John Cowen 91383269b9
ui: Move nspace CRUD to use the same approach as partitions (#11633)
This sounds a bit 'backwards' as the end goal here is to add an improved UX to partitions, not namespaces. The reason for doing it this way is that Namespaces already has a type of 'improved UX' CRUD in that it has one to many relationship in the form when saving your namespaces (the end goal for partitions). In moving Namespaces to use the same approach as partitions we:

- Ensure the new approach works with one-to-many forms.
- Test the new approach without writing a single test (we already have a bunch of tests for namespaces which are now testing the approach used by both namespaces and partitions)

Additionally:

- Fixes issue with missing default nspace in the nspace selector
- In doing when checking to see that things where consistent between the two, I found a few little minor problems with the Admin Partition CRUD so fixed those up here also.
- Removed the old style Nspace notifications
2021-12-01 11:04:02 +00:00
..
README.mdx ui: Move nspace CRUD to use the same approach as partitions (#11633) 2021-12-01 11:04:02 +00:00
index.hbs ui: Move nspace CRUD to use the same approach as partitions (#11633) 2021-12-01 11:04:02 +00:00

README.mdx

# Consul::Nspace::Selector

A conditional, autoloading, menu component specifically for making it easy to select namespaces.

Please note: 

- Currently at least, you must add this inside of a `<ul>` element, as the `<li>` elements output by this component are intended to be mixed with other sibling `<li>`s from other components or template code.
- For the moment, make sure you have enabled nspaces using developer debug
  cookies.

```hbs preview-template
<ul>
  <Consul::Nspace::Selector
    @dc={{hash
      Name='dc-1'
    }}
    @nspace='default'
    @partition='default'
    @nspaces={{or this.nspaces (array)}}
    @onchange={{action (mut this.nspaces) value="data"}}
  />
</ul>
```


## Arguments

| Argument/Attribute | Type | Default | Description |
| --- | --- | --- | --- |
| `dc` | `object` |  | The current datacenter |
| `nspace` | `string` |  | The name of the current namespace |
| `partition` | `string` |  | The name of the current partition |
| `nspaces` | `array` |  | A list of nspace models/objects to use for the selector |
| `onchange` | `function` |  | An event handler, for when nspaces are loaded. You probably want to update `@nspaces` using this. |

## See

- [Template Source Code](./index.hbs)

---