Skip to content

Commit d43fb13

Browse files
Various M2M portal updates
ref DEV-2937 ref DEV-2938 ref DEV-2939 ref DEV-2940
2 parents cee4d5e + d0f5eea commit d43fb13

6 files changed

Lines changed: 370 additions & 125 deletions

File tree

portal/src/components/api-resources/ApplicationResourcesList.tsx

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ interface ApplicationResourcesListProps {
3232
isAuthorized: boolean
3333
) => void;
3434
disabledToggleClientIDs?: string[];
35-
onManageScopes: (item: ApplicationResourceListItem) => void;
35+
onManageScopes?: (item: ApplicationResourceListItem) => void;
3636
}
3737

3838
export const ApplicationResourcesList: React.FC<ApplicationResourcesListProps> =
@@ -65,54 +65,57 @@ export const ApplicationResourcesList: React.FC<ApplicationResourcesListProps> =
6565
);
6666

6767
const columns: IColumn[] = useMemo(
68-
() => [
69-
{
70-
key: "resources",
71-
name: renderToString("ApplicationResourcesList.columns.resources"),
72-
minWidth: 200,
73-
maxWidth: 400,
74-
isResizable: true,
75-
onRender: (item: ApplicationResourceListItem) => {
76-
return item.name || item.resourceURI;
68+
() =>
69+
[
70+
{
71+
key: "resources",
72+
name: renderToString("ApplicationResourcesList.columns.resources"),
73+
minWidth: 200,
74+
maxWidth: 400,
75+
isResizable: true,
76+
onRender: (item: ApplicationResourceListItem) => {
77+
return item.name || item.resourceURI;
78+
},
7779
},
78-
},
79-
{
80-
key: "authorized",
81-
name: renderToString("ApplicationResourcesList.columns.authorized"),
82-
minWidth: 150,
83-
isResizable: true,
84-
onRender: renderAuthorizedToggle,
85-
},
86-
{
87-
key: "actions",
88-
name: "",
89-
minWidth: 100,
90-
maxWidth: 100,
91-
isResizable: false,
92-
// eslint-disable-next-line react/no-unstable-nested-components
93-
onRender: (item: ApplicationResourceListItem) => {
94-
if (!item.isAuthorized) {
95-
return null;
96-
}
97-
const handleClick = () => {
98-
onManageScopes(item);
99-
};
100-
return (
101-
<ActionButton
102-
text={renderToString(
103-
"ApplicationResourcesList.columns.manageScopes"
104-
)}
105-
styles={{
106-
label: { fontWeight: 600 },
107-
root: { height: "auto" },
108-
}}
109-
theme={themes.actionButton}
110-
onClick={handleClick}
111-
/>
112-
);
80+
{
81+
key: "authorized",
82+
name: renderToString("ApplicationResourcesList.columns.authorized"),
83+
minWidth: 150,
84+
isResizable: true,
85+
onRender: renderAuthorizedToggle,
11386
},
114-
},
115-
],
87+
onManageScopes
88+
? {
89+
key: "actions",
90+
name: "",
91+
minWidth: 100,
92+
maxWidth: 100,
93+
isResizable: false,
94+
// eslint-disable-next-line react/no-unstable-nested-components
95+
onRender: (item: ApplicationResourceListItem) => {
96+
if (!item.isAuthorized) {
97+
return null;
98+
}
99+
const handleClick = () => {
100+
onManageScopes(item);
101+
};
102+
return (
103+
<ActionButton
104+
text={renderToString(
105+
"ApplicationResourcesList.columns.manageScopes"
106+
)}
107+
styles={{
108+
label: { fontWeight: 600 },
109+
root: { height: "auto" },
110+
}}
111+
theme={themes.actionButton}
112+
onClick={handleClick}
113+
/>
114+
);
115+
},
116+
}
117+
: null,
118+
].filter((it) => !!it),
116119
[
117120
renderToString,
118121
renderAuthorizedToggle,

portal/src/components/api-resources/ResourceForm.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ export interface ResourceFormProps {
2525
}
2626

2727
export function sanitizeFormState(state: ResourceFormState): ResourceFormState {
28+
const resourceURI = state.resourceURI.trim();
29+
2830
return {
2931
name: state.name.trim(),
30-
resourceURI: state.resourceURI.trim(),
32+
resourceURI: resourceURI ? `https://${resourceURI}` : "",
3133
};
3234
}
3335

@@ -41,11 +43,16 @@ export const ResourceForm: React.VFC<ResourceFormProps> =
4143
function ResourceForm({ className, state, setState, mode }) {
4244
const { renderToString } = useContext(Context);
4345
const handleNameChange = useCallback(
44-
(_e, value) => setState((s) => ({ ...s, name: value ?? "" })),
46+
(_e, value?: string) => setState((s) => ({ ...s, name: value ?? "" })),
4547
[setState]
4648
);
4749
const handleResourceURIChange = useCallback(
48-
(_e, value) => setState((s) => ({ ...s, resourceURI: value ?? "" })),
50+
(_e, value?: string) =>
51+
setState((s) => {
52+
let resourceURI = value ?? "";
53+
resourceURI = resourceURI.replace(/^(\s*)https:\/\//, "");
54+
return { ...s, resourceURI: resourceURI };
55+
}),
4956
[setState]
5057
);
5158
const { onSubmit, canSave, isUpdating } = useFormContainerBaseContext();
@@ -104,11 +111,9 @@ export const ResourceForm: React.VFC<ResourceFormProps> =
104111
fieldName="resourceURI"
105112
parentJSONPointer=""
106113
type="text"
114+
prefix="https://"
107115
value={state.resourceURI}
108116
onChange={handleResourceURIChange}
109-
placeholder={renderToString(
110-
"ResourceForm.resourceURI.placeholder"
111-
)}
112117
/>
113118
)}
114119
</div>

portal/src/graphql/portal/CreateOAuthClientScreen.module.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
.buttons {
2222
display: flex;
23-
flex-direction: row-reverse;
2423
align-items: center;
24+
justify-content: flex-start;
25+
@apply gap-6;
2526
}

0 commit comments

Comments
 (0)