Skip to content

Commit 7ce8caa

Browse files
feat(lightspeed): add missing permission screen for Notebooks tab (#2633)
* feat(lightspeed): add missing permission screen for Notebooks tab Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com> * fixing tests Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com> * yarn dedupe Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com> * moving notebook specific files to notebooks folder Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com> * using same permission error component for chat and notebook Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com> * updating the test Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com> * doing yarn dedupe Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com> * fixing prettier Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com> --------- Signed-off-by: its-mitesh-kumar <itsmiteshkumar98@gmail.com>
1 parent 01241c2 commit 7ce8caa

31 files changed

Lines changed: 1525 additions & 177 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-lightspeed': patch
3+
---
4+
5+
Added a missing permission screen for the Notebooks tab. When a user lacks the `lightspeed.notebooks.use` permission, the Notebooks tab now displays a "Missing permission" message with a "Go back" button instead of the notebook list.

workspaces/lightspeed/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@
6666
"resolutions": {
6767
"@types/react": "^18",
6868
"@types/react-dom": "^18",
69-
"refractor@npm:3.6.0/prismjs": "^1.30.0"
69+
"refractor@npm:3.6.0/prismjs": "^1.30.0",
70+
"@backstage/frontend-plugin-api": "0.15.1"
7071
},
7172
"prettier": "@spotify/prettier-config",
7273
"lint-staged": {

workspaces/lightspeed/packages/app-legacy/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"lint": "backstage-cli package lint"
2020
},
2121
"dependencies": {
22+
"@backstage-community/plugin-rbac": "^1.51.0",
2223
"@backstage/app-defaults": "^1.7.6",
2324
"@backstage/catalog-model": "^1.7.7",
2425
"@backstage/cli": "^0.36.0",

workspaces/lightspeed/packages/app-legacy/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
LightspeedPage,
5858
LightspeedDrawerProvider,
5959
} from '@red-hat-developer-hub/backstage-plugin-lightspeed';
60+
import { RbacPage } from '@backstage-community/plugin-rbac';
6061

6162
const githubProvider = {
6263
id: 'github-auth-provider',
@@ -129,6 +130,7 @@ const routes = (
129130
<Route path="/settings" element={<UserSettingsPage />} />
130131
<Route path="/catalog-graph" element={<CatalogGraphPage />} />
131132
<Route path="/lightspeed" element={<LightspeedPage />} />
133+
<Route path="/rbac" element={<RbacPage />} />
132134
</FlatRoutes>
133135
);
134136

workspaces/lightspeed/packages/app-legacy/src/components/Root/Root.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
LightspeedDrawerStateExposer,
4848
LightspeedFAB,
4949
} from '@red-hat-developer-hub/backstage-plugin-lightspeed';
50+
import { Administration } from '@backstage-community/plugin-rbac';
5051
import { ApplicationDrawer } from './ApplicationDrawer';
5152
import LogoFull from './LogoFull';
5253
import LogoIcon from './LogoIcon';
@@ -127,6 +128,7 @@ export const Root = ({ children }: PropsWithChildren<{}>) => {
127128
</SidebarGroup>
128129
<SidebarSpace />
129130
<SidebarDivider />
131+
<Administration />
130132
<SidebarGroup
131133
label="Settings"
132134
icon={<UserSettingsSignInAvatar />}

workspaces/lightspeed/packages/backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"build-image": "docker build ../.. -f Dockerfile --tag backstage"
2222
},
2323
"dependencies": {
24+
"@backstage-community/plugin-rbac-backend": "5.2.6",
2425
"@backstage/backend-defaults": "^0.16.0",
2526
"@backstage/config": "^1.3.6",
2627
"@backstage/plugin-app-backend": "^0.5.12",

workspaces/lightspeed/packages/backend/src/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ backend.add(
3838
// See https://backstage.io/docs/features/software-catalog/configuration#subscribing-to-catalog-errors
3939
backend.add(import('@backstage/plugin-catalog-backend-module-logs'));
4040

41-
// permission plugin
42-
backend.add(import('@backstage/plugin-permission-backend'));
43-
// See https://backstage.io/docs/permissions/getting-started for how to create your own permission policy
44-
backend.add(
45-
import('@backstage/plugin-permission-backend-module-allow-all-policy'),
46-
);
41+
// RBAC backend (registers as "permission" and provides /rbac; do not add plugin-permission-backend separately)
42+
backend.add(import('@backstage-community/plugin-rbac-backend'));
4743

4844
// search plugin
4945
backend.add(import('@backstage/plugin-search-backend/alpha'));

workspaces/lightspeed/plugins/lightspeed/report-alpha.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ export const lightspeedTranslationRef: TranslationRef<
7070
readonly 'conversation.rename.placeholder': string;
7171
readonly 'permission.required.title': string;
7272
readonly 'permission.required.description': string;
73+
readonly 'permission.subject.plugin': string;
74+
readonly 'permission.subject.notebooks': string;
75+
readonly 'permission.notebooks.goBack': string;
7376
readonly 'footer.accuracy.label': string;
7477
readonly 'common.cancel': string;
7578
readonly 'common.close': string;

workspaces/lightspeed/plugins/lightspeed/src/api/api.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { createApiRef } from '@backstage/core-plugin-api';
17+
import { createApiRef, type ApiRef } from '@backstage/core-plugin-api';
1818

1919
import {
2020
Attachment,
@@ -57,6 +57,7 @@ export type LightspeedAPI = {
5757
* Lightspeed API interface
5858
*/
5959

60-
export const lightspeedApiRef = createApiRef<LightspeedAPI>({
61-
id: 'plugin.lightspeed.service',
62-
});
60+
export const lightspeedApiRef: ApiRef<LightspeedAPI> =
61+
createApiRef<LightspeedAPI>({
62+
id: 'plugin.lightspeed.service',
63+
});

workspaces/lightspeed/plugins/lightspeed/src/api/notebooksApi.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { createApiRef } from '@backstage/core-plugin-api';
17+
import { createApiRef, type ApiRef } from '@backstage/core-plugin-api';
1818

1919
import { NotebookSession } from '../types';
2020

@@ -32,6 +32,8 @@ export type NotebooksAPI = {
3232
* @public
3333
* AI Notebooks API interface
3434
*/
35-
export const notebooksApiRef = createApiRef<NotebooksAPI>({
36-
id: 'plugin.lightspeed.notebooks.service',
37-
});
35+
export const notebooksApiRef: ApiRef<NotebooksAPI> = createApiRef<NotebooksAPI>(
36+
{
37+
id: 'plugin.lightspeed.notebooks.service',
38+
},
39+
);

0 commit comments

Comments
 (0)