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

Create documents and themes for each workflow type #19

Merged
merged 6 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
63 changes: 41 additions & 22 deletions src/workflows/plm/actions/plmEmbeddedSpaceConfigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,55 @@ import { configureSpace } from '@flatfile/plugin-space-configure';
import * as plmBlueprints from '../blueprints/_index';
import { FlatfileListener } from '@flatfile/listener';
import { modifySheet } from '../../../shared/helpers/modifySheet';
import { embeddedSpaceTheme } from '@/workflows/plm/themes/embedded-space-theme';
import { embeddedSpaceDocument } from '@/workflows/plm/documents/embedded-space-document';
import api from '@flatfile/api';

const WORKBOOK_NAME = 'PLM Import';
const modifiedProducts = modifySheet(plmBlueprints.products);

export function plmEmbeddedSpaceConfigure(listener: FlatfileListener) {
listener.use(
configureSpace({
space: {
metadata: {
theme: {
// add theme here
configureSpace(
{
documents: [embeddedSpaceDocument],
workbooks: [
{
name: WORKBOOK_NAME,
namespace: 'plmImport',
sheets: [modifiedProducts],
actions: [
{
operation: 'submitAction',
mode: 'foreground',
constraints: [{ type: 'hasData' }],
label: 'Submit Data',
primary: true,
},
],
},
},
],
},
workbooks: [
{
name: WORKBOOK_NAME,
namespace: 'plmImport',
sheets: [modifiedProducts],
actions: [
{
operation: 'submitAction',
mode: 'foreground',
constraints: [{ type: 'hasData' }],
label: 'Submit Data',
primary: true,
async (event) => {
const { spaceId } = event.context;
const documents = await api.documents.list(spaceId);

// Get the first documentId
const documentId = documents.data[0]['id'];

// Update the space adding theme and setting the documentId as the default page
await api.spaces.update(spaceId, {
metadata: {
sidebarConfig: {
showSidebar: true,
defaultPage: {
documentId,
},
},
],
},
],
})
theme: embeddedSpaceTheme,
},
});
}
gaelyn marked this conversation as resolved.
Show resolved Hide resolved
)
);
}
63 changes: 41 additions & 22 deletions src/workflows/plm/actions/plmFileFeedSpaceConfigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,55 @@ import { configureSpace } from '@flatfile/plugin-space-configure';
import * as plmBlueprints from '../blueprints/_index';
import { FlatfileListener } from '@flatfile/listener';
import { modifySheet } from '../../../shared/helpers/modifySheet';
import { fileFeedSpaceTheme } from '@/workflows/plm/themes/file-feed-space-theme';
import { fileFeedSpaceDocument } from '@/workflows/plm/documents/file-feed-space-document';
import api from '@flatfile/api';

const WORKBOOK_NAME = 'PLM Import';
const modifiedProducts = modifySheet(plmBlueprints.products);

export function plmFileFeedSpaceConfigure(listener: FlatfileListener) {
listener.use(
configureSpace({
space: {
metadata: {
theme: {
// add theme here
configureSpace(
{
documents: [fileFeedSpaceDocument],
workbooks: [
{
name: WORKBOOK_NAME,
namespace: 'plmImport',
sheets: [modifiedProducts],
actions: [
{
operation: 'submitAction',
mode: 'foreground',
constraints: [{ type: 'hasData' }],
label: 'Submit Data',
primary: true,
},
],
},
},
],
},
workbooks: [
{
name: WORKBOOK_NAME,
namespace: 'plmImport',
sheets: [modifiedProducts],
actions: [
{
operation: 'submitAction',
mode: 'foreground',
constraints: [{ type: 'hasData' }],
label: 'Submit Data',
primary: true,
async (event) => {
const { spaceId } = event.context;
const documents = await api.documents.list(spaceId);

// Get the first documentId
const documentId = documents.data[0]['id'];

// Update the space adding theme and setting the documentId as the default page
await api.spaces.update(spaceId, {
metadata: {
sidebarConfig: {
showSidebar: true,
defaultPage: {
documentId,
},
},
],
},
],
})
theme: fileFeedSpaceTheme,
},
});
}
)
);
}
72 changes: 45 additions & 27 deletions src/workflows/plm/actions/plmProjectSpaceConfigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,59 @@ import api from '@flatfile/api';
import { WorkbookResponse } from '@flatfile/api/api';
import { attributes as attributesBlueprint } from '../blueprints/_index';
import { ProductsShowApiService } from '../../../shared/products-show-api-service';
import { projectSpaceTheme } from '@/workflows/plm/themes/project-space-theme';
import { projectSpaceDocument } from '@/workflows/plm/documents/project-space-document';

const WORKBOOK_NAME = 'PLM Import';

export function plmProjectSpaceConfigure(listener: FlatfileListener) {
listener.use(
configureSpace({
space: {
metadata: {
theme: {
// add theme here
configureSpace(
{
documents: [projectSpaceDocument],
workbooks: [
{
name: WORKBOOK_NAME,
namespace: 'plmImport',
sheets: [
plmBlueprints.attributes,
plmBlueprints.suppliers,
plmBlueprints.categories,
plmBlueprints.products,
],
actions: [
{
operation: 'submitAction',
mode: 'foreground',
constraints: [{ type: 'hasData' }],
label: 'Submit Data',
primary: true,
},
],
},
},
],
},
workbooks: [
{
name: WORKBOOK_NAME,
namespace: 'plmImport',
sheets: [
plmBlueprints.attributes,
plmBlueprints.suppliers,
plmBlueprints.categories,
plmBlueprints.products,
],
actions: [
{
operation: 'submitAction',
mode: 'foreground',
constraints: [{ type: 'hasData' }],
label: 'Submit Data',
primary: true,
async (event) => {
const { spaceId } = event.context;
const documents = await api.documents.list(spaceId);

// Get the first documentId
const documentId = documents.data[0]['id'];

// Update the space adding theme and setting the documentId as the default page
await api.spaces.update(spaceId, {
metadata: {
sidebarConfig: {
showSidebar: true,
defaultPage: {
documentId,
},
},
],
},
],
})
theme: projectSpaceTheme,
},
});
}
)
);

// Seed the workbook with data
Expand Down
Loading