Refactor of team websites.

This commit is contained in:
Mike Cao 2024-01-18 16:46:40 -08:00
parent 2552e1d495
commit dc3818baaa
22 changed files with 61 additions and 208 deletions

View file

@ -12,9 +12,6 @@ export interface WebsitesDataTableProps {
allowEdit?: boolean;
allowView?: boolean;
showActions?: boolean;
showTeam?: boolean;
includeTeams?: boolean;
onlyTeams?: boolean;
children?: ReactNode;
}
@ -23,9 +20,6 @@ export function WebsitesDataTable({
allowEdit = true,
allowView = true,
showActions = true,
showTeam,
includeTeams,
onlyTeams,
children,
}: WebsitesDataTableProps) {
const { get } = useApi();
@ -33,11 +27,9 @@ export function WebsitesDataTable({
const { websitesUrl } = useContext(SettingsContext);
const queryResult = useFilterQuery({
queryKey: ['websites', { includeTeams, onlyTeams, modified }],
queryKey: ['websites', { modified }],
queryFn: (params: any) => {
return get(websitesUrl, {
includeTeams,
onlyTeams,
...params,
});
},
@ -49,7 +41,6 @@ export function WebsitesDataTable({
{({ data }) => (
<WebsitesTable
data={data}
showTeam={showTeam}
showActions={showActions}
allowEdit={allowEdit}
allowView={allowView}

View file

@ -7,7 +7,6 @@ import SettingsContext from '../SettingsContext';
export interface WebsitesTableProps {
data: any[];
showTeam?: boolean;
showActions?: boolean;
allowEdit?: boolean;
allowView?: boolean;
@ -16,7 +15,6 @@ export interface WebsitesTableProps {
export function WebsitesTable({
data = [],
showTeam,
showActions,
allowEdit,
allowView,
@ -31,16 +29,6 @@ export function WebsitesTable({
<GridTable data={data} cardMode={['xs', 'sm', 'md'].includes(breakpoint)}>
<GridColumn name="name" label={formatMessage(labels.name)} />
<GridColumn name="domain" label={formatMessage(labels.domain)} />
{showTeam && (
<GridColumn name="teamName" label={formatMessage(labels.teamName)}>
{row => row.teamWebsite[0]?.team.name}
</GridColumn>
)}
{showTeam && (
<GridColumn name="owner" label={formatMessage(labels.owner)}>
{row => row.user.username}
</GridColumn>
)}
{showActions && (
<GridColumn name="action" label=" " alignment="end">
{row => {
@ -51,7 +39,7 @@ export function WebsitesTable({
return (
<>
{allowEdit && (!showTeam || ownerId === user.id) && (
{allowEdit && ownerId === user.id && (
<Link href={`${settingsPath}/${id}`}>
<Button>
<Icon>

View file

@ -43,7 +43,7 @@ export function WebsiteDeleteForm({
<Form onSubmit={handleSubmit} error={error}>
<p>
<FormattedMessage
{...messages.deleteWebsite}
{...messages.actionConfirmation}
values={{ confirmation: <b>{CONFIRM_VALUE}</b> }}
/>
</p>

View file

@ -43,7 +43,7 @@ export function WebsiteResetForm({
<Form onSubmit={handleSubmit} error={error}>
<p>
<FormattedMessage
{...messages.resetWebsite}
{...messages.actionConfirmation}
values={{ confirmation: <b>{CONFIRM_VALUE}</b> }}
/>
</p>