diff --git a/plugins/bazaar-backend/migrations/20210902073122_init.js b/plugins/bazaar-backend/migrations/20210902073122_init.js index 42244216b3..0649061c10 100644 --- a/plugins/bazaar-backend/migrations/20210902073122_init.js +++ b/plugins/bazaar-backend/migrations/20210902073122_init.js @@ -19,15 +19,18 @@ exports.up = async function setUpTables(knex) { table.comment('The table of Bazaar metadata'); table.text('name').notNullable().comment('The name of the entity'); table.text('entity_ref').notNullable().comment('The ref of the entity'); + table + .text('community') + .comment('Link to where the community can discuss ideas'); table .text('announcement') .notNullable() - .comment('The announcement of the bazaar project'); + .comment('The announcement of the Bazaar project'); table .text('status') .defaultTo('proposed') .notNullable() - .comment('The status of the bazaar project'); + .comment('The status of the Bazaar project'); table .dateTime('updated_at') .defaultTo(knex.fn.now()) diff --git a/plugins/bazaar-backend/src/service/router.ts b/plugins/bazaar-backend/src/service/router.ts index e814c0a695..b6f1ba10b3 100644 --- a/plugins/bazaar-backend/src/service/router.ts +++ b/plugins/bazaar-backend/src/service/router.ts @@ -138,12 +138,13 @@ export async function createRouter( router.put('/metadata', async (request, response) => { const entityRef = request.headers.entity_ref; - const { name, announcement, status } = request.body; + const { name, announcement, status, community } = request.body; const count = await db?.('public.metadata') .where({ entity_ref: entityRef }) .update({ announcement: announcement, + community: community, status: status, }); @@ -154,6 +155,7 @@ export async function createRouter( ?.insert({ name: name, entity_ref: entityRef, + community: community, announcement: announcement, status: status, }) diff --git a/plugins/bazaar/src/api.ts b/plugins/bazaar/src/api.ts index ec6dd8ec0a..fb133b5a28 100644 --- a/plugins/bazaar/src/api.ts +++ b/plugins/bazaar/src/api.ts @@ -35,6 +35,7 @@ export interface BazaarApi { updateMetadata( entity: Entity, name: string, + community: string, announcement: string, status: Status, ): Promise; @@ -73,6 +74,7 @@ export class BazaarClient implements BazaarApi { async updateMetadata( entity: Entity, name: string, + community: string, announcement: string, status: Status, ): Promise { @@ -88,6 +90,7 @@ export class BazaarClient implements BazaarApi { body: JSON.stringify({ name: name, announcement: announcement, + community: community, status: status, }), }).then(resp => resp.json()); diff --git a/plugins/bazaar/src/components/AddProjectDialog/AddProjectDialog.tsx b/plugins/bazaar/src/components/AddProjectDialog/AddProjectDialog.tsx index 2b0b6bb527..2cac8521f6 100644 --- a/plugins/bazaar/src/components/AddProjectDialog/AddProjectDialog.tsx +++ b/plugins/bazaar/src/components/AddProjectDialog/AddProjectDialog.tsx @@ -49,6 +49,7 @@ export const AddProjectDialog = ({ const defaultValues = { title: 'Add project', + community: '', announcement: '', status: 'proposed' as Status, }; @@ -66,6 +67,7 @@ export const AddProjectDialog = ({ const bazaarProject: BazaarProject = { entityRef: stringifyEntityRef(selectedEntity!), name: selectedEntity!.metadata.name, + community: formValues.community, announcement: formValues.announcement, status: formValues.status, updatedAt: new Date().toISOString(), @@ -82,6 +84,7 @@ export const AddProjectDialog = ({ await bazaarApi.updateMetadata( selectedEntity!, selectedEntity!.metadata.name, + formValues.community, formValues.announcement, formValues.status, ); diff --git a/plugins/bazaar/src/components/EditProjectDialog/EditProjectDialog.tsx b/plugins/bazaar/src/components/EditProjectDialog/EditProjectDialog.tsx index 657d9e965e..bb179b4331 100644 --- a/plugins/bazaar/src/components/EditProjectDialog/EditProjectDialog.tsx +++ b/plugins/bazaar/src/components/EditProjectDialog/EditProjectDialog.tsx @@ -39,6 +39,7 @@ export const EditProjectDialog = ({ }: Props) => { const [defaultValues, setDefaultValues] = useState({ announcement: bazaarProject.announcement, + community: bazaarProject.community, status: bazaarProject.status, }); @@ -47,6 +48,7 @@ export const EditProjectDialog = ({ useEffect(() => { setDefaultValues({ announcement: bazaarProject.announcement, + community: bazaarProject.community, status: bazaarProject.status, }); }, [bazaarProject]); @@ -57,6 +59,7 @@ export const EditProjectDialog = ({ const updateResponse = await bazaarApi.updateMetadata( entity!, entity.metadata.name, + formValues.community, formValues.announcement, formValues.status, ); @@ -65,6 +68,7 @@ export const EditProjectDialog = ({ setBazaarProject((oldProject: BazaarProject) => { return { ...oldProject, + community: formValues.community, announcement: formValues.announcement, status: formValues.status, }; diff --git a/plugins/bazaar/src/components/EntityBazaarInfoCard/EntityBazaarInfoCard.tsx b/plugins/bazaar/src/components/EntityBazaarInfoCard/EntityBazaarInfoCard.tsx index bf72a7eea5..efd0339d9e 100644 --- a/plugins/bazaar/src/components/EntityBazaarInfoCard/EntityBazaarInfoCard.tsx +++ b/plugins/bazaar/src/components/EntityBazaarInfoCard/EntityBazaarInfoCard.tsx @@ -91,6 +91,7 @@ export const EntityBazaarInfoCard = () => { const [bazaarProject, setBazaarProject] = useState({ entityRef: '', name: '', + community: '', announcement: '', status: 'proposed', updatedAt: '', @@ -129,6 +130,7 @@ export const EntityBazaarInfoCard = () => { setBazaarProject({ entityRef: data[0].entityRef, name: data[0].name, + community: data[0].community, announcement: data[0].announcement, status: data[0].status, updatedAt: data[0].updatedAt, @@ -188,6 +190,8 @@ export const EntityBazaarInfoCard = () => { { label: 'Community', icon: , + href: bazaarProject.community, + disabled: bazaarProject.community === '', }, { label: isMember ? 'Leave' : 'Join', diff --git a/plugins/bazaar/src/components/InputField/InputField.tsx b/plugins/bazaar/src/components/InputField/InputField.tsx index 68dd201c55..de2179ef23 100644 --- a/plugins/bazaar/src/components/InputField/InputField.tsx +++ b/plugins/bazaar/src/components/InputField/InputField.tsx @@ -20,30 +20,30 @@ import { TextField } from '@material-ui/core'; import { FormValues } from '../../types'; type Props = { - inputType: string; - error: FieldError | undefined; + inputType: 'announcement' | 'community'; + error?: FieldError | undefined; control: Control; - name: 'announcement' | 'status'; - helperText: string; + helperText?: string; placeholder?: string; + required: boolean; }; export const InputField = ({ inputType, error, control, - name, helperText, placeholder, + required, }: Props) => { const label = inputType.charAt(0).toUpperCase() + inputType.slice(1); return ( ( + + { name: project.name, status: project.status, announcement: project.announcement, + community: project.community, updatedAt: project.updated_at, }); @@ -95,9 +100,7 @@ export const SortView = () => { setBazaarProjects(dbProjects); setCatalogEntities( entities.items.filter((entity: Entity) => { - const catalogEntityRef = `${entity.metadata.namespace}/${entity.kind}/${entity.metadata.name}`; - - return !bazaarProjectRefs.includes(catalogEntityRef); + return !bazaarProjectRefs.includes(stringifyEntityRef(entity)); }), ); }); diff --git a/plugins/bazaar/src/types.ts b/plugins/bazaar/src/types.ts index f9d53cc866..d04859db93 100644 --- a/plugins/bazaar/src/types.ts +++ b/plugins/bazaar/src/types.ts @@ -27,6 +27,7 @@ export type Status = 'ongoing' | 'proposed'; export type BazaarProject = { name: string; entityRef: EntityRef; + community: string; status: Status; announcement: string; updatedAt: string; @@ -34,5 +35,6 @@ export type BazaarProject = { export type FormValues = { announcement: string; + community: string; status: string; };