Skip to content

Commit

Permalink
add test widget to activatePlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-i committed Dec 19, 2024
1 parent cc9c0b0 commit 3fd008c
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { NotebookJobsPanel } from './notebook-jobs-panel';
import { Scheduler } from './tokens';
import { SERVER_EXTENSION_404_JSX } from './util/errors';
import { MakeNameValid } from './util/job-name-validation';
import { WorkflowModelFactory } from './workflows/workflowModel';
import { WorkflowWidgetFactory } from './workflows/workflowWidgetFactory';

export namespace CommandIDs {
export const deleteJob = 'scheduling:delete-job';
Expand Down Expand Up @@ -194,10 +196,58 @@ function activatePlugin(
telemetryHandler: Scheduler.TelemetryHandler,
launcher: ILauncher | null
): void {
// Hardcoded boolean for testing. If true, set up workflow widget instead of scheduler UI
const showWorkflowsWidget = true;

const trans = translator.load('jupyterlab');
const api = new SchedulerService({});
verifyServerExtension({ api, translator });

if (showWorkflowsWidget) {
const WORKFLOW_FACTORY = 'Workflow Editor';
const WORKFLOW_CONTENT_TYPE = 'workflow';
const WORKFLOW_FILE_EXT = '.jwf';

// Register the workflow file type
app.docRegistry.addFileType({
name: WORKFLOW_CONTENT_TYPE,
displayName: 'Workflow File',
extensions: [WORKFLOW_FILE_EXT],
fileFormat: 'text',
contentType: 'file',
mimeTypes: ['application/json']
});

// Register the workflow model factory
const modelFactory = new WorkflowModelFactory();
app.docRegistry.addModelFactory(modelFactory);

// Register the workflow widget factory
const widgetFactory = new WorkflowWidgetFactory({
name: WORKFLOW_FACTORY,
modelName: modelFactory.name,
fileTypes: [WORKFLOW_CONTENT_TYPE],
defaultFor: [WORKFLOW_CONTENT_TYPE]
});
app.docRegistry.addWidgetFactory(widgetFactory);

// Create a new untitled .jwf file and open it
void app.commands
.execute('docmanager:new-untitled', {
type: 'file',
ext: '.jwf'
})
.then(model => {
if (model) {
void app.commands.execute('docmanager:open', {
path: model.path
});
}
});

return;
}

const { commands } = app;
const fileBrowserTracker = browserFactory.tracker;
const widgetTracker = new WidgetTracker<MainAreaWidget<NotebookJobsPanel>>({
Expand Down

0 comments on commit 3fd008c

Please sign in to comment.