Skip to content

Commit

Permalink
Fixed sets without properties
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Sep 1, 2022
1 parent d2d567d commit b4d56c5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions backend/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ label.configuration-action=Action
message.delete-property-title=Delete Configuration?
message.delete-property-body=You are requesting to delete a configuration set. If you complete this process the set will be removed. This cannot be undone. Do you wish to continue?
message.name-required=Name is required.
message.properties-none=At least one property is required.

label.external-description=Description

Expand Down
12 changes: 11 additions & 1 deletion ui/src/app/admin/component/ConfigurationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export function ConfigurationForm({ configurations, configuration = {}, loading,
const { fields, append, remove } = useFieldArray({
control,
name: "properties",
rules: {
minLength: 1
}
});

const properties = useProperties();
Expand Down Expand Up @@ -80,7 +83,7 @@ export function ConfigurationForm({ configurations, configuration = {}, loading,
<Button variant="info" className="me-2"
type="button"
onClick={() => saveConfig(getValues())}
disabled={ !isValid || loading}
disabled={ !isValid || fields.length < 1 || loading}
aria-label="Save changes to the metadata source. You will return to the dashboard">
<FontAwesomeIcon icon={loading ? faSpinner : faSave} pulse={loading} />&nbsp;
<Translate value="action.save">Save</Translate>
Expand Down Expand Up @@ -169,6 +172,13 @@ export function ConfigurationForm({ configurations, configuration = {}, loading,
</td>
</tr>
))}
{fields.length === 0 &&
<tr>
<td colSpan="5">
<Translate value="message.properties-none">At least one property is required.</Translate>
</td>
</tr>
}
</tbody>
</table>
</div>
Expand Down
3 changes: 1 addition & 2 deletions ui/src/app/admin/component/PropertySelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ export function PropertySelector ({ properties, options, onAddProperties }) {

const menu = useCallback((results, menuProps, state) => {
let index = 0;
const mapped = results.map((p, idx) => !p.category || p.category === '?' ? { ...p, category: 'Misc' } : p);
const ordered = orderBy(mapped, 'category');
const ordered = orderBy(results, 'category');
const grouped = groupBy(ordered, 'category');
const items = Object.keys(grouped).sort().map((item) => {
index = index + 1;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/admin/hoc/PropertiesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function PropertiesProvider({ children, cache = 'no-cache' }) {

function useProperties() {
const { properties } = React.useContext(PropertiesContext);
return properties;
return properties.map((p, idx) => !p.category || p.category === '?' ? { ...p, category: 'Misc' } : p);;
}

function usePropertiesLoading() {
Expand Down

0 comments on commit b4d56c5

Please sign in to comment.