-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
280 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/common/src/sites/_internal/SiteUiSchemaSettings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { IHubSite } from "../../core/types"; | ||
import { IArcGISContext } from "../../ArcGISContext"; | ||
import { IUiSchema } from "../../core/schemas/types"; | ||
|
||
/** | ||
* @private | ||
* constructs the edit uiSchema for Hub Sites. | ||
* This defines how the schema properties should | ||
* be rendered in the site editing experience | ||
*/ | ||
export const buildUiSchema = async ( | ||
i18nScope: string, | ||
entity: IHubSite, | ||
context: IArcGISContext | ||
): Promise<IUiSchema> => { | ||
return { | ||
type: "Layout", | ||
elements: [ | ||
{ | ||
type: "Section", | ||
elements: [ | ||
{ | ||
scope: "/properties/telemetry/properties/consentNotice", | ||
type: "Control", | ||
options: { | ||
control: "arcgis-privacy-config", | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
}; |
59 changes: 59 additions & 0 deletions
59
packages/common/src/sites/_internal/_migrate-telemetry-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { getProp, setProp } from "../../objects"; | ||
import { IModel, IDraft } from "../../types"; | ||
import { cloneObject } from "../../util"; | ||
|
||
/** | ||
* Reconfigure event list card properties | ||
* @private | ||
* @param {object} model Site Model | ||
* @returns {object} | ||
*/ | ||
export function _migrateTelemetryConfig<T extends IModel | IDraft>( | ||
model: T | ||
): T { | ||
const newSchemaVersion = 1.7; | ||
// do nothing if migration already applied | ||
if (getProp(model, "item.properties.schemaVersion") >= newSchemaVersion) { | ||
return model; | ||
} | ||
|
||
// apply migration | ||
const clone = cloneObject(model); | ||
|
||
clone.data.telemetry = {}; | ||
// get allowPrivacyConfig from consentNotice capability | ||
const capabilities = getProp(model, "data.values.capabilities") || []; | ||
const allowPrivacyConfig = capabilities.includes("consentNotice"); | ||
|
||
// migrate consentNotice | ||
clone.data.telemetry.consentNotice = { | ||
allowPrivacyConfig, | ||
disclaimer: [ | ||
{ | ||
text: | ||
getProp(model, "data.values.telemetry.consentNotice.consentText") || | ||
"", | ||
default: true, | ||
}, | ||
], | ||
policyURL: | ||
getProp(model, "data.values.telemetry.consentNotice.policyURL") || "", | ||
}; | ||
|
||
// this doesn't actually have any effect - not sure we have a way to get rid of stuff | ||
// delete clone.data?.values?.telemetry; | ||
|
||
// if we have item.properties.telemetry.plugins, move it to data.telemetry | ||
const plugins = getProp(model, "item.properties.telemetry.plugins"); | ||
if (plugins) { | ||
clone.data.telemetry.plugins = plugins; | ||
|
||
// this doesn't actually have any effect - not sure we have a way to get rid of stuff | ||
// delete clone.item?.properties?.telemetry; | ||
} | ||
|
||
// increment schemaVersion | ||
setProp("item.properties.schemaVersion", newSchemaVersion, clone); | ||
|
||
return clone; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const SITE_SCHEMA_VERSION = 1.6; | ||
export const SITE_SCHEMA_VERSION = 1.7; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/common/test/sites/_internal/SiteuUiSchemaTelemetry.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { buildUiSchema } from "../../../src/sites/_internal/SiteUiSchemaSettings"; | ||
import { MOCK_CONTEXT } from "../../mocks/mock-auth"; | ||
|
||
describe("buildUiSchema: site telemetry", () => { | ||
it("returns the full site telemetry uiSchema", async () => { | ||
const uiSchema = await buildUiSchema("some.scope", {} as any, MOCK_CONTEXT); | ||
expect(uiSchema).toEqual({ | ||
type: "Layout", | ||
elements: [ | ||
{ | ||
type: "Section", | ||
elements: [ | ||
{ | ||
scope: "/properties/telemetry/properties/consentNotice", | ||
type: "Control", | ||
options: { | ||
control: "arcgis-privacy-config", | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.