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(hub-common): change content settings schema's extract toggle to be a tile select #1681

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/common/src/content/_internal/ContentSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const ContentSchema: IConfigurationSchema = {
},
serverExtractCapability: {
type: "boolean",
enum: [true, false],
},
schedule: {
type: "object",
Expand Down
27 changes: 17 additions & 10 deletions packages/common/src/content/_internal/getDownloadsSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export function getDownloadsSection(
): IUiSchemaElement {
const downloadSectionElements: IUiSchemaElement[] = [];

if (shouldShowExtractToggleElement(entity)) {
const extractToggleElement = getExtractToggleElement(i18nScope);
downloadSectionElements.push(extractToggleElement);
if (shouldShowDownloadSystemElement(entity)) {
const downloadSystemElement = getDownloadSystemElement(i18nScope);
downloadSectionElements.push(downloadSystemElement);
}

const downloadFormatsElement = getDownloadFormatsElement(i18nScope, entity);
Expand All @@ -41,23 +41,30 @@ export function getDownloadsSection(
}

/**
* NOTE: we only show the extract toggle for main entities of a hosted feature service
* NOTE: we only show the download system toggle for main entities of a hosted feature service
* since we can guarantee that the user will have the necessary permissions to enable
* extract capabilities on the service.
*/
function shouldShowExtractToggleElement(entity: IHubEditableContent): boolean {
function shouldShowDownloadSystemElement(entity: IHubEditableContent): boolean {
return isHostedFeatureServiceMainEntity(entity);
}

function getExtractToggleElement(i18nScope: string): IUiSchemaElement {
function getDownloadSystemElement(i18nScope: string): IUiSchemaElement {
return {
labelKey: `${i18nScope}.fields.serverExtractCapability.label`,
scope: "/properties/serverExtractCapability",
type: "Control",
options: {
helperText: {
labelKey: `${i18nScope}.fields.serverExtractCapability.helperText`,
},
control: "hub-field-input-tile-select",
labels: [
`{{${i18nScope}.fields.serverExtractCapability.exportDataSetting.label:translate}}`,
`{{${i18nScope}.fields.serverExtractCapability.defaultDownloadsSystem.label:translate}}`,
],
descriptions: [
`{{${i18nScope}.fields.serverExtractCapability.exportDataSetting.description:translate}}`,
`{{${i18nScope}.fields.serverExtractCapability.defaultDownloadsSystem.description:translate}}`,
],
layout: "vertical",
messages: [
{
type: UiSchemaMessageTypes.custom,
Expand Down Expand Up @@ -107,7 +114,7 @@ function getDownloadFormatsElement(
// Product has asked that if the extract capability toggle is present, we should disable
// the download formats control when the toggle is off. We hope this will encourage more
// users to opt into the hosted downloads experience.
if (shouldShowExtractToggleElement(entity)) {
if (shouldShowDownloadSystemElement(entity)) {
result.rules.push({
effect: UiSchemaRuleEffects.DISABLE,
conditions: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ describe("buildUiSchema: content settings", () => {
scope: "/properties/serverExtractCapability",
type: "Control",
options: {
helperText: {
labelKey:
"some.scope.fields.serverExtractCapability.helperText",
},
control: "hub-field-input-tile-select",
labels: [
`{{some.scope.fields.serverExtractCapability.exportDataSetting.label:translate}}`,
`{{some.scope.fields.serverExtractCapability.defaultDownloadsSystem.label:translate}}`,
],
descriptions: [
`{{some.scope.fields.serverExtractCapability.exportDataSetting.description:translate}}`,
`{{some.scope.fields.serverExtractCapability.defaultDownloadsSystem.description:translate}}`,
],
layout: "vertical",
messages: [
{
type: "CUSTOM",
Expand Down
13 changes: 10 additions & 3 deletions packages/common/test/content/_internal/getDownloadsSection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ describe("getDownloadsSection", () => {
scope: "/properties/serverExtractCapability",
type: "Control",
options: {
helperText: {
labelKey: "some.scope.fields.serverExtractCapability.helperText",
},
control: "hub-field-input-tile-select",
labels: [
`{{some.scope.fields.serverExtractCapability.exportDataSetting.label:translate}}`,
`{{some.scope.fields.serverExtractCapability.defaultDownloadsSystem.label:translate}}`,
],
descriptions: [
`{{some.scope.fields.serverExtractCapability.exportDataSetting.description:translate}}`,
`{{some.scope.fields.serverExtractCapability.defaultDownloadsSystem.description:translate}}`,
],
layout: "vertical",
messages: [
{
type: "CUSTOM",
Expand Down
Loading