Skip to content

Commit

Permalink
clean and remove unneeded snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
salim-1997 committed Jul 14, 2022
1 parent e6b43f0 commit e015442
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,16 @@ const EditorView = ({
sidebar,
name,
}) => {
const [tabs, setTabs] = useState([]);
const [options, setOptions] = useState({
tabs: new Array(),
selectedTabID: '1',
});
useEffect(() => {
// console.log('tabs', tabs);
// if (tabs) {
// setTabs(() => {
// tabs.push({
// id: name,
// title: name,
// panelContent: value,
// });
// return tabs;
// });
// let newTab = tabs[tabs.length - 1];
// console.log('newTab', newTab);
// if (tabs.length !== 0) {
if (name) {
if (name && value) {
ready((instance) => {
_instance = instance;
});
_instance.open({
let newInstance = {
id: name,
title: name,
panelComponent: () => (
Expand All @@ -84,15 +74,19 @@ const EditorView = ({
readOnly={readOnly}
/>
),
};
_instance.open(newInstance);
_instance.select(name);
setOptions(() => {
let isExisting = options.tabs.some((e) => {
return e.id === newInstance.id;
});
console.log('isExisting', isExisting);
if (!isExisting) {
options.tabs.push(newInstance);
}
return options;
});
if (name) {
_instance.select(name);
}
console.log('optins.tabs', options.tabs);
if (options.tabs.length > 5) {
console.log('reached the most amount of tabs', options.tabs[0]);
_instance.close(options.tabs[0].id);
}
}
}, [name]);

Expand All @@ -108,10 +102,6 @@ const EditorView = ({
const isLiveSelected = currentVersion === 'live';
const configurationType = getConfigurationType(value);

let options = {
tabs,
selectedTabID: '1',
};
let _instance = _instance;
const [TabList, PanelList, ready] = useDynTabs(options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,6 @@ class ConfigurationView extends React.Component {
this.props.selectFile(filename);
};

/* Adds a new child object containing the name and the content of the newely clicked file */
addToChildren = (newName, newFileContent) => {
function isSameId(child) {
return child.id === newName;
}
if (this.state.tabs.filter(isSameId).length === 0) {
// console.log('newName', newName);
let newChild = {
id: newName,
title: newName,
panelContent: newFileContent,
};
// if (!this.state.tabs.includes(newChild)) {
let tabs = this.state.tabs;
tabs.push(newChild);
this.setState({ tabs: tabs });
// console.log('tabs: ', this.state.tabs);
}
};
render() {
const {
selection,
Expand All @@ -199,8 +180,6 @@ class ConfigurationView extends React.Component {
const readOnly = !canWrite || !!selectedDefaultConfigFile || !isLatestVersion;

const fileContentWithoutFirstLine = fileContent ? fileContent.split('\n').slice(1).join('\n') : '';
// console.log('name', name);
this.addToChildren(name, fileContent);

return (
<div className="this">
Expand Down

0 comments on commit e015442

Please sign in to comment.