Skip to content

Commit

Permalink
Merge branch 'main' into update-opensuse-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukewh authored Aug 9, 2023
2 parents 4175b49 + 255fdbd commit bb7ada8
Show file tree
Hide file tree
Showing 31 changed files with 1,141 additions and 144 deletions.
20 changes: 17 additions & 3 deletions static/js/brand-store/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,21 @@ const policiesListFilterState = atom({
default: "" as string,
});

const signingKeysListState = atom({
key: "signingKeysList",
default: [] as Array<SigningKey>,
const signingKeysListState = atom<SigningKey[]>({
key: "signingKeysListState",
default: [],
});

const signingKeysListFilterState = atom({
key: "signingKeysListFilter",
default: "" as string,
});

const newSigningKeyState = atom({
key: "newSigningKey",
default: {
name: "",
},
});

export {
Expand All @@ -47,4 +59,6 @@ export {
policiesListState,
policiesListFilterState,
signingKeysListState,
signingKeysListFilterState,
newSigningKeyState,
};
1 change: 1 addition & 0 deletions static/js/brand-store/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function App() {
element={<Policies />}
/>
<Route path="/admin/:id/signing-keys" element={<SigningKeys />} />
<Route path="/admin/:id/signing-keys/create" element={<SigningKeys />} />
</Routes>
</div>
</QueryClientProvider>
Expand Down
18 changes: 9 additions & 9 deletions static/js/brand-store/components/Members/Members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,6 @@ function Members() {
) : (
<>
<Row>
<Col size={6}>
<Button
onClick={() => {
setSidePanelOpen(true);
}}
>
Add new member
</Button>
</Col>
<Col size={6}>
<SearchBox
placeholder="Search and filter"
Expand All @@ -229,6 +220,15 @@ function Members() {
}}
/>
</Col>
<Col size={6} className="u-align--right">
<Button
onClick={() => {
setSidePanelOpen(true);
}}
>
Add new member
</Button>
</Col>
</Row>
<div className="u-fixed-width app-accordion">
<Accordion
Expand Down
34 changes: 26 additions & 8 deletions static/js/brand-store/components/Model/Policies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ import PoliciesFilter from "./PoliciesFilter";
import PoliciesTable from "./PoliciesTable";
import CreatePolicyForm from "./CreatePolicyForm";

import { usePolicies } from "../../hooks";
import { policiesListFilterState, policiesListState } from "../../atoms";
import { usePolicies, useSigningKeys } from "../../hooks";
import {
policiesListFilterState,
policiesListState,
signingKeysListState,
} from "../../atoms";
import { brandStoreState } from "../../selectors";

import { isClosedPanel, setPageTitle } from "../../utils";

import type { Policy } from "../../types/shared";
import type { Policy, SigningKey } from "../../types/shared";

function Policies() {
const { id, model_id } = useParams();
Expand All @@ -30,6 +34,7 @@ function Policies() {
id,
model_id
);
const signingKeys = useSigningKeys(id);
const setPoliciesList = useSetRecoilState<Array<Policy>>(policiesListState);
const setFilter = useSetRecoilState<string>(policiesListFilterState);
const brandStore = useRecoilValue(brandStoreState(id));
Expand All @@ -38,6 +43,15 @@ function Policies() {
const [showErrorNotification, setShowErrorNotification] = useState<boolean>(
false
);
const setSigningKeysList = useSetRecoilState<Array<SigningKey>>(
signingKeysListState
);

useEffect(() => {
if (!signingKeys.isLoading && !signingKeys.isError) {
setSigningKeysList(signingKeys.data);
}
}, [signingKeys]);

useEffect(() => {
if (!isLoading && !isError) {
Expand Down Expand Up @@ -92,21 +106,25 @@ function Policies() {
)}
<Row>
<Col size={6}>
<PoliciesFilter />
</Col>
<Col size={6} className="u-align--right">
<Link
className="p-button"
className="p-button--positive"
to={`/admin/${id}/models/${model_id}/policies/create`}
>
Create policy
</Link>
</Col>
<Col size={6}>
<PoliciesFilter />
</Col>
</Row>
<div className="u-fixed-width">
<>
{isLoading && <p>Fetching policies...</p>}
{isError && error && <p>Error: {error.message}</p>}
{isError && error && (
<Notification severity="negative">
Error: {error.message}
</Notification>
)}
<PoliciesTable />
</>
</div>
Expand Down
10 changes: 1 addition & 9 deletions static/js/brand-store/components/Model/PoliciesTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import { useRecoilValue } from "recoil";
import { useParams, Link } from "react-router-dom";
import { format } from "date-fns";
import { MainTable } from "@canonical/react-components";

Expand All @@ -9,7 +8,6 @@ import { filteredPoliciesListState } from "../../selectors";
import type { Policy } from "../../types/shared";

function ModelsTable() {
const { id } = useParams();
const policiesList = useRecoilValue<Array<Policy>>(filteredPoliciesListState);

return (
Expand Down Expand Up @@ -46,13 +44,7 @@ function ModelsTable() {
content: policy.revision,
},
{
content: (
<Link
to={`/admin/${id}/signing-keys/${policy["signing-key-sha3-384"]}`}
>
{policy["signing-key-name"]}
</Link>
),
content: policy["signing-key-name"],
className: "u-align--right",
},
{
Expand Down
17 changes: 12 additions & 5 deletions static/js/brand-store/components/Models/Models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,25 @@ function Models() {
)}
<Row>
<Col size={6}>
<Link className="p-button" to={`/admin/${id}/models/create`}>
<ModelsFilter />
</Col>
<Col size={6} className="u-align--right">
<Link
className="p-button--positive"
to={`/admin/${id}/models/create`}
>
Create new model
</Link>
</Col>
<Col size={6}>
<ModelsFilter />
</Col>
</Row>
<div className="u-fixed-width">
<>
{isLoading && <p>Fetching models...</p>}
{isError && error && <p>Error: {error.message}</p>}
{isError && error && (
<Notification severity="negative">
Error: {error.message}
</Notification>
)}
<ModelsTable />
</>
</div>
Expand Down
3 changes: 2 additions & 1 deletion static/js/brand-store/components/Models/ModelsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ function ModelsTable() {
{model.name}
</Link>
),
className: "u-truncate",
},
{
content: maskString(model["api-key"]),
content: maskString(model["api-key"]) || "-",
className: "u-align--right",
},
{
Expand Down
5 changes: 1 addition & 4 deletions static/js/brand-store/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function Navigation() {
</div>

<div className="p-panel__content">
<div className="p-side-navigation--icons">
<div className="p-side-navigation">
<nav aria-label="Stores navigation">
<ul className="p-side-navigation__list">
{brandStoresList.map((item: Store) => {
Expand All @@ -64,9 +64,6 @@ function Navigation() {
className="p-side-navigation__link"
to={`/admin/${item.id}/snaps`}
>
<i className="p-side-navigation__icon p-icon--initial">
<span>{item.name.charAt(0)}</span>
</i>
<span className="p-side-navigation__label u-truncate">
{item.name}
</span>
Expand Down
Loading

0 comments on commit bb7ada8

Please sign in to comment.