Skip to content

Commit

Permalink
Merge branch 'master' into admin-button
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat authored Nov 5, 2024
2 parents b3bb669 + 93a8090 commit b7a58e8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/frontend/src/components/nav/NotificationDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ApiEndpoints } from '../../enums/ApiEndpoints';
import { ModelType } from '../../enums/ModelType';
import { navigateToLink } from '../../functions/navigation';
import { getDetailUrl } from '../../functions/urls';
import { base_url } from '../../main';
import { apiUrl } from '../../states/ApiState';
import { useUserState } from '../../states/UserState';
import { Boundary } from '../Boundary';
Expand Down Expand Up @@ -66,7 +67,7 @@ function NotificationEntry({
>
<Stack gap={2}>
<Anchor
href={link}
href={link ? `/${base_url}${link}` : '#'}
underline="hover"
target="_blank"
onClick={(event: any) => {
Expand Down
11 changes: 6 additions & 5 deletions src/frontend/src/forms/PurchaseOrderForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ function LineItemFormRow({
if (
!record.destination &&
!record.destination_detail &&
location === record.part_detail.category_default_location
record.part_detail &&
location === record.part_detail?.category_default_location
) {
return t`Part category default location selected`;
}
Expand Down Expand Up @@ -511,17 +512,17 @@ function LineItemFormRow({
}
/>
<Flex style={{ marginBottom: '7px' }}>
{(record.part_detail.default_location ||
record.part_detail.category_default_location) && (
{(record.part_detail?.default_location ||
record.part_detail?.category_default_location) && (
<ActionButton
icon={<InvenTreeIcon icon="default_location" />}
tooltip={t`Store at default location`}
onClick={() =>
props.changeFn(
props.idx,
'location',
record.part_detail.default_location ??
record.part_detail.category_default_location
record.part_detail?.default_location ??
record.part_detail?.category_default_location
)
}
tooltipAlignment="top"
Expand Down
16 changes: 8 additions & 8 deletions src/frontend/src/forms/StockForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ function StockItemDefaultMove({
const { data } = useSuspenseQuery({
queryKey: [
'location',
stockItem.part_detail.default_location ??
stockItem.part_detail.category_default_location
stockItem.part_detail?.default_location ??
stockItem.part_detail?.category_default_location
],
queryFn: async () => {
const url = apiUrl(
ApiEndpoints.stock_location_list,
stockItem.part_detail.default_location ??
stockItem.part_detail.category_default_location
stockItem.part_detail?.default_location ??
stockItem.part_detail?.category_default_location
);

return api
Expand Down Expand Up @@ -384,8 +384,8 @@ function moveToDefault(
children: <StockItemDefaultMove stockItem={stockItem} value={value} />,
onConfirm: () => {
if (
stockItem.location === stockItem.part_detail.default_location ||
stockItem.location === stockItem.part_detail.category_default_location
stockItem.location === stockItem.part_detail?.default_location ||
stockItem.location === stockItem.part_detail?.category_default_location
) {
return;
}
Expand All @@ -400,8 +400,8 @@ function moveToDefault(
}
],
location:
stockItem.part_detail.default_location ??
stockItem.part_detail.category_default_location
stockItem.part_detail?.default_location ??
stockItem.part_detail?.category_default_location
})
.then((response) => {
refresh();
Expand Down
15 changes: 10 additions & 5 deletions src/frontend/src/pages/build/BuildDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export default function BuildDetail() {

const user = useUserState();

const buildStatus = useStatusCodes({ modelType: ModelType.build });

const {
instance: build,
refreshInstance,
Expand Down Expand Up @@ -269,8 +271,10 @@ export default function BuildDetail() {
<BuildOutputTable build={build} refreshBuild={refreshInstance} />
) : (
<Skeleton />
)
// TODO: Hide if build is complete
),
hidden:
build.status == buildStatus.COMPLETE ||
build.status == buildStatus.CANCELLED
},
{
name: 'complete-outputs',
Expand All @@ -291,6 +295,9 @@ export default function BuildDetail() {
name: 'allocated-stock',
label: t`Allocated Stock`,
icon: <IconList />,
hidden:
build.status == buildStatus.COMPLETE ||
build.status == buildStatus.CANCELLED,
content: build.pk ? (
<BuildAllocatedStockTable buildId={build.pk} showPartInfo allowEdit />
) : (
Expand Down Expand Up @@ -355,7 +362,7 @@ export default function BuildDetail() {
model_id: build.pk
})
];
}, [build, id, user]);
}, [build, id, user, buildStatus]);

const buildOrderFields = useBuildOrderFields({ create: false });

Expand All @@ -379,8 +386,6 @@ export default function BuildDetail() {
modelType: ModelType.build
});

const buildStatus = useStatusCodes({ modelType: ModelType.build });

const cancelOrder = useCreateApiFormModal({
url: apiUrl(ApiEndpoints.build_order_cancel, build.pk),
title: t`Cancel Build Order`,
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/tables/settings/CustomUnitsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ export default function CustomUnitsTable() {
let actions = [];

actions.push(
// TODO: Adjust actions based on user permissions
<AddItemButton
tooltip={t`Add custom unit`}
onClick={() => newUnit.open()}
hidden={!user.isStaff() || !user.hasChangeRole(UserRoles.admin)}
/>
);

return actions;
}, []);
}, [user]);

return (
<>
Expand Down

0 comments on commit b7a58e8

Please sign in to comment.