Skip to content

Commit

Permalink
fix: TemporaryStorageField widget
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Orel <[email protected]>
  • Loading branch information
olexii4 committed Oct 9, 2024
1 parent 04b25a7 commit 165b1f2
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 52 deletions.
2 changes: 0 additions & 2 deletions packages/common/src/dto/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ export interface IDevWorkspaceList {
export interface IDevWorkspaceResources {
devfileContent: string | undefined;
editorPath: string | undefined;
pluginRegistryUrl: string | undefined;
editorId: string | undefined;
editorContent: string | undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ export function registerDevworkspaceResourcesRoute(instance: FastifyInstance) {
`${baseApiPath}/devworkspace-resources`,
getSchema({ tags, body: devWorkspaceResourcesSchema }),
async function (request: FastifyRequest) {
const { devfileContent, editorPath, pluginRegistryUrl, editorId, editorContent } =
const { devfileContent, editorPath, editorContent } =
request.body as api.IDevWorkspaceResources;
const context = await generator.generateDevfileContext(
{
devfileContent,
editorPath,
pluginRegistryUrl,
editorEntry: editorId,
pluginRegistryUrl: undefined,
editorEntry: undefined,
editorContent,
projects: [],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ exports[`TemporaryStorageField switched off snapshot 1`] = `
data-ouia-component-id="OUIA-Generated-Switch-1"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="temporary-storage-switch"
htmlFor="adv-temporary-storage-switch"
>
<input
aria-label="Temporary Storage"
aria-labelledby={null}
checked={false}
className="pf-c-switch__input"
disabled={false}
id="temporary-storage-switch"
id="adv-temporary-storage-switch"
onChange={[Function]}
type="checkbox"
/>
Expand Down Expand Up @@ -92,15 +92,15 @@ exports[`TemporaryStorageField switched on snapshot 1`] = `
data-ouia-component-id="OUIA-Generated-Switch-2"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="temporary-storage-switch"
htmlFor="adv-temporary-storage-switch"
>
<input
aria-label="Temporary Storage"
aria-labelledby={null}
checked={true}
className="pf-c-switch__input"
disabled={false}
id="temporary-storage-switch"
id="adv-temporary-storage-switch"
onChange={[Function]}
type="checkbox"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ exports[`TemporaryStorageField switched off snapshot 1`] = `
data-ouia-component-id="OUIA-Generated-Switch-1"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="temporary-storage-switch"
htmlFor="adv-temporary-storage-switch"
>
<input
aria-label="Temporary Storage"
aria-labelledby={null}
checked={false}
className="pf-c-switch__input"
disabled={false}
id="temporary-storage-switch"
id="adv-temporary-storage-switch"
onChange={[Function]}
type="checkbox"
/>
Expand Down Expand Up @@ -92,15 +92,15 @@ exports[`TemporaryStorageField switched on snapshot 1`] = `
data-ouia-component-id="OUIA-Generated-Switch-2"
data-ouia-component-type="PF4/Switch"
data-ouia-safe={true}
htmlFor="temporary-storage-switch"
htmlFor="adv-temporary-storage-switch"
>
<input
aria-label="Temporary Storage"
aria-labelledby={null}
checked={true}
className="pf-c-switch__input"
disabled={false}
id="temporary-storage-switch"
id="adv-temporary-storage-switch"
onChange={[Function]}
type="checkbox"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class TemporaryStorageField extends React.PureComponent<Props, State> {
return (
<FormGroup label="Temporary Storage">
<Switch
id="temporary-storage-switch"
id="adv-temporary-storage-switch"
aria-label="Temporary Storage"
isChecked={isTemporary}
onChange={value => this.handleChange(value)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ describe('Workspace-client helpers', () => {
});

describe('Look for the custom editor', () => {
const pluginRegistryUrl = 'https://dummy-plugin-registry';
let optionalFilesContent: { [fileName: string]: string };
let editor: devfileApi.Devfile;

Expand All @@ -285,7 +284,6 @@ describe('Workspace-client helpers', () => {
it('should return undefined without optionalFilesContent', async () => {
const store = new FakeStoreBuilder().build();
const customEditor = await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
store.dispatch,
store.getState,
Expand All @@ -300,7 +298,6 @@ describe('Workspace-client helpers', () => {
const store = new FakeStoreBuilder().build();

const customEditor = await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
store.dispatch,
store.getState,
Expand All @@ -324,7 +321,6 @@ describe('Workspace-client helpers', () => {
const store = new FakeStoreBuilder().build();

const customEditor = await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
store.dispatch,
store.getState,
Expand All @@ -342,12 +338,7 @@ describe('Workspace-client helpers', () => {
let errorText: string | undefined;

try {
await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
store.dispatch,
store.getState,
);
await getCustomEditor(optionalFilesContent, store.dispatch, store.getState);
} catch (e) {
errorText = common.helpers.errors.getMessage(e);
}
Expand Down Expand Up @@ -393,7 +384,6 @@ describe('Workspace-client helpers', () => {
.build();

const customEditor = await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
store.dispatch,
store.getState,
Expand Down Expand Up @@ -452,7 +442,6 @@ describe('Workspace-client helpers', () => {
.build();

const customEditor = await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
store.dispatch,
store.getState,
Expand Down Expand Up @@ -505,12 +494,7 @@ describe('Workspace-client helpers', () => {

let errorText: string | undefined;
try {
await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
store.dispatch,
store.getState,
);
await getCustomEditor(optionalFilesContent, store.dispatch, store.getState);
} catch (e) {
errorText = common.helpers.errors.getMessage(e);
}
Expand Down Expand Up @@ -539,7 +523,6 @@ describe('Workspace-client helpers', () => {
.build();

const customEditor = await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
store.dispatch,
store.getState,
Expand Down Expand Up @@ -573,7 +556,6 @@ describe('Workspace-client helpers', () => {
.build();

const customEditor = await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
store.dispatch,
store.getState,
Expand Down Expand Up @@ -602,12 +584,7 @@ describe('Workspace-client helpers', () => {

let errorText: string | undefined;
try {
await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
store.dispatch,
store.getState,
);
await getCustomEditor(optionalFilesContent, store.dispatch, store.getState);
} catch (e) {
errorText = common.helpers.errors.getMessage(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export const CHE_EDITOR_YAML_PATH = '.che/che-editor.yaml';
* Look for the custom editor in .che/che-editor.yaml
*/
export async function getCustomEditor(
pluginRegistryUrl: string | undefined,
optionalFilesContent: { [fileName: string]: string },
dispatch: ThunkDispatch<AppState, unknown, KnownAction>,
getState: () => AppState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,8 @@ export const actionCreators: ActionCreators = {
editorContent = updateEditorDevfile(editorContent, editorImage);
}
const resourcesContent = await fetchResources({
pluginRegistryUrl,
devfileContent: dump(defaultsDevfile),
editorPath: undefined,
editorId: undefined,
editorContent,
});
const resources = loadResourcesContent(resourcesContent);
Expand Down Expand Up @@ -877,7 +875,6 @@ export const actionCreators: ActionCreators = {
): AppThunk<KnownAction, Promise<void>> =>
async (dispatch, getState): Promise<void> => {
const state = getState();
const pluginRegistryUrl = selectPluginRegistryUrl(state);
let devWorkspaceResource: devfileApi.DevWorkspace;
let devWorkspaceTemplateResource: devfileApi.DevWorkspaceTemplate;
let editorContent: string | undefined;
Expand All @@ -895,12 +892,7 @@ export const actionCreators: ActionCreators = {
} else {
// do we have the custom editor in `.che/che-editor.yaml` ?
try {
editorContent = await getCustomEditor(
pluginRegistryUrl,
optionalFilesContent,
dispatch,
getState,
);
editorContent = await getCustomEditor(optionalFilesContent, dispatch, getState);
if (!editorContent) {
console.warn('No custom editor found');
}
Expand Down Expand Up @@ -932,10 +924,8 @@ export const actionCreators: ActionCreators = {
}
editorContent = updateEditorDevfile(editorContent, params.editorImage);
const resourcesContent = await fetchResources({
pluginRegistryUrl,
devfileContent: dump(devfile),
editorPath: undefined,
editorId: undefined,
editorContent: editorContent,
});
const resources = loadResourcesContent(resourcesContent);
Expand Down

0 comments on commit 165b1f2

Please sign in to comment.