Skip to content

Commit

Permalink
Merge pull request #1308 from syucream/fix/small-improvements-on-fron…
Browse files Browse the repository at this point in the history
…tend

Small improvements on frontend
  • Loading branch information
userlocalhost authored Oct 28, 2024
2 parents bcb955b + e263f41 commit fc245b6
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 73 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/acl/ACLForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import { Schema } from "./aclForm/ACLFormSchema";

import { TestWrapper } from "TestWrapper";
import { ACLForm } from "components/acl/ACLForm";
import { ACLType } from "services/Constants";

test("should render a component with essential props", function () {
const Wrapper: FC = () => {
const { control, watch } = useForm<Schema>({
defaultValues: {
isPublic: true,
defaultPermission: 0,
defaultPermission: ACLType.Nothing,
roles: [],
},
});
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/entry/EntryAttributes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("EntryAttributes", () => {
isReadable: true,
schema: {
id: 1,
name: "string",
name: "string1",
},
value: {
asString: "value1",
Expand All @@ -37,7 +37,7 @@ describe("EntryAttributes", () => {
isReadable: false,
schema: {
id: 2,
name: "string",
name: "string2",
},
value: {
asString: "value2",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/entry/EntryAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const AttrValueTableCell = styled(TableCell)(() => ({
export const EntryAttributes: FC<Props> = ({ attributes }) => {
return (
<TableContainer component={Paper}>
<Table id="table_attr_list">
<Table>
<TableHead sx={{ backgroundColor: "primary.dark" }}>
<TableRow>
<HeaderTableCell>項目</HeaderTableCell>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/entry/EntryHistoryList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("EntryHistoryList", () => {
createdTime: new Date("2020-01-02T00:00:00Z"),
},
{
id: 1,
id: 2,
type: EntryAttributeTypeTypeEnum.STRING,
parentAttr: {
id: 1,
Expand Down
74 changes: 36 additions & 38 deletions frontend/src/components/trigger/ActionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -409,45 +409,43 @@ export const ActionForm: FC<Props> = ({
<>
{fields.map((actionField, index) => (
<TableRow key={actionField.key}>
<Controller
name={`actions.${index}.attr.id`}
control={control}
defaultValue={actionField.attr.id}
render={({ field }) => (
<>
<TableCell>
<Select
{...field}
size="small"
fullWidth
onChange={(e) => {
field.onChange(e);
<TableCell>
<Controller
name={`actions.${index}.attr.id`}
control={control}
defaultValue={actionField.attr.id}
render={({ field }) => (
<Select
{...field}
size="small"
fullWidth
onChange={(e) => {
field.onChange(e);

// clear all action values when attribute is changed
resetActionValues(index);
}}
>
<MenuItem key={0} value={0} disabled hidden />
{entity.attrs
.filter((attr) => isSupportedType(attr))
.map((attr) => (
<MenuItem key={attr.id} value={attr.id}>
{attr.name}
</MenuItem>
))}
</Select>
</TableCell>
<TableCell>
<ActionValue
indexAction={index}
control={control}
actionField={actionField}
entity={entity}
/>
</TableCell>
</>
)}
/>
// clear all action values when attribute is changed
resetActionValues(index);
}}
>
<MenuItem key={0} value={0} disabled hidden />
{entity.attrs
.filter((attr) => isSupportedType(attr))
.map((attr) => (
<MenuItem key={attr.id} value={attr.id}>
{attr.name}
</MenuItem>
))}
</Select>
)}
/>
</TableCell>
<TableCell>
<ActionValue
indexAction={index}
control={control}
actionField={actionField}
entity={entity}
/>
</TableCell>
<TableCell>
{" "}
<IconButton onClick={() => remove(index)}>
Expand Down
54 changes: 26 additions & 28 deletions frontend/src/components/trigger/Conditions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,34 +245,32 @@ export const Conditions: FC<Props> = ({ control, entity }) => {
{fields.map((condField, index) => {
return (
<TableRow key={condField.key}>
<Controller
name={`conditions.${index}.attr.id`}
control={control}
render={({ field }) => (
<>
<TableCell>
<Select {...field} size="small" fullWidth>
<MenuItem key={0} value={0} disabled hidden />
{entity.attrs
.filter((attr) => isSupportedType(attr))
.map((attr) => (
<MenuItem key={attr.id} value={attr.id}>
{attr.name}
</MenuItem>
))}
</Select>
</TableCell>
<TableCell>
<ConditionValue
index={index}
control={control}
condField={condField}
entity={entity}
/>
</TableCell>
</>
)}
/>
<TableCell>
<Controller
name={`conditions.${index}.attr.id`}
control={control}
render={({ field }) => (
<Select {...field} size="small" fullWidth>
<MenuItem key={0} value={0} disabled hidden />
{entity.attrs
.filter((attr) => isSupportedType(attr))
.map((attr) => (
<MenuItem key={attr.id} value={attr.id}>
{attr.name}
</MenuItem>
))}
</Select>
)}
/>
</TableCell>
<TableCell>
<ConditionValue
index={index}
control={control}
condField={condField}
entity={entity}
/>
</TableCell>
<TableCell>
{" "}
<IconButton onClick={() => remove(index)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ exports[`should match snapshot 1`] = `
>
<table
class="MuiTable-root css-rqglhn-MuiTable-root"
id="table_attr_list"
>
<thead
class="MuiTableHead-root css-15n4dzy-MuiTableHead-root"
Expand Down Expand Up @@ -822,7 +821,6 @@ exports[`should match snapshot 1`] = `
>
<table
class="MuiTable-root css-rqglhn-MuiTable-root"
id="table_attr_list"
>
<thead
class="MuiTableHead-root css-15n4dzy-MuiTableHead-root"
Expand Down

0 comments on commit fc245b6

Please sign in to comment.