Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding license picker to content workspace #1192

Merged
merged 8 commits into from
Aug 29, 2023
Merged
6 changes: 6 additions & 0 deletions packages/common/src/content/_internal/ContentSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ export const ContentEditorTypes = ["hub:content:edit"] as const;
*/
export const ContentSchema: IConfigurationSchema = {
...HubItemEntitySchema,
properties: {
...HubItemEntitySchema.properties,
licenseInfo: {
type: "string",
},
},
} as IConfigurationSchema;
12 changes: 12 additions & 0 deletions packages/common/src/content/_internal/ContentUiSchemaEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ export const uiSchema: IUiSchema = {
},
},
},
// license
{
labelKey: "{{i18nScope}}.fields.license.label",
scope: "/properties/licenseInfo",
type: "Control",
options: {
control: "arcgis-hub-license-picker",
helperText: {
labelKey: "{{i18nScope}}.fields.license.helperText",
},
},
},
],
},
// location section
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/content/_internal/computeProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function computeProps(
}
// thumbnail url
content.thumbnailUrl = getItemThumbnailUrl(model.item, requestOptions, token);
content.licenseInfo = model.item.licenseInfo;

if (!content.location) {
// build location if one does not exist based off of the boundary and the item's extent
Expand Down
5 changes: 5 additions & 0 deletions packages/common/src/content/_internal/getPropertyMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export function getPropertyMap(): IPropertyMap[] {
storeKey: "item.properties.location",
});

map.push({
entityKey: "licenseInfo",
storeKey: "item.licenseInfo",
});

// features is intentionally left out

// TODO: look into composeContent() for what we can add here
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/core/types/IHubEditableContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface IHubEditableContent
* TODO: add additional props
* perhaps using Pick from IHubContent
*/
licenseInfo: string;
}

export type IHubContentEditor = Omit<IHubEditableContent, "extent"> & {
Expand Down
2 changes: 2 additions & 0 deletions packages/common/test/content/edit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe("content editing:", () => {
canEdit: false,
canDelete: false,
location: { type: "none" },
licenseInfo: "",
};
const chk = await updateContent(content, { authentication: MOCK_AUTH });
expect(chk.id).toBe(GUID);
Expand Down Expand Up @@ -117,6 +118,7 @@ describe("content editing:", () => {
canEdit: false,
canDelete: false,
location: { type: "item" },
licenseInfo: "",
};
const chk = await updateContent(content, { authentication: MOCK_AUTH });
expect(chk.id).toBe(GUID);
Expand Down