Skip to content

Commit

Permalink
Merge pull request #4429 from nulib/deploy/staging
Browse files Browse the repository at this point in the history
Deploy v9.7.1 to production
  • Loading branch information
mbklein authored Feb 26, 2025
2 parents 59ade10 + fc612ba commit 10ab324
Show file tree
Hide file tree
Showing 19 changed files with 504 additions and 467 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
actions: write
jobs:
build:
if: ${{ ! github.event.pull_request }}
if: ${{ !github.event.pull_request && !contains(github.event.head_commit.message, '[no-deploy]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
51 changes: 33 additions & 18 deletions app/assets/js/components/Dashboards/LocalAuthorities/List.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ import {
UPDATE_NUL_AUTHORITY_RECORD,
} from "@js/components/Dashboards/dashboards.gql";
import { IconEdit, IconImages, IconTrashCan } from "@js/components/Icon";
import { Link, useHistory } from "react-router-dom";
import { useHistory } from "react-router-dom";
import { ModalDelete, SearchBarRow } from "@js/components/UI/UI";
import {
useLazyQuery,
useMutation,
useQuery,
} from "@apollo/client";
import { useLazyQuery, useMutation, useQuery } from "@apollo/client";

import { AUTHORITIES_SEARCH } from "@js/components/Work/controlledVocabulary.gql";
import DashboardsLocalAuthoritiesModalEdit from "@js/components/Dashboards/LocalAuthorities/ModalEdit";
Expand All @@ -34,13 +30,16 @@ export default function DashboardsLocalAuthoritiesList() {
},
});
const [searchValue, setSearchValue] = React.useState("");
const [limit, setLimit] = React.useState(100);

// GraphQL
const { loading, error, data } = useQuery(GET_NUL_AUTHORITY_RECORDS, {
variables: { limit: 100 },
pollInterval: 1000,
variables: { limit },
pollInterval: 10000,
});

const limitOptions = [25, 50, 100, 500];

function filterValues() {
if (!data) return;
if (searchValue) {
Expand All @@ -64,7 +63,7 @@ export default function DashboardsLocalAuthoritiesList() {
fields: {
nulAuthorityRecords(existingNulAuthorityRefs = [], { readField }) {
const newData = existingNulAuthorityRefs.filter(
(ref) => deleteNulAuthorityRecord.id !== readField("id", ref)
(ref) => deleteNulAuthorityRecord.id !== readField("id", ref),
);
return [...newData];
},
Expand All @@ -74,10 +73,7 @@ export default function DashboardsLocalAuthoritiesList() {
onError({ graphQLErrors, networkError }) {
console.error("graphQLErrors", graphQLErrors);
console.error("networkError", networkError);
toastWrapper(
"is-danger",
`Error deleting authority record.`
);
toastWrapper("is-danger", `Error deleting authority record.`);
},
});

Expand All @@ -88,7 +84,7 @@ export default function DashboardsLocalAuthoritiesList() {
onCompleted({ updateNulAuthorityRecord }) {
toastWrapper(
"is-success",
`NUL Authority: ${updateNulAuthorityRecord.label} updated`
`NUL Authority: ${updateNulAuthorityRecord.label} updated`,
);
setCurrentAuthority(null);
filterValues();
Expand All @@ -110,10 +106,7 @@ export default function DashboardsLocalAuthoritiesList() {
onError({ graphQLErrors, networkError }) {
console.error("graphQLErrors", graphQLErrors);
console.error("networkError", networkError);
toastWrapper(
"is-danger",
`Error searching NUL local authorities.`
);
toastWrapper("is-danger", `Error searching NUL local authorities.`);
},
});

Expand Down Expand Up @@ -184,6 +177,28 @@ export default function DashboardsLocalAuthoritiesList() {
/>
</SearchBarRow>

<div
className="is-flex is-justify-content-flex-end is-align-items-center mb-5"
data-testid="local-authorities-dashboard-table-options"
>
<label className="is-flex is-align-items-center columns is-3">
<span className="column">Item Count</span>
<div className="is-flex is-align-items-center column">
{limitOptions.map((option) => {
return (
<button
key={option}
className={`button ${limit === option ? "is-primary active" : "is-ghost"}`}
onClick={() => setLimit(option)}
>
{option}
</button>
);
})}
</div>
</label>
</div>

<div className="table-container">
<table
className="table is-striped is-fullwidth"
Expand Down
30 changes: 28 additions & 2 deletions app/assets/js/components/Dashboards/LocalAuthorities/List.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DashboardsLocalAuthoritiesList from "./List";
import {
deleteNulAuthorityRecordMock,
getNulAuthorityRecordsMock,
getNulAuthorityRecordsSetLimitMock,
updateNulAuthorityRecordMock,
} from "@js/components/Dashboards/dashboards.gql.mock";
import { authoritiesSearchMock } from "@js/components/Work/controlledVocabulary.gql.mock";
Expand All @@ -16,6 +17,7 @@ describe("DashboardsLocalAuthoritiesList component", () => {
mocks: [
deleteNulAuthorityRecordMock,
getNulAuthorityRecordsMock,
getNulAuthorityRecordsSetLimitMock,
updateNulAuthorityRecordMock,
],
});
Expand All @@ -32,17 +34,41 @@ describe("DashboardsLocalAuthoritiesList component", () => {

it("renders correct nul authority row details", async () => {
const td = await screen.findByText(
"info:nul/675ed59a-ab54-481a-9bd1-d9b7fd2604dc"
"info:nul/675ed59a-ab54-481a-9bd1-d9b7fd2604dc",
);
const row = td.closest("tr");
const utils = within(row);
expect(utils.getByText(/NUL Auth Record 1/i));
expect(utils.getByText(/Ima Hint 1/i));
});

it("renders correct nul authority query limit options", async () => {
const options = await screen.findByTestId(
"local-authorities-dashboard-table-options",
);

const buttons = within(options).getAllByRole("button");

// expect 4 buttons
expect(buttons).toHaveLength(4);

// expect button text content
expect(buttons[0]).toHaveTextContent("25");
expect(buttons[1]).toHaveTextContent("50");
expect(buttons[2]).toHaveTextContent("100");
expect(buttons[3]).toHaveTextContent("500");

// expect default active button
expect(buttons[2]).toHaveClass("active", "is-primary");

// expect button click and active class change
await userEvent.click(buttons[0]);
expect(await screen.findByText("25")).toHaveClass("active", "is-primary");
});

it("renders an edit, search, and delete buttons", async () => {
const td = await screen.findByText(
"info:nul/675ed59a-ab54-481a-9bd1-d9b7fd2604dc"
"info:nul/675ed59a-ab54-481a-9bd1-d9b7fd2604dc",
);
const row = td.closest("tr");
const utils = within(row);
Expand Down
19 changes: 16 additions & 3 deletions app/assets/js/components/Dashboards/dashboards.gql.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export const mockGetBatchesResults = [
worksUpdated: 2,
},
{
add:
'{"administrative_metadata":{},"descriptive_metadata":{"alternate_title":["Alt title here"],"box_name":["Beta box"],"box_number":["14"],"contributor":[{"role":{"id":"asg","scheme":"marc_relator"},"term":"http://id.worldcat.org/fast/1204155"}],"keywords":["some key word","keyword2"]}}',
add: '{"administrative_metadata":{},"descriptive_metadata":{"alternate_title":["Alt title here"],"box_name":["Beta box"],"box_number":["14"],"contributor":[{"role":{"id":"asg","scheme":"marc_relator"},"term":"http://id.worldcat.org/fast/1204155"}],"keywords":["some key word","keyword2"]}}',
delete: '{"genre":[{"term":"http://vocab.getty.edu/aat/300266117"}]}',
error: null,
id: "7b9fa4c5-fa97-46e8-8fd7-db0001dc76c3",
Expand Down Expand Up @@ -224,7 +223,21 @@ export const getNulAuthorityRecordsMock = {
query: GET_NUL_AUTHORITY_RECORDS,
variables: {
limit: 100,
}
},
},
result: {
data: {
nulAuthorityRecords: mockNulAuthorityRecords,
},
},
};

export const getNulAuthorityRecordsSetLimitMock = {
request: {
query: GET_NUL_AUTHORITY_RECORDS,
variables: {
limit: 25,
},
},
result: {
data: {
Expand Down
Loading

0 comments on commit 10ab324

Please sign in to comment.