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

chore: remove version in manifest json file name #8414

Merged
merged 7 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,9 @@

import { getManifestId } from '../content';

const skillManifest = {
id: 'test',
content: {
$schema: 'https://schemas.botframework.com/schemas/skills/skill-manifest-2.1.1.json',
},
};

describe('geManifestId', () => {
it('should generate valid id without manifest schema version', () => {
const result = getManifestId('test', [], {});
const result = getManifestId('test');
expect(result).toEqual('test-manifest');
});

it('should generate valid, non-conflicting id without manifest schema version', () => {
const skillManifests: any = [{ id: 'test-manifest' }, { id: 'test-manifest-0' }];
const result = getManifestId('test', skillManifests, {});
expect(result).toEqual('test-manifest-1');
});

it('should generate valid id with manifest schema version', () => {
const result = getManifestId('test', [], skillManifest);
expect(result).toEqual('test-2-1-1-manifest');
});

it('should generate valid, non-conflicting id with manifest schema version', () => {
const skillManifests: any = [{ id: 'test-2-1-1-manifest' }, { id: 'test-2-1-1-manifest-0' }];
const result = getManifestId('test', skillManifests, skillManifest);
expect(result).toEqual('test-2-1-1-manifest-1');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { SkillManifestFile } from '@bfc/shared';
import startCase from 'lodash/startCase';
import { SDKKinds } from '@bfc/shared';

import { nameRegex } from '../../../constants';

import { Description, ReviewManifest, SaveManifest, SelectDialogs, SelectTriggers } from './content';
import { SelectProfile } from './content/SelectProfile';
import { Description, ReviewManifest, SelectDialogs, SelectTriggers, SelectProfile } from './content';
import { AddCallers } from './content/AddCallers';

export const VERSION_REGEX = /\d\.\d+\.(\d+|preview-\d+)|\d\.\d+/i;
Expand Down Expand Up @@ -123,7 +120,6 @@ interface EditorStep {
export enum ManifestEditorSteps {
MANIFEST_DESCRIPTION = 'MANIFEST_DESCRIPTION',
MANIFEST_REVIEW = 'MANIFEST_REVIEW',
SAVE_MANIFEST = 'SAVE_MANIFEST',
SELECT_DIALOGS = 'SELECT_DIALOGS',
SELECT_TRIGGERS = 'SELECT_TRIGGERS',
SELECT_PROFILE = 'SELECT_PROFILE',
Expand Down Expand Up @@ -296,35 +292,4 @@ export const editorSteps: { [key in ManifestEditorSteps]: EditorStep } = {
title: () => formatMessage('Select triggers'),
helpLink,
},
[ManifestEditorSteps.SAVE_MANIFEST]: {
buttons: [
cancelButton,
backButton,
{
primary: true,
text: () => formatMessage('Save'),
onClick: ({ onNext }) => () => {
onNext({ dismiss: true, save: true });
},
},
],
content: SaveManifest,
editJson: false,
subText: () => formatMessage('Name and save your skill manifest.'),
title: () => formatMessage('Save your skill manifest'),
validate: ({ editingId, id, skillManifests }) => {
if (!id || !nameRegex.test(id)) {
return { id: formatMessage('Spaces and special characters are not allowed. Use letters, numbers, -, or _.') };
}

if (
(typeof editingId === 'undefined' || editingId !== id) &&
skillManifests.some(({ id: manifestId }) => manifestId === id)
) {
return { id: formatMessage('{id} already exists. Please enter a unique file name.', { id }) };
}

return {};
},
},
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/** @jsx jsx */
import { css, jsx } from '@emotion/core';
import { PublishTarget, SkillManifestFile } from '@bfc/shared';
import { PublishTarget } from '@bfc/shared';
import formatMessage from 'format-message';
import React, { Fragment, useEffect, useMemo, useState } from 'react';
import { useRecoilValue } from 'recoil';
Expand All @@ -15,10 +15,10 @@ import { NeutralColors } from '@uifabric/fluent-theme';
import { MessageBar, MessageBarType } from 'office-ui-fabric-react/lib/MessageBar';
import { Link } from 'office-ui-fabric-react/lib/Link';

import { botDisplayNameState, dispatcherState, settingsState, skillManifestsState } from '../../../../recoilModel';
import { botDisplayNameState, dispatcherState, settingsState } from '../../../../recoilModel';
import { CreatePublishProfileDialog } from '../../../botProject/CreatePublishProfileDialog';
import { iconStyle } from '../../../botProject/runtime-settings/style';
import { ContentProps, VERSION_REGEX } from '../constants';
import { ContentProps } from '../constants';
import { PublishProfileWrapperDialog } from '../../../botProject/PublishProfieWrapperDialog';

const styles = {
Expand Down Expand Up @@ -74,25 +74,8 @@ const onRenderInvalidProfileWarning = (hasValidProfile, handleShowPublishProfile
);
};

export const getManifestId = (
botName: string,
skillManifests: SkillManifestFile[],
{ content: { $schema } = {} }: Partial<SkillManifestFile>
): string => {
const [version] = VERSION_REGEX.exec($schema) || [''];

let fileId = version ? `${botName}-${version.replace(/\./g, '-')}-manifest` : `${botName}-manifest`;
let i = -1;

while (skillManifests.some(({ id }) => id === fileId) && i < skillManifests.length) {
if (i < 0) {
fileId = fileId.concat(`-${++i}`);
} else {
fileId = fileId.substr(0, fileId.lastIndexOf('-')).concat(`-${++i}`);
}
}

return fileId;
export const getManifestId = (botName: string): string => {
return `${botName}-manifest`;
};

const onRenderTitle = (options: IDropdownOption[] | undefined): JSX.Element | null => {
Expand Down Expand Up @@ -129,7 +112,6 @@ export const SelectProfile: React.FC<ContentProps> = ({
const [appId, setAppId] = useState<string>();
const { id, content } = manifest;
const botName = useRecoilValue(botDisplayNameState(projectId));
const skillManifests = useRecoilValue(skillManifestsState(projectId));

const [showCreateProfileDialog, setShowCreateProfileDialog] = useState(true);
const [selectedKey, setSelectedKey] = useState('');
Expand Down Expand Up @@ -219,10 +201,8 @@ export const SelectProfile: React.FC<ContentProps> = ({
}, [settings]);

useEffect(() => {
if (!id) {
const fileId = getManifestId(botName, skillManifests, manifest);
setSkillManifest({ ...manifest, id: fileId });
}
const fileId = getManifestId(botName);
setSkillManifest({ ...manifest, id: fileId });
}, [id]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
export * from './Description';
export * from './Endpoints';
export * from './ReviewManifest';
export * from './SaveManifest';
export * from './SelectDialogs';
export * from './SelectTriggers';
export * from './SelectProfile';
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import { DefaultButton, PrimaryButton } from 'office-ui-fabric-react/lib/Button'
import { JSONSchema7 } from '@bfc/extension-client';
import { Link } from 'office-ui-fabric-react/lib/components/Link';
import { useRecoilValue } from 'recoil';
import { PublishTarget, SkillManifestFile } from '@bfc/shared';
import { isUsingAdaptiveRuntime, PublishTarget, SkillManifestFile } from '@bfc/shared';
import { navigate } from '@reach/router';
import { isUsingAdaptiveRuntime } from '@bfc/shared';
import cloneDeep from 'lodash/cloneDeep';

import { Notification } from '../../../recoilModel/types';
Expand Down