Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-it committed Jan 1, 2025
1 parent 046c118 commit 3c7c6e2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@
{
"command": "spfx-toolkit.setFormCustomizer",
"title": "Set Form Customizer",
"category": "SharePoint Framework Toolkit",
"icon": "$(file-code)"
"category": "SharePoint Framework Toolkit"
},
{
"command": "spfx-toolkit.showMoreActions",
Expand Down
2 changes: 1 addition & 1 deletion src/panels/CommandPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ export class CommandPanel {

actionCommands.push(new ActionTreeItem('Add new component', '', { name: 'add', custom: false }, undefined, Commands.addToProject));
actionCommands.push(new ActionTreeItem('Scaffold CI/CD Workflow', '', { name: 'rocket', custom: false }, undefined, Commands.pipeline));
actionCommands.push(new ActionTreeItem('View samples', '', { name: 'library', custom: false }, undefined, Commands.samplesGallery));
actionCommands.push(new ActionTreeItem('Set Form Customizer', '', { name: 'checklist', custom: false }, undefined, Commands.setFormCustomizer));
actionCommands.push(new ActionTreeItem('View samples', '', { name: 'library', custom: false }, undefined, Commands.samplesGallery));

window.registerTreeDataProvider('pnp-view-actions', new ActionTreeDataProvider(actionCommands));
}
Expand Down
39 changes: 30 additions & 9 deletions src/services/actions/CliActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,23 +928,43 @@ export class CliActions {
* Sets the form customizer for a content type on a list.
*/
public static async setFormCustomizer() {
const siteUrl = await window.showInputBox({
prompt: 'Enter the site URL',
const relativeUrl = await window.showInputBox({
prompt: 'Enter the relative URL of the site',
ignoreFocusOut: true,
validateInput: (value) => value ? undefined : 'Site URL is required'
placeHolder: 'e.g., sites/sales',
validateInput: (input) => {
if (!input) {
return 'site URL is required';
}

const trimmedInput = input.trim();

if (trimmedInput.startsWith('https://')) {
return 'Please provide a relative URL, not an absolute URL.';
}
if (trimmedInput.startsWith('/')) {
return 'Please provide a relative URL without a leading slash.';
}

return undefined;
}
});

if (!siteUrl) {
if (relativeUrl === undefined) {
Notifications.warning('No site URL provided. Setting form customizer aborted.');
return;
}

const siteUrl = `${EnvironmentInformation.tenantUrl}/${relativeUrl.trim()}`;

const listTitle = await window.showInputBox({
prompt: 'Enter the list title',
ignoreFocusOut: true,
validateInput: (value) => value ? undefined : 'List title is required'
});

if (!listTitle) {
Notifications.warning('No list title provided. Setting form customizer aborted.');
return;
}

Expand All @@ -955,21 +975,22 @@ export class CliActions {
});

if (!contentType) {
Notifications.warning('No content type name provided. Setting form customizer aborted.');
return;
}

const editFormClientSideComponentId = await window.showInputBox({
prompt: 'Enter the Edit form customizer (leave empty to skip)',
prompt: 'Enter the Edit form customizer ID (leave empty to skip)',
ignoreFocusOut: true
});

const newFormClientSideComponentId = await window.showInputBox({
prompt: 'Enter the New form customizer (leave empty to skip)',
const newFormClientSideComponentId = await window.showInputBox({
prompt: 'Enter the New form customizer ID (leave empty to skip)',
ignoreFocusOut: true
});

const displayFormClientSideComponentId = await window.showInputBox({
prompt: 'Enter the View form customizer (leave empty to skip)',
prompt: 'Enter the View form customizer ID (leave empty to skip)',
ignoreFocusOut: true
});

Expand All @@ -984,7 +1005,7 @@ export class CliActions {
}

if (newFormClientSideComponentId ) {
commandOptions.newFormCustomizer = newFormClientSideComponentId ;
commandOptions.NewFormClientSideComponentId = newFormClientSideComponentId ;
}

if (displayFormClientSideComponentId) {
Expand Down

0 comments on commit 3c7c6e2

Please sign in to comment.