Merged PR 1229: hide document links if scheduled docapi downtime set
hide document links if scheduled docapi downtime set Related work items: #12112
This commit is contained in:
@@ -54,6 +54,7 @@ SHOWMAPS = "false"
|
|||||||
API_ROOT = "http://localhost:3000"
|
API_ROOT = "http://localhost:3000"
|
||||||
CY_API_ROOT = "http://cymru.local:3000"
|
CY_API_ROOT = "http://cymru.local:3000"
|
||||||
I18N_DOMAIN = "cymru.local"
|
I18N_DOMAIN = "cymru.local"
|
||||||
|
DOCAPI_OFFLINE = "12:00:00,14:00:00"
|
||||||
|
|
||||||
|
|
||||||
// Next Auth vars
|
// Next Auth vars
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ const Case = (props) => {
|
|||||||
searchResultsObj={props.searchResultsObj}
|
searchResultsObj={props.searchResultsObj}
|
||||||
searchDetailsObj={props.searchDetailsObj}
|
searchDetailsObj={props.searchDetailsObj}
|
||||||
documentDetailsObj={props.documentDetailsObj}
|
documentDetailsObj={props.documentDetailsObj}
|
||||||
|
docsOffline={props.props.docsOffline}
|
||||||
/>
|
/>
|
||||||
{showRepresentations == true && (
|
{showRepresentations == true && (
|
||||||
<RepresentationList
|
<RepresentationList
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const DocumentDetails = (props) => {
|
|||||||
documentDetailsObj,
|
documentDetailsObj,
|
||||||
setDocumentDetails,
|
setDocumentDetails,
|
||||||
setCurrentPage,
|
setCurrentPage,
|
||||||
|
docsOffline,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -38,6 +39,40 @@ const DocumentDetails = (props) => {
|
|||||||
const [selectedOption, setSelectedOption] = useState(10);
|
const [selectedOption, setSelectedOption] = useState(10);
|
||||||
const [documentTypes, setDocumentTypes] = useState([{}]);
|
const [documentTypes, setDocumentTypes] = useState([{}]);
|
||||||
const [selectedDocumentType, setSelectedDocumentType] = useState("all");
|
const [selectedDocumentType, setSelectedDocumentType] = useState("all");
|
||||||
|
let ShowDocLinks = false;
|
||||||
|
let checkShowDocLinks = docsOffline != false ? true : false;
|
||||||
|
|
||||||
|
const getDocLink = (docsOffline) => {
|
||||||
|
var startTime = docsOffline.split(",")[0];
|
||||||
|
var endTime = docsOffline.split(",")[1];
|
||||||
|
|
||||||
|
console.log(startTime);
|
||||||
|
console.log(endTime);
|
||||||
|
|
||||||
|
var currentDate = new Date();
|
||||||
|
|
||||||
|
var startDate = new Date(currentDate.getTime());
|
||||||
|
startDate.setHours(startTime.split(":")[0]);
|
||||||
|
startDate.setMinutes(startTime.split(":")[1]);
|
||||||
|
startDate.setSeconds(startTime.split(":")[2]);
|
||||||
|
|
||||||
|
var endDate = new Date(currentDate.getTime());
|
||||||
|
endDate.setHours(endTime.split(":")[0]);
|
||||||
|
endDate.setMinutes(endTime.split(":")[1]);
|
||||||
|
endDate.setSeconds(endTime.split(":")[2]);
|
||||||
|
|
||||||
|
console.log(startDate);
|
||||||
|
console.log(endDate);
|
||||||
|
console.log(currentDate);
|
||||||
|
|
||||||
|
var valid = startDate < currentDate && endDate > currentDate;
|
||||||
|
|
||||||
|
console.log(valid);
|
||||||
|
|
||||||
|
ShowDocLinks = valid;
|
||||||
|
};
|
||||||
|
|
||||||
|
checkShowDocLinks && getDocLink(docsOffline);
|
||||||
|
|
||||||
const DocumentView = (documentDetailsArr) => {
|
const DocumentView = (documentDetailsArr) => {
|
||||||
documentDetailsArr = documentDetailsArr.value;
|
documentDetailsArr = documentDetailsArr.value;
|
||||||
@@ -146,6 +181,23 @@ const DocumentDetails = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
{ShowDocLinks && (
|
||||||
|
<div className="govuk-warning-text ">
|
||||||
|
<span
|
||||||
|
className="govuk-warning-text__icon"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
!
|
||||||
|
</span>
|
||||||
|
<strong className="govuk-warning-text__text govuk-!-margin-top-2">
|
||||||
|
<span className="govuk-visually-hidden">
|
||||||
|
Notice
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{t("case:documents-not-available-label")}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<dl className="documentList govuk-summary-list govuk-!-margin-bottom-9 results">
|
<dl className="documentList govuk-summary-list govuk-!-margin-bottom-9 results">
|
||||||
<div className="govuk-summary-list__row results-headings">
|
<div className="govuk-summary-list__row results-headings">
|
||||||
<dd className="govuk-summary-list__key govuk-!-font-size-16 ">
|
<dd className="govuk-summary-list__key govuk-!-font-size-16 ">
|
||||||
@@ -247,22 +299,46 @@ const DocumentDetails = (props) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Link
|
{!ShowDocLinks ? (
|
||||||
scroll={false}
|
<Link
|
||||||
href={detailsObj.pinswg_hashlink}
|
scroll={false}
|
||||||
key={key}
|
href={
|
||||||
onClick={() => {
|
detailsObj.pinswg_hashlink
|
||||||
toggleDownLoadLink(key);
|
}
|
||||||
}}
|
key={key}
|
||||||
>
|
onClick={() => {
|
||||||
<span className="results-visually-hidden">
|
toggleDownLoadLink(key);
|
||||||
{t("case:documents-name-label")}
|
}}
|
||||||
:
|
>
|
||||||
</span>
|
<span className="results-visually-hidden">
|
||||||
{_.has(detailsObj, "pinswg_name")
|
{t(
|
||||||
? detailsObj.pinswg_name
|
"case:documents-name-label"
|
||||||
: ""}
|
)}
|
||||||
</Link>
|
:
|
||||||
|
</span>
|
||||||
|
{_.has(
|
||||||
|
detailsObj,
|
||||||
|
"pinswg_name"
|
||||||
|
)
|
||||||
|
? detailsObj.pinswg_name
|
||||||
|
: ""}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<span className="results-visually-hidden">
|
||||||
|
{t(
|
||||||
|
"case:documents-name-label"
|
||||||
|
)}
|
||||||
|
:
|
||||||
|
</span>
|
||||||
|
{_.has(
|
||||||
|
detailsObj,
|
||||||
|
"pinswg_name"
|
||||||
|
)
|
||||||
|
? detailsObj.pinswg_name
|
||||||
|
: ""}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</dd>
|
</dd>
|
||||||
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
<dd className="govuk-summary-list__value govuk-!-font-size-16">
|
||||||
<span className="results-visually-hidden">
|
<span className="results-visually-hidden">
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"summary-event-date-label": "Dyddiad Digwyddiad",
|
"summary-event-date-label": "Dyddiad Digwyddiad",
|
||||||
"summary-decision-date-label": "Dyddiad y Penderfyniad",
|
"summary-decision-date-label": "Dyddiad y Penderfyniad",
|
||||||
"summary-documents-button-label": "Dogfennau",
|
"summary-documents-button-label": "Dogfennau",
|
||||||
|
"documents-not-available-label": "Nid yw dogfennau ar gael i'w llwytho i lawr ar hyn o bryd, gwiriwch yn nes ymlaen.",
|
||||||
"documents-document-count-label": "Dogfennau",
|
"documents-document-count-label": "Dogfennau",
|
||||||
"documents-name-label": "Enw",
|
"documents-name-label": "Enw",
|
||||||
"documents-doc-type-label": "Math o Ddogfen",
|
"documents-doc-type-label": "Math o Ddogfen",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"summary-event-date-label": "Event Date",
|
"summary-event-date-label": "Event Date",
|
||||||
"summary-decision-date-label": "Decision Date",
|
"summary-decision-date-label": "Decision Date",
|
||||||
"summary-documents-button-label": "Documents",
|
"summary-documents-button-label": "Documents",
|
||||||
|
"documents-not-available-label": "Documents are not available for download at this time, please check later.",
|
||||||
"documents-document-count-label": "Document(s)",
|
"documents-document-count-label": "Document(s)",
|
||||||
"documents-name-label": "Name",
|
"documents-name-label": "Name",
|
||||||
"documents-doc-type-label": "Document type",
|
"documents-doc-type-label": "Document type",
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
// searchDetailsObj: searchDetailsObj,
|
// searchDetailsObj: searchDetailsObj,
|
||||||
// },
|
// },
|
||||||
currentType: "directResultsObj",
|
currentType: "directResultsObj",
|
||||||
|
docsOffline: process.env.DOCAPI_OFFLINE || false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
searchDetailsObj: searchDetailsObj,
|
searchDetailsObj: searchDetailsObj,
|
||||||
},
|
},
|
||||||
currentType: "directResultsObj",
|
currentType: "directResultsObj",
|
||||||
|
docsOffline: process.env.DOCAPI_OFFLINE || false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,6 +339,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
// searchDetailsObj: searchDetailsObj,
|
// searchDetailsObj: searchDetailsObj,
|
||||||
// },
|
// },
|
||||||
currentType: "directResultsObj",
|
currentType: "directResultsObj",
|
||||||
|
docsOffline: process.env.DOCAPI_OFFLINE || false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
searchDetailsObj: searchDetailsObj,
|
searchDetailsObj: searchDetailsObj,
|
||||||
},
|
},
|
||||||
currentType: "directResultsObj",
|
currentType: "directResultsObj",
|
||||||
|
docsOffline: process.env.DOCAPI_OFFLINE || false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user