-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate announcements react from procore-oss (#2404)
* migrate announcements-react Signed-off-by: Kurt King <[email protected]> * Update Backstage plugin packages Signed-off-by: Kurt King <[email protected]> * Use announcements-react from backstage-community Signed-off-by: Kurt King <[email protected]> * Build api report Signed-off-by: Kurt King <[email protected]> * improve readme Signed-off-by: Kurt King <[email protected]> * update imports to use backstage-community Signed-off-by: Kurt King <[email protected]> * remove additional references to procore-oss Signed-off-by: Kurt King <[email protected]> * fix api report Signed-off-by: Kurt King <[email protected]> --------- Signed-off-by: Kurt King <[email protected]>
- Loading branch information
Showing
47 changed files
with
925 additions
and
65 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
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
1 change: 1 addition & 0 deletions
1
workspaces/announcements/plugins/announcements-react/.eslintrc.js
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); |
11 changes: 11 additions & 0 deletions
11
workspaces/announcements/plugins/announcements-react/README.md
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 @@ | ||
# @backstage-community/plugin-announcements-react | ||
|
||
This library provides reusable components and frontend utilities for displaying and interacting with announcements in a Backstage plugin. | ||
|
||
## Hooks | ||
|
||
There are multiple [hooks](./src/hooks/index.ts) you may use in your Backstage plugin to fetch and use announcements however you see fit. | ||
|
||
## Previously maintained by | ||
|
||
- [procore-oss](https://github.com/procore-oss/backstage-plugin-announcements/tree/main/plugins/announcements-react) |
59 changes: 59 additions & 0 deletions
59
workspaces/announcements/plugins/announcements-react/package.json
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": "@backstage-community/plugin-announcements-react", | ||
"description": "Web library 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.esm.js", | ||
"types": "dist/index.d.ts" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/backstage/community-plugins", | ||
"directory": "workspaces/announcements/plugins/announcements-react" | ||
}, | ||
"backstage": { | ||
"role": "web-library", | ||
"pluginId": "announcements", | ||
"pluginPackages": [ | ||
"@backstage-community/plugin-announcements", | ||
"@backstage-community/plugin-announcements-backend", | ||
"@backstage-community/plugin-announcements-common", | ||
"@backstage-community/plugin-announcements-node", | ||
"@backstage-community/plugin-announcements-react" | ||
] | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"start": "backstage-cli package start", | ||
"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" | ||
}, | ||
"dependencies": { | ||
"@backstage-community/plugin-announcements-common": "workspace:^", | ||
"@backstage/core-plugin-api": "^1.10.1", | ||
"@backstage/errors": "^1.2.5", | ||
"luxon": "^3.4.4", | ||
"react-use": "^17.2.4" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.13.1 || ^17.0.0 || ^18.0.0" | ||
}, | ||
"devDependencies": { | ||
"@backstage/cli": "^0.29.2", | ||
"@testing-library/jest-dom": "^5.10.1", | ||
"@testing-library/react": "^12.1.3", | ||
"react": "^16.13.1 || ^17.0.0 || ^18.0.0" | ||
}, | ||
"files": [ | ||
"dist" | ||
] | ||
} |
261 changes: 261 additions & 0 deletions
261
workspaces/announcements/plugins/announcements-react/report.api.md
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,261 @@ | ||
## API Report File for "@backstage-community/plugin-announcements-react" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
```ts | ||
import { Announcement } from '@backstage-community/plugin-announcements-common'; | ||
import { AnnouncementsFilters } from '@backstage-community/plugin-announcements-common'; | ||
import { AnnouncementsList } from '@backstage-community/plugin-announcements-common'; | ||
import { ApiRef } from '@backstage/core-plugin-api'; | ||
import { Category } from '@backstage-community/plugin-announcements-common'; | ||
import { DateTime } from 'luxon'; | ||
import { TranslationFunction } from '@backstage/core-plugin-api/alpha'; | ||
import { TranslationRef } from '@backstage/core-plugin-api/alpha'; | ||
|
||
// @public | ||
export interface AnnouncementsApi { | ||
// (undocumented) | ||
announcementByID(id: string): Promise<Announcement>; | ||
// (undocumented) | ||
announcements(opts: { | ||
max?: number; | ||
page?: number; | ||
category?: string; | ||
active?: boolean; | ||
}): Promise<AnnouncementsList>; | ||
// (undocumented) | ||
categories(): Promise<Category[]>; | ||
// (undocumented) | ||
createAnnouncement(request: CreateAnnouncementRequest): Promise<Announcement>; | ||
// (undocumented) | ||
createCategory(request: CreateCategoryRequest): Promise<void>; | ||
// (undocumented) | ||
deleteAnnouncementByID(id: string): Promise<void>; | ||
// (undocumented) | ||
deleteCategory(slug: string): Promise<void>; | ||
// (undocumented) | ||
lastSeenDate(): DateTime; | ||
// (undocumented) | ||
markLastSeenDate(date: DateTime): void; | ||
// (undocumented) | ||
updateAnnouncement( | ||
id: string, | ||
request: CreateAnnouncementRequest, | ||
): Promise<Announcement>; | ||
} | ||
|
||
// @public (undocumented) | ||
export const announcementsApiRef: ApiRef<AnnouncementsApi>; | ||
|
||
// @public | ||
export type AnnouncementsOptions = { | ||
dependencies?: any[]; | ||
}; | ||
|
||
// @public (undocumented) | ||
export const announcementsTranslationRef: TranslationRef< | ||
'announcements', | ||
{ | ||
readonly 'announcementForm.active': 'Active'; | ||
readonly 'announcementForm.title': 'Title'; | ||
readonly 'announcementForm.submit': 'Submit'; | ||
readonly 'announcementForm.excerpt': 'Excerpt'; | ||
readonly 'announcementForm.editAnnouncement': 'Edit announcement'; | ||
readonly 'announcementForm.newAnnouncement': 'New announcement'; | ||
readonly 'announcementForm.categoryInput.label': 'Category'; | ||
readonly 'announcementForm.categoryInput.create': 'Create'; | ||
readonly 'announcementsPage.grid.announcementDeleted': 'Announcement deleted.'; | ||
readonly 'announcementsPage.contextMenu.admin': 'Admin'; | ||
readonly 'announcementsPage.contextMenu.categories': 'Categories'; | ||
readonly 'announcementsPage.newAnnouncement': 'New announcement'; | ||
readonly 'announcementsPage.genericNew': 'New'; | ||
readonly 'announcementsPage.card.by': 'By'; | ||
readonly 'announcementsPage.card.in': 'in'; | ||
readonly 'announcementsPage.card.delete': 'DELETE'; | ||
readonly 'announcementsPage.card.edit': 'EDIT'; | ||
readonly 'admin.adminPortal.title': 'Admin Portal for Announcements'; | ||
readonly 'admin.adminPortal.subtitle': 'Manage announcements and categories'; | ||
readonly 'admin.adminPortal.announcementsLabels': 'Announcements'; | ||
readonly 'admin.adminPortal.categoriesLabel': 'Categories'; | ||
readonly 'admin.announecementsContent.table.active': 'Active'; | ||
readonly 'admin.announecementsContent.table.inactive': 'Inactive'; | ||
readonly 'admin.announecementsContent.table.body': 'Body'; | ||
readonly 'admin.announecementsContent.table.title': 'Title'; | ||
readonly 'admin.announecementsContent.table.status': 'Status'; | ||
readonly 'admin.announecementsContent.table.actions': 'Actions'; | ||
readonly 'admin.announecementsContent.table.category': 'Category'; | ||
readonly 'admin.announecementsContent.table.publisher': 'Publisher'; | ||
readonly 'admin.announecementsContent.announcements': 'Announcements'; | ||
readonly 'admin.announecementsContent.alertMessage': 'Announcement created.'; | ||
readonly 'admin.announecementsContent.alertMessageWithNewCategory': 'with new category'; | ||
readonly 'admin.announecementsContent.cancelButton': 'Cancel'; | ||
readonly 'admin.announecementsContent.createButton': 'Create Announcement'; | ||
readonly 'admin.announecementsContent.noAnnouncementsFound': 'No announcements found'; | ||
readonly 'admin.categoriesContent.table.title': 'Title'; | ||
readonly 'admin.categoriesContent.table.actions': 'Actions'; | ||
readonly 'admin.categoriesContent.table.categoryDeleted': 'Category deleted.'; | ||
readonly 'admin.categoriesContent.table.slug': 'Slug'; | ||
readonly 'admin.categoriesContent.table.addTooltip': 'Add'; | ||
readonly 'admin.categoriesContent.table.noCategoriesFound': 'No categories found.'; | ||
readonly 'admin.categoriesContent.createdMessage': 'created'; | ||
readonly 'admin.categoriesContent.cancelButton': 'Cancel'; | ||
readonly 'admin.categoriesContent.createButton': 'Create category'; | ||
readonly 'admin.categoriesContent.deletedMessage': 'Category deleted.'; | ||
readonly 'deleteDialog.cancel': 'Cancel'; | ||
readonly 'deleteDialog.title': 'Are you sure you want to delete this announcement?'; | ||
readonly 'deleteDialog.delete': 'Delete'; | ||
readonly 'announcementsCard.new': 'New'; | ||
readonly 'announcementsCard.in': 'in'; | ||
readonly 'announcementsCard.announcements': 'Announcements'; | ||
readonly 'announcementsCard.seeAll': 'See all'; | ||
readonly 'announcementsCard.noAnnouncements': 'No announcements yet, want to'; | ||
readonly 'announcementsCard.addOne': 'add one'; | ||
readonly 'announcementSearchResultListItem.published': 'Published'; | ||
readonly 'announcementSearchResultListItem.announcement': 'Announcement'; | ||
readonly 'announcementsTimeline.error': 'Error'; | ||
readonly 'announcementsTimeline.noAnnouncements': 'No announcements'; | ||
readonly 'categoriesForm.submit': 'Submit'; | ||
readonly 'categoriesForm.newCategory': 'New category'; | ||
readonly 'categoriesForm.editCategory': 'Edit category'; | ||
readonly 'categoriesForm.titleLabel': 'Title'; | ||
readonly 'categoriesTable.title': 'Title'; | ||
readonly 'categoriesTable.actions': 'Actions'; | ||
readonly 'categoriesTable.categoryDeleted': 'Category deleted.'; | ||
readonly 'categoriesTable.slug': 'Slug'; | ||
readonly 'categoriesTable.addTooltip': 'Add'; | ||
readonly 'categoriesTable.noCategoriesFound': 'No categories found.'; | ||
readonly 'categoriesPage.title': 'Categories'; | ||
readonly 'categoriesPage.subtitle': 'Manage announcement categories'; | ||
readonly 'createAnnouncementPage.alertMessage': 'Announcement created.'; | ||
readonly 'createAnnouncementPage.alertMessageWithNewCategory': 'with new category'; | ||
readonly 'editAnnouncementPage.edit': 'Edit'; | ||
readonly 'editAnnouncementPage.updatedMessage': 'Announcement updated.'; | ||
readonly 'editAnnouncementPage.notFoundMessage': 'Unable to find announcement'; | ||
readonly 'newAnnouncementBanner.markAsSeen': 'Mark as seen'; | ||
readonly 'newCategoryDialog.title': 'Title'; | ||
readonly 'newCategoryDialog.newCategory': 'New category'; | ||
readonly 'newCategoryDialog.createdMessage': 'Category created.'; | ||
readonly 'newCategoryDialog.cancelButton': 'Cancel'; | ||
readonly 'newCategoryDialog.createButton': 'Create'; | ||
} | ||
>; | ||
|
||
// @public | ||
export type CreateAnnouncementRequest = Omit< | ||
Announcement, | ||
'id' | 'category' | 'created_at' | ||
> & { | ||
category?: string; | ||
}; | ||
|
||
// @public | ||
export type CreateCategoryRequest = { | ||
title: string; | ||
}; | ||
|
||
// @public | ||
export const useAnnouncements: ( | ||
props: AnnouncementsFilters, | ||
options?: AnnouncementsOptions, | ||
) => { | ||
announcements: AnnouncementsList; | ||
loading: boolean; | ||
error: Error | undefined; | ||
retry: () => void; | ||
}; | ||
|
||
// @public | ||
export const useAnnouncementsTranslation: () => { | ||
t: TranslationFunction<{ | ||
readonly 'announcementForm.active': 'Active'; | ||
readonly 'announcementForm.title': 'Title'; | ||
readonly 'announcementForm.submit': 'Submit'; | ||
readonly 'announcementForm.excerpt': 'Excerpt'; | ||
readonly 'announcementForm.editAnnouncement': 'Edit announcement'; | ||
readonly 'announcementForm.newAnnouncement': 'New announcement'; | ||
readonly 'announcementForm.categoryInput.label': 'Category'; | ||
readonly 'announcementForm.categoryInput.create': 'Create'; | ||
readonly 'announcementsPage.grid.announcementDeleted': 'Announcement deleted.'; | ||
readonly 'announcementsPage.contextMenu.admin': 'Admin'; | ||
readonly 'announcementsPage.contextMenu.categories': 'Categories'; | ||
readonly 'announcementsPage.newAnnouncement': 'New announcement'; | ||
readonly 'announcementsPage.genericNew': 'New'; | ||
readonly 'announcementsPage.card.by': 'By'; | ||
readonly 'announcementsPage.card.in': 'in'; | ||
readonly 'announcementsPage.card.delete': 'DELETE'; | ||
readonly 'announcementsPage.card.edit': 'EDIT'; | ||
readonly 'admin.adminPortal.title': 'Admin Portal for Announcements'; | ||
readonly 'admin.adminPortal.subtitle': 'Manage announcements and categories'; | ||
readonly 'admin.adminPortal.announcementsLabels': 'Announcements'; | ||
readonly 'admin.adminPortal.categoriesLabel': 'Categories'; | ||
readonly 'admin.announecementsContent.table.active': 'Active'; | ||
readonly 'admin.announecementsContent.table.inactive': 'Inactive'; | ||
readonly 'admin.announecementsContent.table.body': 'Body'; | ||
readonly 'admin.announecementsContent.table.title': 'Title'; | ||
readonly 'admin.announecementsContent.table.status': 'Status'; | ||
readonly 'admin.announecementsContent.table.actions': 'Actions'; | ||
readonly 'admin.announecementsContent.table.category': 'Category'; | ||
readonly 'admin.announecementsContent.table.publisher': 'Publisher'; | ||
readonly 'admin.announecementsContent.announcements': 'Announcements'; | ||
readonly 'admin.announecementsContent.alertMessage': 'Announcement created.'; | ||
readonly 'admin.announecementsContent.alertMessageWithNewCategory': 'with new category'; | ||
readonly 'admin.announecementsContent.cancelButton': 'Cancel'; | ||
readonly 'admin.announecementsContent.createButton': 'Create Announcement'; | ||
readonly 'admin.announecementsContent.noAnnouncementsFound': 'No announcements found'; | ||
readonly 'admin.categoriesContent.table.title': 'Title'; | ||
readonly 'admin.categoriesContent.table.actions': 'Actions'; | ||
readonly 'admin.categoriesContent.table.categoryDeleted': 'Category deleted.'; | ||
readonly 'admin.categoriesContent.table.slug': 'Slug'; | ||
readonly 'admin.categoriesContent.table.addTooltip': 'Add'; | ||
readonly 'admin.categoriesContent.table.noCategoriesFound': 'No categories found.'; | ||
readonly 'admin.categoriesContent.createdMessage': 'created'; | ||
readonly 'admin.categoriesContent.cancelButton': 'Cancel'; | ||
readonly 'admin.categoriesContent.createButton': 'Create category'; | ||
readonly 'admin.categoriesContent.deletedMessage': 'Category deleted.'; | ||
readonly 'deleteDialog.cancel': 'Cancel'; | ||
readonly 'deleteDialog.title': 'Are you sure you want to delete this announcement?'; | ||
readonly 'deleteDialog.delete': 'Delete'; | ||
readonly 'announcementsCard.new': 'New'; | ||
readonly 'announcementsCard.in': 'in'; | ||
readonly 'announcementsCard.announcements': 'Announcements'; | ||
readonly 'announcementsCard.seeAll': 'See all'; | ||
readonly 'announcementsCard.noAnnouncements': 'No announcements yet, want to'; | ||
readonly 'announcementsCard.addOne': 'add one'; | ||
readonly 'announcementSearchResultListItem.published': 'Published'; | ||
readonly 'announcementSearchResultListItem.announcement': 'Announcement'; | ||
readonly 'announcementsTimeline.error': 'Error'; | ||
readonly 'announcementsTimeline.noAnnouncements': 'No announcements'; | ||
readonly 'categoriesForm.submit': 'Submit'; | ||
readonly 'categoriesForm.newCategory': 'New category'; | ||
readonly 'categoriesForm.editCategory': 'Edit category'; | ||
readonly 'categoriesForm.titleLabel': 'Title'; | ||
readonly 'categoriesTable.title': 'Title'; | ||
readonly 'categoriesTable.actions': 'Actions'; | ||
readonly 'categoriesTable.categoryDeleted': 'Category deleted.'; | ||
readonly 'categoriesTable.slug': 'Slug'; | ||
readonly 'categoriesTable.addTooltip': 'Add'; | ||
readonly 'categoriesTable.noCategoriesFound': 'No categories found.'; | ||
readonly 'categoriesPage.title': 'Categories'; | ||
readonly 'categoriesPage.subtitle': 'Manage announcement categories'; | ||
readonly 'createAnnouncementPage.alertMessage': 'Announcement created.'; | ||
readonly 'createAnnouncementPage.alertMessageWithNewCategory': 'with new category'; | ||
readonly 'editAnnouncementPage.edit': 'Edit'; | ||
readonly 'editAnnouncementPage.updatedMessage': 'Announcement updated.'; | ||
readonly 'editAnnouncementPage.notFoundMessage': 'Unable to find announcement'; | ||
readonly 'newAnnouncementBanner.markAsSeen': 'Mark as seen'; | ||
readonly 'newCategoryDialog.title': 'Title'; | ||
readonly 'newCategoryDialog.newCategory': 'New category'; | ||
readonly 'newCategoryDialog.createdMessage': 'Category created.'; | ||
readonly 'newCategoryDialog.cancelButton': 'Cancel'; | ||
readonly 'newCategoryDialog.createButton': 'Create'; | ||
}>; | ||
}; | ||
|
||
// @public | ||
export const useCategories: () => { | ||
categories: Category[]; | ||
loading: boolean; | ||
error: Error | undefined; | ||
retry: () => void; | ||
}; | ||
``` |
Oops, something went wrong.