Skip to content

Commit

Permalink
fix: remove edit page dependency on erSistPublisert
Browse files Browse the repository at this point in the history
  • Loading branch information
NilsOveTen committed Dec 5, 2024
1 parent cf38ee0 commit 730007d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/components/form-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const FormControl = <V,>({
const dispatch = useAppDispatch();
const conceptForm = useAppSelector(state => state.conceptForm);
const { concept } = conceptForm;
const erSistPublisert = concept?.erSistPublisert ?? false;
const published = concept?.erPublisert ?? false;
const isSaving = conceptForm.isSaving ?? false;
const justChangedStatus = conceptForm.justChangedStatus ?? false;
Expand Down Expand Up @@ -109,7 +108,7 @@ const FormControl = <V,>({
return concept ? (
<SC.FormControl $isSticky={isSticky}>
<SC.FormControlContent>
{isFormDirty && published && erSistPublisert && (
{isFormDirty && published && (
<SC.Button onClick={onNewConceptRevision}>
<SC.StatusDraftIcon />
{localization.saveDraft}
Expand Down
9 changes: 3 additions & 6 deletions src/lib/concept/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { Concept } from '../../types';
import {Concept} from '../../types';

export const isConceptEditable = (concept: Concept | undefined) => {
if (concept == null) {
return false;
}
const { id, erPublisert, erSistPublisert, revisjonAvSistPublisert } = concept;
const editable =
id == null || (erPublisert && erSistPublisert) || revisjonAvSistPublisert;

return editable;
const { id, erPublisert } = concept;
return id == null || !erPublisert;
};
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,11 @@ export const schema = Yup.object().shape({
context.parent.id
? getRevisions(context.parent.id)
.then(revisions => {
const latestPublishedRevision = revisions.find(
rev => rev.erSistPublisert
const latestPublishedRevision = revisions.reduce(
(prev, current) =>
compareVersion(prev.versjonsnr, current.versjonsnr) < 0
? prev
: current
);
return (
compareVersion(
Expand Down

0 comments on commit 730007d

Please sign in to comment.