Skip to content

Commit

Permalink
migrate announcements-common
Browse files Browse the repository at this point in the history
Signed-off-by: Kurt King <[email protected]>
  • Loading branch information
kurtaking committed Dec 7, 2024
1 parent 23f47de commit 6d3db49
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @backstage-community/plugin-announcements-common

Welcome to the common package for the announcements plugin!

_This plugin was created through the Backstage CLI_
45 changes: 45 additions & 0 deletions workspaces/announcements/plugins/announcements-common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@backstage-community/plugin-announcements-common",
"description": "Common functionalities for the announcements plugin",
"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"
},
"repository": {
"type": "git",
"url": "https://github.com/backstage/community-plugins",
"directory": "workspaces/announcements/plugins/announcements-common"
},
"backstage": {
"role": "common-library",
"pluginId": "announcements",
"pluginPackages": [
"@backstage-community/plugin-announcements-common"
]
},
"sideEffects": false,
"scripts": {
"build": "backstage-cli package build",
"lint": "backstage-cli package lint",
"test": "backstage-cli package test",
"clean": "backstage-cli package clean",
"prepack": "backstage-cli package prepack",
"postpack": "backstage-cli package postpack"
},
"devDependencies": {
"@backstage/cli": "^0.29.0"
},
"files": [
"dist"
],
"dependencies": {
"@backstage/plugin-permission-common": "^0.8.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const EVENTS_TOPIC_ANNOUNCEMENTS = 'announcements';

export const EVENTS_ACTION_CREATE_ANNOUNCEMENT = 'create_announcement';
export const EVENTS_ACTION_UPDATE_ANNOUNCEMENT = 'update_announcement';
export const EVENTS_ACTION_DELETE_ANNOUNCEMENT = 'delete_announcement';

export const EVENTS_ACTION_CREATE_CATEGORY = 'create_category';
export const EVENTS_ACTION_DELETE_CATEGORY = 'delete_category';

export const SIGNALS_CHANNEL_ANNOUNCEMENTS = 'announcements:new';
25 changes: 25 additions & 0 deletions workspaces/announcements/plugins/announcements-common/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Common functionalities for the announcements plugin.
*
* @packageDocumentation
*/

export * from './constants';
export * from './permissions';
export * from './types';
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createPermission } from '@backstage/plugin-permission-common';

export const announcementCreatePermission = createPermission({
name: 'announcement.entity.create',
attributes: { action: 'create' },
});

export const announcementDeletePermission = createPermission({
name: 'announcement.entity.delete',
attributes: { action: 'delete' },
});

export const announcementUpdatePermission = createPermission({
name: 'announcement.entity.update',
attributes: { action: 'update' },
});

export const announcementEntityPermissions = {
announcementCreatePermission,
announcementDeletePermission,
announcementUpdatePermission,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export {};
47 changes: 47 additions & 0 deletions workspaces/announcements/plugins/announcements-common/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export type Category = {
slug: string;
title: string;
};

export type Announcement = {
id: string;
category?: Category;
publisher: string;
title: string;
excerpt: string;
body: string;
created_at: string;
active: boolean;
};

export type AnnouncementsList = {
count: number;
results: Announcement[];
};

export type AnnouncementsFilters = {
max?: number;
offset?: number;
category?: string;
page?: number;
active?: boolean;
};

export type AnnouncementSignal = {
data: Announcement;
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
"postpack": "backstage-cli package postpack"
},
"dependencies": {
"@backstage-community/plugin-announcements-common": "workspace:^",
"@backstage/backend-plugin-api": "^1.0.2",
"@backstage/plugin-search-backend-node": "^1.3.5",
"@backstage/plugin-search-common": "^1.2.15",
"@procore-oss/backstage-plugin-announcements-common": "^0.2.8",
"@procore-oss/backstage-plugin-announcements-node": "^0.3.3"
},
"devDependencies": {
Expand Down
10 changes: 9 additions & 1 deletion workspaces/announcements/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2443,17 +2443,25 @@ __metadata:
languageName: node
linkType: hard

"@backstage-community/plugin-announcements-common@workspace:^, @backstage-community/plugin-announcements-common@workspace:plugins/announcements-common":
version: 0.0.0-use.local
resolution: "@backstage-community/plugin-announcements-common@workspace:plugins/announcements-common"
dependencies:
"@backstage/cli": ^0.29.0
languageName: unknown
linkType: soft

"@backstage-community/plugin-search-backend-module-announcements@workspace:plugins/search-backend-module-announcements":
version: 0.0.0-use.local
resolution: "@backstage-community/plugin-search-backend-module-announcements@workspace:plugins/search-backend-module-announcements"
dependencies:
"@backstage-community/plugin-announcements-common": "workspace:^"
"@backstage/backend-plugin-api": ^1.0.2
"@backstage/backend-test-utils": ^1.1.0
"@backstage/cli": ^0.29.0
"@backstage/plugin-search-backend-node": ^1.3.5
"@backstage/plugin-search-common": ^1.2.15
"@backstage/test-utils": ^1.7.2
"@procore-oss/backstage-plugin-announcements-common": ^0.2.8
"@procore-oss/backstage-plugin-announcements-node": ^0.3.3
"@testing-library/react": ^14.0.0
msw: ^1.3.2
Expand Down

0 comments on commit 6d3db49

Please sign in to comment.