Fix report create for view only, fix createdby on save and add column in team websites table

This commit is contained in:
Francis Cao 2024-02-22 15:31:32 -08:00
parent fd1b9ff7b4
commit 8fbd6871f7
5 changed files with 19 additions and 9 deletions

View File

@ -1,20 +1,25 @@
import PageHeader from 'components/layout/PageHeader';
import { Icon, Icons, Text } from 'react-basics';
import { useMessages, useTeamUrl } from 'components/hooks';
import { useLogin, useMessages, useTeamUrl } from 'components/hooks';
import LinkButton from 'components/common/LinkButton';
import { ROLES } from 'lib/constants';
export function ReportsHeader() {
const { formatMessage, labels } = useMessages();
const { renderTeamUrl } = useTeamUrl();
const { user } = useLogin();
const canEdit = user.role !== ROLES.viewOnly;
return (
<PageHeader title={formatMessage(labels.reports)}>
<LinkButton href={renderTeamUrl('/reports/create')} variant="primary">
<Icon>
<Icons.Plus />
</Icon>
<Text>{formatMessage(labels.createReport)}</Text>
</LinkButton>
{canEdit && (
<LinkButton href={renderTeamUrl('/reports/create')} variant="primary">
<Icon>
<Icons.Plus />
</Icon>
<Text>{formatMessage(labels.createReport)}</Text>
</LinkButton>
)}
</PageHeader>
);
}

View File

@ -13,12 +13,15 @@ export function TeamWebsitesTable({
allowEdit?: boolean;
}) {
const { user } = useLogin();
const { formatMessage, labels } = useMessages();
return (
<GridTable data={data}>
<GridColumn name="name" label={formatMessage(labels.name)} />
<GridColumn name="domain" label={formatMessage(labels.domain)} />
<GridColumn name="createdBy" label={formatMessage(labels.createdBy)}>
{row => row?.createUser?.username}
</GridColumn>
<GridColumn name="action" label=" " alignment="end">
{row => {
const { id: websiteId } = row;

View File

@ -26,6 +26,7 @@ export const labels = defineMessages({
myWebsites: { id: 'label.my-websites', defaultMessage: 'My websites' },
teamWebsites: { id: 'label.team-websites', defaultMessage: 'Team websites' },
created: { id: 'label.created', defaultMessage: 'Created' },
createdBy: { id: 'label.created-by', defaultMessage: 'Created By' },
edit: { id: 'label.edit', defaultMessage: 'Edit' },
name: { id: 'label.name', defaultMessage: 'Name' },
member: { id: 'label.member', defaultMessage: 'Member' },

View File

@ -62,6 +62,7 @@ export default async (
const data: any = {
id: uuid(),
createdBy: userId,
name,
domain,
shareId,

View File

@ -87,7 +87,7 @@ export async function getTeamWebsites(
teamId,
},
include: {
user: {
createUser: {
select: {
id: true,
username: true,