|
| 1 | +# SecretList.vue |
| 2 | + |
| 3 | +A list component for Konnect config store secrets. *This component should only be used in Konnect*. |
| 4 | + |
| 5 | +- [Requirements](#requirements) |
| 6 | +- [Usage](#usage) |
| 7 | + - [Install](#install) |
| 8 | + - [Props](#props) |
| 9 | + - [Events](#events) |
| 10 | + - [Usage example](#usage-example) |
| 11 | +- [TypeScript interfaces](#typescript-interfaces) |
| 12 | + |
| 13 | +## Requirements |
| 14 | + |
| 15 | +- `vue` and `vue-router` must be initialized in the host application |
| 16 | +- `@kong/kongponents` must be added as a dependency in the host application, globally available via the Vue Plugin installation, and the package's style imports must be added in the app entry file. [See here for instructions on installing Kongponents](https://kongponents.konghq.com/#globally-install-all-kongponents). |
| 17 | +- `@kong-ui-public/i18n` must be available as a `dependency` in the host application. |
| 18 | +- `axios` must be installed as a dependency in the host application |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +### Install |
| 23 | + |
| 24 | +[See instructions for installing the `@kong-ui-public/entities-vaults` package.](../README.md#install) |
| 25 | + |
| 26 | +### Props |
| 27 | + |
| 28 | +#### `config` |
| 29 | + |
| 30 | +- type: `Object as PropType<KonnectSecretListConfig>` |
| 31 | +- required: `true` |
| 32 | +- default: `undefined` |
| 33 | +- properties: |
| 34 | + - `app`: |
| 35 | + - type: `'konnect'` |
| 36 | + - required: `true` |
| 37 | + - default: `undefined` |
| 38 | + - App name. |
| 39 | + |
| 40 | + - `apiBaseUrl`: |
| 41 | + - type: `string` |
| 42 | + - required: `true` |
| 43 | + - default: `undefined` |
| 44 | + - Base URL for API requests. |
| 45 | + |
| 46 | + - `axiosRequestConfig`: |
| 47 | + - type: `AxiosRequestConfig` |
| 48 | + - required: `false` |
| 49 | + - default: `undefined` |
| 50 | + - An optional configuration object for the underlying Axios request. |
| 51 | + |
| 52 | + - `cancelRoute`: |
| 53 | + - type: `RouteLocationRaw` |
| 54 | + - required: `true` |
| 55 | + - default: `undefined` |
| 56 | + - Route to return to when canceling creating or editing a secret. |
| 57 | + |
| 58 | + - `createRoute`: |
| 59 | + - type: `RouteLocationRaw` |
| 60 | + - required: `true` |
| 61 | + - default: `undefined` |
| 62 | + - Route for creating a secret. |
| 63 | + |
| 64 | + - `getEditRoute`: |
| 65 | + - type: `(id: string) => RouteLocationRaw` |
| 66 | + - required: `true` |
| 67 | + - default: `undefined` |
| 68 | + - A function that returns the route for editing a secret. |
| 69 | + |
| 70 | + - `additionMessageForEmptyState`: |
| 71 | + - type: `string` |
| 72 | + - required: `false` |
| 73 | + - default: `undefined` |
| 74 | + - Additional message to show when there are no records. |
| 75 | + |
| 76 | + - `controlPlaneId`: |
| 77 | + - type: `string` |
| 78 | + - required: `true` |
| 79 | + - default: `undefined` |
| 80 | + - Name of the current control plane. |
| 81 | + |
| 82 | +#### `vaultId` |
| 83 | + |
| 84 | +- type: `String` |
| 85 | +- required: `true` |
| 86 | +- default: `undefined` |
| 87 | +- Current vault ID. |
| 88 | + |
| 89 | +#### `cacheIdentifier` |
| 90 | + |
| 91 | +- type: `String` |
| 92 | +- required: `false` |
| 93 | +- default: `''` |
| 94 | + |
| 95 | +Used to override the default unique identifier for the table's entry in the cache. This should be unique across the Vue App. |
| 96 | +Note: the default value is usually sufficient unless the app needs to support multiple separate instances of the table. |
| 97 | + |
| 98 | +#### `canCreate` |
| 99 | + |
| 100 | +- type: `Function as PropType<() => boolean | Promise<boolean>>` |
| 101 | +- required: `false` |
| 102 | +- default: `async () => true` |
| 103 | + |
| 104 | +A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can create a new entity. |
| 105 | + |
| 106 | +#### `canDelete` |
| 107 | + |
| 108 | +- type: `Function as PropType<(row: object) => boolean | Promise<boolean>>` |
| 109 | +- required: `false` |
| 110 | +- default: `async () => true` |
| 111 | + |
| 112 | +A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can delete a given entity. |
| 113 | + |
| 114 | +#### `canEdit` |
| 115 | + |
| 116 | +- type: `Function as PropType<(row: object) => boolean | Promise<boolean>>` |
| 117 | +- required: `false` |
| 118 | +- default: `async () => true` |
| 119 | + |
| 120 | +A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can edit a given entity. |
| 121 | + |
| 122 | +### Events |
| 123 | + |
| 124 | +#### error |
| 125 | + |
| 126 | +An `@error` event is emitted when the table fails to fetch secrets or delete a secret. The event payload is the response error. |
| 127 | + |
| 128 | +#### delete:success |
| 129 | + |
| 130 | +A `@delete:success` event is emitted when a secret is successfully deleted. The event payload is the secret item data object. |
| 131 | + |
| 132 | +### Usage example |
| 133 | + |
| 134 | +Please refer to the [sandbox](../sandbox/pages/VaultConfigCardPage.vue). |
| 135 | + |
| 136 | +## TypeScript interfaces |
| 137 | + |
| 138 | +TypeScript interfaces [are available here](../src/types/secret-list.ts) and can be directly imported into your host application. The following type interfaces are available for import: |
| 139 | + |
| 140 | +```ts |
| 141 | +import type { |
| 142 | + KonnectSecretListConfig, |
| 143 | + SecretEntityRow, |
| 144 | +} from '@kong-ui-public/entities-vaults' |
0 commit comments