Skip to content

Commit

Permalink
feat(hub-common): change content settings schema's extract toggle to …
Browse files Browse the repository at this point in the history
…be a tile select (#1681)
  • Loading branch information
sonofflynn89 authored Oct 8, 2024
1 parent 5a128e7 commit 6445470
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 17 deletions.
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

0 comments on commit 6445470

Please sign in to comment.