Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
Remove broken contentful dependency. Update event name in integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ScopeyNZ committed Nov 18, 2021
1 parent 8a9466e commit 68e3eac
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 199 deletions.
22 changes: 13 additions & 9 deletions configuration-app/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { createSDK } from '@chec/integration-configuration-sdk';

import 'regenerator-runtime/runtime';
const contentful = require('contentful-management');

interface Option {
value: string,
label: string,
Expand Down Expand Up @@ -44,18 +41,27 @@ interface ContentfulConfig {
};

const updateSpacesDropdown = async (accessToken) => {
// Reset the client
const client = contentful.createClient({
accessToken,
// Load spaces from Contentful
const response = await fetch('https://api.contentful.com/spaces', {
mode: 'cors',
headers: {
'Authorization': `Bearer ${accessToken}`
},
});

if (response.status !== 200) {
return;
}

const spaces = (await response.json()).items;

// Asynchronously load organisations for the dropdown, and set the schema to have these new options
sdk.setSchema([
...baseFields,
{
...spacesField,
disabled: false,
options: (await client.getSpaces()).items.map((space) => ({
options: spaces.map((space) => ({
value: `o:${space.sys.organization.sys.id}==s:${space.sys.id}`,
label: space.name,
}))
Expand All @@ -73,8 +79,6 @@ interface ContentfulConfig {
sdk.onConfigUpdate(({
contentManagementApiKey,
}: ContentfulConfig) => {
console.log('hi');

// Check if the key has changed and we should reset everything
if (existingKey === contentManagementApiKey) {
return;
Expand Down
9 changes: 9 additions & 0 deletions dist/config/index.189c67c2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/config/index.189c67c2.js.map

Large diffs are not rendered by default.

Loading

1 comment on commit 68e3eac

@vercel
Copy link

@vercel vercel bot commented on 68e3eac Nov 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.