forked from janus-idp/backstage-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tekton): add permissions support for tekton plugin (janus-idp#1854)
- Loading branch information
1 parent
e04d231
commit f744896
Showing
18 changed files
with
241 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Tekton Common plugin | ||
|
||
Welcome to the tekton-common plugin! | ||
|
||
This plugin contains common utilities for the tekton plugin. | ||
|
||
# Tekton plugin for Backstage | ||
|
||
The Tekton plugin enables you to visualize the `PipelineRun` resources available on the Kubernetes cluster. | ||
|
||
For more information about Tekton plugin, see the [Tekton plugin documentation](https://github.com/janus-idp/backstage-plugins/tree/main/plugins/tekton) on GitHub. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"name": "@janus-idp/backstage-plugin-tekton-common", | ||
"version": "0.1.0", | ||
"main": "src/index.ts", | ||
"types": "src/index.ts", | ||
"license": "Apache-2.0", | ||
"private": true, | ||
"publishConfig": { | ||
"access": "public", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"types": "dist/index.d.ts" | ||
}, | ||
"backstage": { | ||
"role": "common-library", | ||
"supported-versions": "1.28.4", | ||
"pluginId": "tekton", | ||
"pluginPackages": [ | ||
"@janus-idp/backstage-plugin-tekton", | ||
"@janus-idp/backstage-plugin-tekton-common" | ||
] | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"build": "backstage-cli package build", | ||
"clean": "backstage-cli package clean", | ||
"lint": "backstage-cli package lint", | ||
"postpack": "backstage-cli package postpack", | ||
"prepack": "backstage-cli package prepack", | ||
"test": "backstage-cli package test --passWithNoTests --coverage", | ||
"tsc": "tsc" | ||
}, | ||
"dependencies": { | ||
"@backstage/plugin-permission-common": "^0.8.0" | ||
}, | ||
"devDependencies": { | ||
"@backstage/cli": "0.26.11" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/janus-idp/backstage-plugins", | ||
"directory": "plugins/tekton-common" | ||
}, | ||
"keywords": [ | ||
"support:production", | ||
"lifecycle:active", | ||
"backstage", | ||
"plugin" | ||
], | ||
"author": "Red Hat", | ||
"homepage": "https://red.ht/rhdh", | ||
"bugs": "https://github.com/janus-idp/backstage-plugins/issues", | ||
"maintainers": [ | ||
"janus-idp/rhtap" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Common functionalities for the tekton plugin. | ||
* | ||
* @packageDocumentation | ||
*/ | ||
|
||
export * from './permissions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { createPermission } from '@backstage/plugin-permission-common'; | ||
|
||
export const tektonViewPermission = createPermission({ | ||
name: 'tekton.view.read', | ||
attributes: { | ||
action: 'read', | ||
}, | ||
}); | ||
|
||
/** | ||
* List of all permissions on permission polices. | ||
*/ | ||
export const tektonPermissions = [tektonViewPermission]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "@backstage/cli/config/tsconfig.json", | ||
"include": ["src", "dev"], | ||
"exclude": ["node_modules"], | ||
"compilerOptions": { | ||
"outDir": "../../dist-types/plugins/tekton-common", | ||
"rootDir": "." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": ["//"], | ||
"pipeline": { | ||
"tsc": { | ||
"outputs": ["../../dist-types/plugins/tekton-common/**"], | ||
"dependsOn": ["^tsc"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import { Alert, AlertTitle } from '@material-ui/lab'; | ||
|
||
const PermissionAlert = () => { | ||
return ( | ||
<Alert severity="warning" data-testid="no-permission-alert"> | ||
<AlertTitle>Permission required</AlertTitle> | ||
To view Tekton Pipeline Runs, contact your administrator to give you the | ||
tekton.view.read permission. | ||
</Alert> | ||
); | ||
}; | ||
export default PermissionAlert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { usePermission } from '@backstage/plugin-permission-react'; | ||
|
||
import { tektonViewPermission } from '@janus-idp/backstage-plugin-tekton-common'; | ||
|
||
export const useTektonViewPermission = () => { | ||
const tektonViewPermissionResult = usePermission({ | ||
permission: tektonViewPermission, | ||
}); | ||
|
||
return tektonViewPermissionResult.allowed; | ||
}; |
Oops, something went wrong.